pax_global_header 0000666 0000000 0000000 00000000064 14003045566 0014515 g ustar 00root root 0000000 0000000 52 comment=29be6ea9edfc979d25a302b4eb170f852f4e0a7c
GlibD-2.3.0/ 0000775 0000000 0000000 00000000000 14003045566 0012500 5 ustar 00root root 0000000 0000000 GlibD-2.3.0/AUTHORS 0000664 0000000 0000000 00000000234 14003045566 0013547 0 ustar 00root root 0000000 0000000 GTKD AUTHORS (alphabetical by last name)
Frank Benoit
Jake Day
Jonas Kivi
Alan Knowles
Antonio Monteiro
Sebastián E. Peyrott
John Reimer
Mike Wey
hauptmech GlibD-2.3.0/COPYING 0000664 0000000 0000000 00000021554 14003045566 0013542 0 ustar 00root root 0000000 0000000 The GtkD library and included works are provided under the terms of the
GNU Library General Public License (LGPL) version 3, or (at your option)
any later version, with the following exceptions:
1. Modifications to any of the works included within the GtkD library to support a specific
platform or application do not constitute a modified or derivative work.
2. Static linking of applications or any other source to the GtkD library does not constitute a
modified or derivative work and does not require the author(s) to provide source code for said
work, use the shared GtkD libraries, or link their applications against a user-supplied version
of GtkD. If you link applications to a modified version of GtkD, then the changes to GtkD must be
provided under the terms of the LGPL.
3. You do not have to provide a copy of the GtkD license with applications that are linked to the
GtkD library, nor do you have to identify GtkD's license in your application as required by the
LGPL. However, applications must still identify their use of GtkD. The following example statement
can be included in the application or it's documentation to satisfy this requirement:
[application] is based in part on works of the GtkD project (https://gtkd.org).
The above exceptions are temporary and are subject to change at any time.
---------------------------------------------------------------------------------------------------
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
GlibD-2.3.0/README.md 0000664 0000000 0000000 00000000656 14003045566 0013766 0 ustar 00root root 0000000 0000000 # GlibD
D bindings for the GLib C Utility Library.
please view COPYING for GlibD's license.
## Building
For building you will need the GLib and Gobject Introspection development files, and the [gir-to-d](https://github.com/gtkd-developers/gir-to-d) tool.
Both [dub](https://code.dlang.org/) and [Meson](https://mesonbuild.com) build files are available.
Compiling with meson:
```
$ meson builddir && cd builddir
$ ninja
```
GlibD-2.3.0/dub.json 0000664 0000000 0000000 00000001540 14003045566 0014145 0 ustar 00root root 0000000 0000000 {
"name": "glibd",
"targetType": "library",
"targetName": "glibd-2",
"sourcePaths": ["generated"],
"importPaths": ["generated"],
"description": "GlibD is the Digital Mars D programing language OO wrapper for Glib.",
"homepage": "http://gtkd.org",
"license": "LGPL license with additional exceptions",
"authors": [
"Frank Benoit",
"Jake Day",
"Jonas Kivi",
"Alan Knowles",
"Antonio Monteiro",
"Sebastián E. Peyrott",
"John Reimer",
"Mike Wey",
"hauptmech"
],
"preGenerateCommands-posix": [
"dub fetch girtod || true",
"cd $PACKAGE_DIR && dub run girtod -- -i src -o generated --use-runtime-linker"
],
"preGenerateCommands-windows": [
"dub fetch girtod || VER>NUL",
"cd $PACKAGE_DIR && dub run girtod -- -i src -o generated --use-runtime-linker"
]
}
GlibD-2.3.0/meson.build 0000664 0000000 0000000 00000004321 14003045566 0014642 0 ustar 00root root 0000000 0000000 project('GlibD', 'd',
license: 'LGPL-3.0',
version: '2.2.0'
)
project_soversion = 0
pkg_conf = import('pkgconfig')
source_root = meson.current_source_dir()
build_root = meson.current_build_dir()
gen_dir = 'generated'
#
# Dependencies
#
glib_dep = dependency('glib-2.0')
gmodule_dep = dependency('gmodule-2.0')
gobject_dep = dependency('gobject-2.0')
gio_dep = dependency('gio-2.0')
# The Glib gir files are part of the gobject introspection package.
introspection_dep = dependency('gobject-introspection-1.0')
#
# Build interfaces from GIR
#
gir_to_d_prog = find_program('girtod')
gir_wrap_dir = join_paths(source_root, 'src')
gir_d_intf_dir = join_paths(build_root, gen_dir)
message('Generating D interfaces from GIR...')
girtod_gen = run_command(gir_to_d_prog,
'-i', gir_wrap_dir,
'-o', gir_d_intf_dir,
'--print-files', 'relative,' + source_root)
if girtod_gen.returncode() != 0
error('Unable to build D intefaces from GIR:\n' + girtod_gen.stderr())
endif
gir_bind_dir = include_directories(gen_dir)
# Enlist D GIR interface sources
gir_binding_sources = girtod_gen.stdout().strip().split('\n')
glibd = library('glibd-2.0',
[gir_binding_sources],
include_directories: [gir_bind_dir],
dependencies: [glib_dep, gmodule_dep, gobject_dep, gio_dep],
install: true,
soversion: project_soversion,
version: meson.project_version())
install_subdir(join_paths(build_root, gen_dir, 'glib'), install_dir: 'include/d/glibd-2/')
install_subdir(join_paths(build_root, gen_dir, 'gio'), install_dir: 'include/d/glibd-2/')
install_subdir(join_paths(build_root, gen_dir, 'gobject'), install_dir: 'include/d/glibd-2/')
install_subdir(join_paths(build_root, gen_dir, 'gtkd'), install_dir: 'include/d/glibd-2/')
pkg_conf.generate(glibd,
name: 'glibd-2.0',
subdirs: 'd/glibd-2',
version: meson.project_version(),
requires: [glib_dep, gmodule_dep, gio_dep, gobject_dep],
description: 'D bindings for the GLib C Utility Library.')
# for use by others which embed this as subproject
glibd_dep = declare_dependency(
link_with: [glibd],
include_directories: [gir_bind_dir]
)
subdir('tests')
GlibD-2.3.0/src/ 0000775 0000000 0000000 00000000000 14003045566 0013267 5 ustar 00root root 0000000 0000000 GlibD-2.3.0/src/APILookup.txt 0000664 0000000 0000000 00000003566 14003045566 0015645 0 ustar 00root root 0000000 0000000 #
# This file is part of gtkD.
#
# gtkD is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version, with
# some exceptions, please read the COPYING file.
#
# gtkD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with gtkD; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
#
# define the license to use
license: start
/*
* This file is part of gtkD.
*
* gtkD is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 3
* of the License, or (at your option) any later version, with
* some exceptions, please read the COPYING file.
*
* gtkD is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with gtkD; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
*/
// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities the gir-to-d pakage
license: end
outputRoot: generated
copy: gtkd
lookup: APILookupGLib.txt
lookup: APILookupGObject.txt
lookup: APILookupGio.txt
GlibD-2.3.0/src/APILookupGLib.txt 0000664 0000000 0000000 00000135725 14003045566 0016406 0 ustar 00root root 0000000 0000000 # This file is part of gtkD.
#
# gtkD is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# gtkD is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with gtkD; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#############################################
### Definitions for wrapping Gtk+ ###########
#############################################
# must start with wrap
wrap: glib
file: GLib-2.0.gir
file: GModule-2.0.gir
addAliases: start
public alias uint uid_t;
public alias int pid_t;
version( Windows )
{
alias int glong;
alias uint gulong;
}
else version( X86_64 )
{
alias long glong;
alias ulong gulong;
}
else
{
alias int glong;
alias uint gulong;
}
version (Windows)
{
private import core.stdc.stdio;
static if( !is(typeof(fdopen(0, null))) )
{
extern (C) FILE* fdopen(int, char*);
}
}
struct Scoped(T)
{
T payload;
alias payload this;
@disable this();
@disable this(this);
~this()
{
.destroy(payload);
}
}
auto getScopedGobject(T, Args...)(auto ref Args args) if (is(T == class))
{
Scoped!(T) result = void;
result.payload = new T(args);
return result;
}
/**
* Get the length of a zero terminated array.
*/
size_t getArrayLength(T)(T* arr)
{
size_t len;
for ( ; arr[len]; len++ ){}
return len;
}
unittest
{
assert(getArrayLength("aaaaaaaaa\0".ptr) == 9);
}
Type* gMalloc(Type)()
{
import glib.c.functions;
return cast(Type*)g_malloc0(Type.sizeof);
}
alias void* GIConv;
addAliases: end
addEnums: start
enum GPriority
{
HIGH = -100,
DEFAULT = 0,
HIGH_IDLE = 100,
DEFAULT_IDLE = 200,
LOW = 300
}
addEnums: end
noConstant: DIR_SEPARATOR
noConstant: DIR_SEPARATOR_S
noConstant: E
noConstant: LN10
noConstant: LN2
noConstant: LOG_2_BASE_10
noConstant: PI
noConstant: PI_2
noConstant: PI_4
noConstant: SEARCHPATH_SEPARATOR
noConstant: SEARCHPATH_SEPARATOR_S
noConstant: SQRT2
noConstant: VERSION_MIN_REQUIRED
struct: Array
class: ArrayG
struct: Base64
move: base64_decode_step Base64 decode_step
move: base64_decode_inplace Base64 decode_inplace
noCode: decode_step
array: decode_inplace Return out_len
code: start
/**
* Incrementally decode a sequence of binary data from its Base-64 stringified
* representation. By calling this function multiple times you can convert
* data in chunks to avoid having to have the full encoded data in memory.
*
* The output buffer must be large enough to fit all the data that will
* be written to it. Since base64 encodes 3 bytes in 4 chars you need
* at least: (@len / 4) * 3 + 3 bytes (+ 3 may be needed in case of non-zero
* state).
*
* Params:
* inn = binary input data
* len = max length of @in data to decode
* output = output buffer
* state = Saved state between steps, initialize to 0
* save = Saved state between steps, initialize to 0
*
* Return: The number of bytes of output that was written
*
* Since: 2.12
*/
public static size_t decodeStep(string inn, ref ubyte[] output, ref int state, ref uint save)
{
auto p = g_base64_decode_step(Str.toStringz(inn), cast(int)inn.length, cast(char*)output.ptr, &state, &save);
return p;
}
code: end
struct: BookmarkFile
out: load_from_data_dirs full_path
array: set_groups groups length
struct: ByteArray
class: ByteArray
struct: Bytes
noCode: new_take
noCode: new_static
struct: Checksum
noCode: get_digest
code: start
/**
* Gets the digest from checksum as a raw binary vector and places it
* into buffer. The size of the digest depends on the type of checksum.
*
* Once this function has been called, the Checksum is closed and can
* no longer be updated with update().
*
* Params:
* buffer = output buffer
* digestLen = an inout parameter. The caller initializes it to the size of buffer.
* After the call it contains the length of the digest.
*
* Since: 2.16
*/
public void getDigest(ref ubyte[] buffer)
{
size_t digestLen = buffer.length;
g_checksum_get_digest(gChecksum, buffer.ptr, &digestLen);
buffer = buffer[0 .. digestLen];
}
code: end
struct: ConstructionException
namespace:
code: start
class ConstructionException : Exception
{
this(string message)
{
super(message);
}
override string toString()
{
return "Construction failure, " ~ msg;
}
}
code: end
struct: DateTime
structWrap: gpointer DateTime
noCode: new_now_utc
noCode: new_now_local
noCode: new_from_unix_local
noCode: new_from_unix_utc
noCode: new_from_timeval_local
noCode: new_from_timeval_utc
noCode: new_local
noCode: new_utc
noCode: hash
code: start
/**
* Creates a DateTime corresponding to the given Unix time t
* Unix time is the number of seconds that have elapsed since 1970-01-01
* 00:00:00 UTC, regardless of the local time offset.
*
* This call can fail (ConstructionException) if t represents a time outside
* of the supported range of GDateTime.
* You should release the return value by calling unref()
* when you are done with it
*
* Params:
* t = the Unix time
* utc = If true use utc else use the local timezone.
*
* Throws: ConstructionException GTK+ fails to create the object.
*
* Since: 2.26
*/
public this (long t, bool utc = true)
{
GDateTime* p;
if ( utc )
{
p = g_date_time_new_from_unix_utc(t);
}
else
{
p = g_date_time_new_from_unix_local(t);
}
if(p is null)
{
throw new ConstructionException("null returned by g_date_time_new_from_unix_local(t)");
}
this(cast(GDateTime*) p);
}
/**
* Creates a DateTime corresponding to the given TimeVal tv.
* The time contained in a TimeVal is always stored in the form of
* seconds elapsed since 1970-01-01 00:00:00 UTC, regardless of the
* local time offset.
*
* This call can fail (ConstructionException) if tv represents a time outside
* of the supported range of DateTime.
* You should release the return value by calling unref()
* when you are done with it.
*
* Params:
* tv = a GTimeVal
* utc = If true use utc else use the local timezone.
*
* Throws: ConstructionException GTK+ fails to create the object.
*
* Since: 2.26
*/
public this (ref GTimeVal tv, bool utc = true)
{
GDateTime* p;
if ( utc )
{
p = g_date_time_new_from_timeval_utc(&tv);
}
else
{
p = g_date_time_new_from_timeval_local(&tv);
}
if(p is null)
{
throw new ConstructionException("null returned by g_date_time_new_from_timeval_local((tv is null) ? null : tv.getTimeValStruct())");
}
this(cast(GDateTime*) p);
}
/** */
override bool opEquals(Object rhs)
{
DateTime date = cast(DateTime)rhs;
if ( date is null )
return false;
return equal(this, date) != 0;
}
/** */
override int opCmp(Object rhs)
{
DateTime date = cast(DateTime)rhs;
if ( date is null )
return int.min;
return compare(this, date);
}
/** */
override nothrow @trusted hash_t toHash()
{
return hash();
}
/**
* Hashes datetime into a guint, suitable for use within GHashTable.
* Since 2.26
* Params:
* datetime = a GDateTime
* Returns: a guint containing the hash
*/
public nothrow @trusted uint hash()
{
try
{
return g_date_time_hash(gDateTime);
}
catch(Exception e)
{
return 0;
}
}
code: end
struct: Dir
class: Directory
struct: Error
class: ErrorG
move: propagate_error Error
move: set_error_literal Error
out: set_error_literal err
out: propagate_error dest
struct: GException
namespace:
import: glib.ErrorG
import: glib.Str
code: start
class GException : Exception
{
ErrorG error;
this(ErrorG error)
{
super( Str.toString(error.getErrorGStruct().message) );
this.error = error;
}
}
code: end
struct: GLib
namespace:
code: start
static import glib.Version;
deprecated("moves to the glib.Version module")
alias glib.Version.Version Version;
code: end
struct: HashTable
class: HashTable
struct: Hmac
noCode: get_digest
move: compute_hmac_for_data Hmac
move: compute_hmac_for_string Hmac
move: compute_hmac_for_bytes Hmac
array: compute_hmac_for_data data length
array: compute_hmac_for_string str length
code: start
/**
* Gets the digest from checksum as a raw binary array and places it
* into buffer. The size of the digest depends on the type of checksum.
*
* Once this function has been called, the Hmac is closed and can
* no longer be updated with update().
*
* Params:
* buffer = output buffer
*
* Since: 2.30
*/
public void getDigest(ref ubyte[] buffer)
{
size_t digestLen = buffer.length;
g_hmac_get_digest(gHmac, buffer.ptr, &digestLen);
buffer = buffer[0 .. digestLen];
}
code: end
struct: IConv
namespace:
noStruct: true
ref: iconv inbuf
out: iconv inbytes_left
array: iconv inbuf inbytes_left
ref: iconv outbuf
out: iconv outbytes_left
array: iconv outbuf outbytes_left
struct: Idle
class: Idle
cType:
code: start
/** Holds all idle delegates */
private bool delegate()[] idleListeners;
/** Our idle ID */
private uint idleID;
/** The priority this class was instantiated with */
private GPriority priority = GPriority.DEFAULT_IDLE;
/**
* Creates a new idle cycle.
* Params:
* dlg = the delegate to be executed
* fireNow = When true the delegate will be executed emmidiatly
*/
this(bool delegate() dlg, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
idleListeners ~= dlg;
idleID = g_idle_add_full(priority, cast(GSourceFunc)&idleCallback, cast(void*)this, cast(GDestroyNotify)&destroyIdleNotify);
}
/**
* Creates a new idle cycle.
* Params:
* dlg = the delegate to be executed
* priority = Priority for the idle function
* fireNow = When true the delegate will be executed emmidiatly
*/
this(bool delegate() dlg, GPriority priority, bool fireNow=false)
{
this.priority = priority;
if ( fireNow && !dlg() )
return;
idleListeners ~= dlg;
idleID = g_idle_add_full(priority, cast(GSourceFunc)&idleCallback, cast(void*)this, cast(GDestroyNotify)&destroyIdleNotify);
}
/** */
public void stop()
{
if ( idleID > 0 )
g_source_remove(idleID);
}
/**
* Removes the idle from gtk
*/
~this()
{
stop();
}
/**
* Adds a new delegate to this idle cycle
* Params:
* dlg =
* fireNow =
*/
public void addListener(bool delegate() dlg, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
idleListeners ~= dlg;
if ( idleID == 0 )
idleID = g_idle_add_full(priority, cast(GSourceFunc)&idleCallback, cast(void*)this, cast(GDestroyNotify)&destroyIdleNotify);
}
/*
* Executes all delegates on the execution list
* Returns: false if the callback should be removed.
*/
extern(C) static bool idleCallback(Idle idle)
{
bool runAgain = false;
int i = 0;
while ( i 0 ) --l;
return line[0..l];
}
extern(C) static void childWatchCallback(int pid, int status, Spawn spawn)
{
//writefln("Spawn.childWatchCallback %s %s", pid, status);
spawn.exitStatus = status;
if ( spawn.externalWatch !is null )
{
spawn.externalWatch(spawn);
}
spawn.close();
}
public bool endOfOutput()
{
if ( standardOutput is null ) return true;
return feof(standardOutput) != 0;
}
public bool endOfError()
{
if ( standardError is null ) return true;
return feof(standardError) != 0;
}
string getOutputString()
{
return Str.toString(strOutput);
}
string getErrorString()
{
return Str.toString(strError);
}
int getExitStatus()
{
return exitStatus;
}
/**
* Executes a command synchronasly and
* optionally calls delegates for sysout, syserr and end of job
*
*/
public int commandLineSync(
ChildWatch externalWatch = null,
bool delegate(string) readOutput = null,
bool delegate(string) readError = null )
{
string commandLine;
foreach ( count, string arg; argv)
{
if ( count > 0 )
{
commandLine ~= ' ';
}
commandLine ~= arg;
}
int status = g_spawn_command_line_sync(
Str.toStringz(commandLine),
&strOutput,
&strError,
&exitStatus,
&error);
if ( readOutput != null )
{
foreach ( string line ; splitLines(Str.toString(strOutput)) )
{
readOutput(line);
}
}
if ( readError != null )
{
foreach ( string line ; splitLines(Str.toString(strError)) )
{
readError(line);
}
}
if ( externalWatch != null )
{
externalWatch(this);
}
return status;
}
code: end
struct: Str
import: core.stdc.stdio
import: core.stdc.string
import: gobject.c.types
code: start
/*
* Convert C-style 0 terminated string s to char[] string.
* copied from phobos
*/
public static string toString(const(char)* s, size_t len = 0) pure
{
if ( s is null )
return cast(string)null;
if ( len == 0 )
len = strlen(s);
return s[0 .. len].idup;
}
/*
* Convert array of chars s[] to a C-style 0 terminated string.
* copied from phobos
*/
public static char* toStringz(string s) pure
{
if ( s is null ) return null;
char[] copy;
if (s.length == 0)
{
copy = "\0".dup;
}
else
{
// Need to make a copy
copy = new char[s.length + 1];
copy[0..s.length] = s[];
copy[s.length] = 0;
}
return copy.ptr;
}
/** */
public static char** toStringzArray(string[] args) pure
{
if ( args is null )
{
return null;
}
char** argv = (new char*[args.length + 1]).ptr;
int argc = 0;
foreach (string p; args)
{
argv[argc++] = cast(char*)(p.dup~'\0');
}
argv[argc] = null;
return argv;
}
/** */
public static char*** toStringzArray(string[][] args) pure
{
if ( args is null )
{
return null;
}
char**[] argv = new char**[args.length + 1];
int argc = 0;
foreach( string[] p; args )
{
argv[argc++] = toStringzArray(p);
}
argv[argc] = null;
return argv.ptr;
}
/** */
public static string[] toStringArray(const(char*)* args) pure
{
if ( args is null )
{
return null;
}
string[] argv;
while ( *args !is null )
{
argv ~= toString(*args);
args++;
}
return argv;
}
/** */
public static string[] toStringArray(const(char*)* args, size_t len) pure
{
string[] argv = new string[len];
for ( int i; i < len; i++ )
{
argv[i] = toString(args[i]);
}
return argv;
}
/** */
public static string[][] toStringArray(char*** args) pure
{
string[][] argv;
if ( args is null )
{
return null;
}
while ( *args !is null )
{
argv ~= toStringArray(*args);
args++;
}
return argv;
}
/** */
public static void freeString(char* str)
{
g_free(str);
}
/** */
public static void freeStringArray(char** str)
{
g_strfreev(str);
}
/** */
public static void freeStringArray(char*** str)
{
while ( *str !is null )
{
g_strfreev(*str);
str++;
}
g_free(str);
}
code: end
struct: String
class: StringG
struct: Thread
noCode: new
struct: Timeout
class: Timeout
cType:
import: core.time
import: std.conv
code: start
/** Holds all idle delegates */
private bool delegate()[] timeoutListeners;
/** Our timeout ID */
private uint timeoutID;
/**
* Creates a new timeout cycle with the default priority, GPriority.DEFAULT.
*
* Note that timeout functions may be delayed, due to the processing of other
* event sources. Thus they should not be relied on for precise timing.
* After each call to the timeout function, the time of the next timeout is
* recalculated based on the current time and the given interval
* (it does not try to 'catch up' time lost in delays).
* Params:
* interval = the timeout in milieconds
* delegate() = the delegate to be executed
* fireNow = When true the delegate will be executed emmidiatly
*/
this(uint interval, bool delegate() dlg, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
timeoutListeners ~= dlg;
timeoutID = g_timeout_add_full(GPriority.DEFAULT, interval, cast(GSourceFunc)&timeoutCallback, cast(void*)this, cast(GDestroyNotify)&destroyTimeoutNotify);
}
this(Duration interval, bool delegate() dlg, bool fireNow=false)
{
this(interval.total!"msecs".to!uint, dlg, fireNow);
}
/**
* Creates a new timeout cycle.
* Params:
* interval = the timeout in milieconds
* delegate() = the delegate to be executed
* priority = Priority for the timeout function
* fireNow = When true the delegate will be executed emmidiatly
*/
this(uint interval, bool delegate() dlg, GPriority priority, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
timeoutListeners ~= dlg;
timeoutID = g_timeout_add_full(priority, interval, cast(GSourceFunc)&timeoutCallback, cast(void*)this, cast(GDestroyNotify)&destroyTimeoutNotify);
}
this(Duration interval, bool delegate() dlg, GPriority priority, bool fireNow=false)
{
this(interval.total!"msecs".to!uint, dlg, priority, fireNow);
}
/**
* Creates a new timeout cycle with the default priority, GPriority.DEFAULT.
* Params:
* delegate() = the delegate to be executed
* seconds = interval in seconds.
* fireNow = When true the delegate will be executed emmidiatly
*/
this(bool delegate() dlg, uint seconds, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
timeoutListeners ~= dlg;
timeoutID = g_timeout_add_seconds_full(GPriority.DEFAULT, seconds, cast(GSourceFunc)&timeoutCallback, cast(void*)this, cast(GDestroyNotify)&destroyTimeoutNotify);
}
this(bool delegate() dlg, Duration seconds, bool fireNow=false)
{
this(dlg, seconds.total!"seconds".to!uint, fireNow);
}
/**
* Creates a new timeout cycle.
* Params:
* delegate() = the delegate to be executed
* seconds = interval in seconds.
* priority = Priority for the timeout function
* fireNow = When true the delegate will be executed emmidiatly
*/
this(bool delegate() dlg, uint seconds, GPriority priority, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
timeoutListeners ~= dlg;
timeoutID = g_timeout_add_seconds_full(priority, seconds, cast(GSourceFunc)&timeoutCallback, cast(void*)this, cast(GDestroyNotify)&destroyTimeoutNotify);
}
this(bool delegate() dlg, Duration seconds, GPriority priority, bool fireNow=false)
{
this(dlg, seconds.total!"seconds".to!uint, priority, fireNow);
}
/** Removes the timeout from gtk */
public void stop()
{
if ( timeoutID > 0 )
{
g_source_remove(timeoutID);
}
}
/**
* Removes the timeout from gtk
*/
~this()
{
stop();
}
/**
* Adds a new delegate to this timeout cycle
* Params:
* dlg =
* fireNow =
*/
public void addListener(bool delegate() dlg, bool fireNow=false)
{
if ( fireNow && !dlg() )
return;
timeoutListeners ~= dlg;
}
/**
* The callback execution from glib
* Params:
* timeout =
* Returns:
*/
extern(C) static bool timeoutCallback(Timeout timeout)
{
bool runAgain = false;
int i = 0;
while ( i