pax_global_header00006660000000000000000000000064140030455660014515gustar00rootroot0000000000000052 comment=29be6ea9edfc979d25a302b4eb170f852f4e0a7c GlibD-2.3.0/000077500000000000000000000000001400304556600125005ustar00rootroot00000000000000GlibD-2.3.0/AUTHORS000066400000000000000000000002341400304556600135470ustar00rootroot00000000000000GTKD AUTHORS (alphabetical by last name) Frank Benoit Jake Day Jonas Kivi Alan Knowles Antonio Monteiro Sebastián E. Peyrott John Reimer Mike Wey hauptmechGlibD-2.3.0/COPYING000066400000000000000000000215541400304556600135420ustar00rootroot00000000000000The 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.md000066400000000000000000000006561400304556600137660ustar00rootroot00000000000000# 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.json000066400000000000000000000015401400304556600141450ustar00rootroot00000000000000{ "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.build000066400000000000000000000043211400304556600146420ustar00rootroot00000000000000project('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/000077500000000000000000000000001400304556600132675ustar00rootroot00000000000000GlibD-2.3.0/src/APILookup.txt000066400000000000000000000035661400304556600156450ustar00rootroot00000000000000# # 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.txt000066400000000000000000001357251400304556600164060ustar00rootroot00000000000000# 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 n_param_values ) assert(false, "DClosure doesn't have enough parameters."); if ( closure.derivativeFlag ) { GValue[] swapped = new GValue[n_param_values]; swapped[0..n_param_values-1] = param_values[1..n_param_values]; swapped[n_param_values-1] = param_values[0]; param_values = swapped.ptr; } mixin(getCallbackCall!T()); } private static string getCallbackCall(T)() { if (!__ctfe) assert(false); string call; alias Params = Parameters!T; foreach ( param; Params ) { static if ( __traits(compiles, TemplateOf!param) && __traits(isSame, TemplateOf!param, glib.c.types.Scoped) ) call ~= "import "~moduleName!(TemplateArgsOf!(param)[0])~";\n"; else static if ( is(param == class) || is(param == interface) || is(param == struct) || is(param == enum) ) call ~= "import "~moduleName!param~";\n"; else static if ( isPointer!param && ( is(PointerTarget!param == struct) || is(PointerTarget!param == enum)) ) //The moduleName template gives an forward reference error here. call ~= "import "~fullyQualifiedName!param.findSplitAfter(".c.types")[0]~";\n"; } alias Ret = ReturnType!T; static if ( is(Ret == class) || is(Ret == interface) || is(Ret == struct) || is(Ret == enum) ) call ~= "import "~moduleName!Ret~";\n"; else static if ( isPointer!Ret && ( is(PointerTarget!Ret == struct) || is(PointerTarget!Ret == enum)) ) call ~= "import "~fullyQualifiedName!Ret.findSplitAfter(".c.types")[0]~";\n"; static if ( !is(Ret == void) ) call ~= "auto ret = "; call ~= "cl.callback("; foreach ( i, param; Params ) { if ( i > 0 ) call ~= ", "; call ~= getValue!param(i); } call ~= ");\n"; static if ( is(Ret == bool) ) call ~= "g_value_set_boolean(return_value, ret);"; else static if ( is(Ret == byte) ) call ~= "g_value_set_schar(return_value, ret);"; else static if ( is(Ret == ubyte) || is(Ret == char) ) call ~= "g_value_set_uchar(return_value, ret);"; else static if ( is(Ret == int) ) call ~= "g_value_set_int(return_value, ret);"; else static if ( is(Ret == uint) ) call ~= "g_value_set_uint(return_value, ret);"; else static if ( is(Ret == long) ) call ~= "g_value_set_int64(return_value, ret);"; else static if ( is(Ret == ulong) ) call ~= "g_value_set_uint64(return_value, ret);"; else static if ( is(Ret == float) ) call ~= "g_value_set_float(return_value, ret);"; else static if ( is(Ret == double) ) call ~= "g_value_set_double(return_value, ret);"; else static if ( is(Ret == string) ) call ~= "g_value_set_string(return_value, Str.toStringz(ret));"; else static if ( is(Ret == string[]) ) call ~= "g_value_set_pointer(return_value, Str.toStringzArray(ret));"; else static if ( is(Ret == enum) ) call ~= "g_type_is_a(return_value.gType, GType.ENUM) ? g_value_set_enum(return_value, ret) : g_value_set_flags(return_value, ret);"; else static if ( isPointer!Ret ) call ~= "g_type_is_a(return_value.gType, GType.POINTER) ? g_value_set_pointer(return_value, ret) : (g_type_is_a(return_value.gType, GType.BOXED) ? g_value_set_boxed(return_value, ret) : g_value_set_object(return_value, ret));"; else static if ( is(Ret == interface) ) call ~= "g_value_set_object(return_value, (cast(ObjectG)ret).getObjectGStruct());"; else static if ( is(Ret == class) ) { static if ( is(Ret == Variant) ) call ~= "g_value_set_variant(return_value, ret.getVariantStruct());"; else static if ( is(Ret == ParamSpec) ) call ~= "g_value_set_param(return_value, ret.getParamSpecStruct());"; else static if ( is(Ret : ObjectG) ) call ~= "g_value_set_object(return_value, ret.getObjectGStruct());"; else call ~= "g_type_is_a(return_value.gType, GType.POINTER) ? g_value_set_pointer(return_value, ret.get"~Ret.stringof~"Struct()) : (g_type_is_a(return_value.gType, GType.BOXED) ? g_value_set_boxed(return_value, ret.get"~Ret.stringof~"Struct()) : g_value_set_object(return_value, ret.get"~Ret.stringof~"Struct()));"; } return call; } private static string getValue(Param)(int index) { if (!__ctfe) assert(false); static if ( is(Param == bool) ) return "g_value_get_boolean(¶m_values["~to!string(index)~"]) != 0"; else static if ( is(Param == byte) ) return "g_value_get_schar(¶m_values["~to!string(index)~"])"; else static if ( is(Param == ubyte) || is(Param == char) ) return "g_value_get_uchar(¶m_values["~to!string(index)~"])"; else static if ( is(Param == int) ) return "g_value_get_int(¶m_values["~to!string(index)~"])"; else static if ( is(Param == uint) ) return "g_value_get_uint(¶m_values["~to!string(index)~"])"; else static if ( is(Param == long) ) return "g_value_get_int64(¶m_values["~to!string(index)~"])"; else static if ( is(Param == ulong) ) return "g_value_get_uint64(¶m_values["~to!string(index)~"])"; else static if ( is(Param == float) ) return "g_value_get_float(¶m_values["~to!string(index)~"])"; else static if ( is(Param == double) ) return "g_value_get_double(¶m_values["~to!string(index)~"])"; else static if ( is(Param == string) ) return "Str.toString(g_value_get_string(¶m_values["~to!string(index)~"]))"; else static if ( is(Param == string[]) ) return "Str.toStringArray(cast(const(char*)*)g_value_get_pointer(¶m_values["~to!string(index)~"]))"; else static if ( is(Param == enum) ) return "cast("~fullyQualifiedName!Param~")(g_type_is_a(param_values["~to!string(index)~"].gType, GType.ENUM) ? g_value_get_enum(¶m_values["~to!string(index)~"]) : g_value_get_flags(¶m_values["~to!string(index)~"]))"; else static if ( isPointer!Param ) return "cast("~fullyQualifiedName!Param~")(g_type_is_a(param_values["~to!string(index)~"].gType, GType.POINTER) ? g_value_get_pointer(¶m_values["~to!string(index)~"]) : (g_type_is_a(param_values["~to!string(index)~"].gType, GType.BOXED) ? g_value_get_boxed(¶m_values["~to!string(index)~"]) : g_value_get_object(¶m_values["~to!string(index)~"])))"; else static if ( __traits(compiles, TemplateOf!Param) && __traits(isSame, TemplateOf!Param, glib.c.types.Scoped) ) return "getScopedGobject!("~fullyQualifiedName!(TemplateArgsOf!(Param)[0])~")(cast(typeof("~fullyQualifiedName!(TemplateArgsOf!(Param)[0])~".tupleof[0]))(g_type_is_a(param_values["~to!string(index)~"].gType, GType.POINTER) ? g_value_get_pointer(¶m_values["~to!string(index)~"]) : (g_type_is_a(param_values["~to!string(index)~"].gType, GType.BOXED) ? g_value_get_boxed(¶m_values["~to!string(index)~"]) : g_value_get_object(¶m_values["~to!string(index)~"]))))"; else static if ( is(Param == interface) ) return "ObjectG.getDObject!("~fullyQualifiedName!Param~")(cast(GObject*)g_value_get_object(¶m_values["~to!string(index)~"]))"; else static if ( is(Param == class) ) { static if ( is(Param == Variant) ) return "new Variant(g_value_get_variant(¶m_values["~to!string(index)~"]))"; else static if ( is(Param== ParamSpec) ) return "new ParamSpec(g_value_get_param(¶m_values["~to!string(index)~"]))"; else static if ( is(Param : ObjectG) ) return "ObjectG.getDObject!("~fullyQualifiedName!Param~")(cast(typeof("~fullyQualifiedName!Param~".tupleof[0]))g_value_get_object(¶m_values["~to!string(index)~"]))"; else return "ObjectG.getDObject!("~fullyQualifiedName!Param~")(cast(typeof("~fullyQualifiedName!Param~".tupleof[0]))(g_type_is_a(param_values["~to!string(index)~"].gType, GType.POINTER) ? g_value_get_pointer(¶m_values["~to!string(index)~"]) : (g_type_is_a(param_values["~to!string(index)~"].gType, GType.BOXED) ? g_value_get_boxed(¶m_values["~to!string(index)~"]) : g_value_get_object(¶m_values["~to!string(index)~"]))))"; } } } code: end struct: Object import: core.memory import: glib.c.functions : g_datalist_get_flags import: gobject.DClosure import: gobject.Signals import: std.traits merge: InitiallyUnowned noSignal: notify move: clear_object Object inout: clear_object object_ptr code: start protected bool isGcRoot; package DClosure[gulong] signals; /** * Sets our main struct and passes store it on the gobject. * Add a gabage collector root to the gtk+ struct so it doesn't get collect */ public this (GObject* gObject, bool ownedRef = false) { this.gObject = gObject; if ( gObject !is null ) { setDataFull("GObject", cast(void*)this, cast(GDestroyNotify)&destroyNotify); addToggleRef(cast(GToggleNotify)&toggleNotify, cast(void*)this); //If the refCount is larger then 1 toggleNotify isn't called if (gObject.refCount > 1 && !isGcRoot) { GC.addRoot(cast(void*)this); isGcRoot = true; } //Remove the floating reference if there is one. if ( isFloating() ) { refSink(); unref(); } //If we already owned this reference remove the one added by addToggleRef. else if ( ownedRef ) { unref(); } } } extern(C) { static void destroyNotify(ObjectG obj) { if ( obj.isGcRoot ) { GC.removeRoot(cast(void*)obj); obj.isGcRoot = false; } if ( obj.hasToggleRef() ) obj.removeToggleRef(cast(GToggleNotify)&toggleNotify, cast(void*)obj); obj.gObject = null; } static void toggleNotify(ObjectG obj, GObject* object, int isLastRef) { if ( isLastRef && obj.isGcRoot ) { GC.removeRoot(cast(void*)obj); obj.isGcRoot = false; } else if ( !obj.isGcRoot ) { GC.addRoot(cast(void*)obj); obj.isGcRoot = true; } } } ~this() { static if ( isPointer!(typeof(g_object_steal_data)) ) bool libLoaded = Linker.isLoaded(LIBRARY_GOBJECT); else enum libLoaded = true; if ( libLoaded && gObject !is null ) { // Remove the GDestroyNotify callback, // for when the D object is destroyed before the C one. g_object_steal_data(gObject, cast(char*)"GObject"); if ( isGcRoot ) { GC.removeRoot(cast(void*)this); isGcRoot = false; } if ( hasToggleRef() ) g_object_remove_toggle_ref(gObject, cast(GToggleNotify)&toggleNotify, cast(void*)this); else g_object_unref(gObject); } } /** */ T opCast(T)() { if ( !this ) return null; static if ( is(T : ObjectG) && !is(T == interface) && is(typeof(new T(cast(typeof(T.tupleof[0]))gObject, false))) ) { //If a regular cast works, return the result. if ( auto r = cast(T)super ) return r; //Prints a warning if the cast is invalid. //g_type_check_instance_cast(cast(GTypeInstance*)gObject, T.getType()); //Can we cast this type to T. if ( !g_type_is_a(gObject.gTypeInstance.gClass.gType, T.getType()) ) return null; //Remove the GDestroyNotify callback for the original d object. g_object_steal_data(gObject, "GObject"); //Remove the original object as a GC root if needed. if ( isGcRoot ) { GC.removeRoot(cast(void*)this); isGcRoot = false; } if ( hasToggleRef() ) { //Add a reference for the original D object before we remove the toggle reference. g_object_ref(gObject); g_object_remove_toggle_ref(gObject, cast(GToggleNotify)&toggleNotify, cast(void*)this); } //The new object handles the memory management. return new T(cast(typeof(T.tupleof[0]))gObject, false); } else static if ( is(T == interface) && hasStaticMember!(T, "getType") && is(ReturnType!(T.getType) == GType) ) { //If a regular cast works, return the result. if ( auto r = cast(T)super ) return r; //Do we implement interface T. if ( !g_type_is_a(gObject.gTypeInstance.gClass.gType, T.getType()) ) return null; return getInterfaceInstance!T(gObject); } else return cast(T)super; } unittest { ObjectG obj = null; assert( (cast(Binding)obj) is null ); } /** * Gets a D Object from the objects table of associations. * Params: * obj = GObject containing the associations. * Returns: the D Object if found, or a newly constructed object if no such Object exists. */ public static RT getDObject(T, RT=T, U)(U obj, bool ownedRef = false) { if ( obj is null ) { return null; } static if ( is(T : ObjectG) && !is(RT == interface) ) { auto p = g_object_get_data(cast(GObject*)obj, Str.toStringz("GObject")); if ( p !is null ) return cast(RT)cast(ObjectG)p; else return new T(obj, ownedRef); } else static if ( is(RT == interface) && hasMember!(RT, "getType") && is(ReturnType!(RT.getType) == GType) ) { auto p = g_object_get_data(cast(GObject*)obj, Str.toStringz("GObject")); if ( p !is null ) return cast(RT)cast(ObjectG)p; else return getInterfaceInstance!RT(cast(GObject*)obj); } else static if ( is(typeof(new T(obj, ownedRef))) ) { return new T(obj, ownedRef); } else { return new T(obj); } } private static I getInterfaceInstance(I)(GObject* instance) { static class Impl: ObjectG, I { public this (GObject* gObject, bool ownedRef = false) { super(gObject, ownedRef); } /** the main Gtk struct as a void* */ protected override void* getStruct() { return cast(void*)gObject; } // add the interface capabilities mixin("import "~ moduleName!I[0..$-2] ~"T;import "~ moduleName!I ~"; mixin "~ __traits(identifier, I)[0..$-2] ~"T!("~__traits(identifier, Impl)~");"); } ClassInfo ci = Impl.classinfo; Impl iface; void* p; //Skip all the setup for the memory management, //and only add an extra reference for the instance returned. p = GC.malloc(ci.initializer.length, GC.BlkAttr.FINALIZE, ci); p[0..ci.initializer.length] = ci.initializer; iface = cast(Impl)p; iface.gObject = instance; iface.doref(); return iface; } /** * Is there a toggle ref connected to this object. */ private bool hasToggleRef() { enum TOGGLE_REF_FLAG = 0x1; if ( (g_datalist_get_flags(&gObject.qdata) & TOGGLE_REF_FLAG) != 0 ) //TODO: Assumes we always have the gObject data set if the toggleRef is connected to this instance. return (g_object_get_data(gObject, cast(char*)"GObject") is cast(void*)this); else return false; } public void removeGcRoot() { if ( hasToggleRef() ) { g_object_ref(gObject); g_object_remove_toggle_ref(gObject, cast(GToggleNotify)&toggleNotify, cast(void*)this); } if ( isGcRoot ) { GC.removeRoot(cast(void*)this); isGcRoot = false; } } /** */ public void setProperty(T)(string propertyName, T value) { setProperty(propertyName, new Value(value)); } deprecated("Use the member function") public static void unref(ObjectG obj) { obj.unref(); } deprecated("Use the member function") public static ObjectG doref(ObjectG obj) { return obj.doref(); } /** * The notify signal is emitted on an object when one of its * properties has been changed. Note that getting this signal * doesn't guarantee that the value of the property has actually * changed, it may also be emitted when the setter for the property * is called to reinstate the previous value. * * This signal is typically used to obtain change notification for a * single property. * * It is important to note that you must use * canonical parameter names for the property. * * Params: * dlg = The callback. * property = Set this if you only want to receive the signal for a specific property. * connectFlags = The behavior of the signal's connection. */ gulong addOnNotify(void delegate(ParamSpec, ObjectG) dlg, string property = "", ConnectFlags connectFlags=cast(ConnectFlags)0) { string signalName; if ( property == "" ) signalName = "notify"; else signalName = "notify::"~ property; return Signals.connect(this, signalName, dlg, connectFlags ^ ConnectFlags.SWAPPED); } code: end struct: ObjectClass merge: InitiallyUnownedClass struct: ParamSpecBoolean noCode: true struct: ParamSpecBoxed noCode: true struct: ParamSpecChar noCode: true struct: ParamSpecDouble noCode: true struct: ParamSpecEnum noCode: true struct: ParamSpecFlags noCode: true struct: ParamSpecFloat noCode: true struct: ParamSpecGType noCode: true struct: ParamSpecInt noCode: true struct: ParamSpecInt64 noCode: true struct: ParamSpecLong noCode: true struct: ParamSpecObject noCode: true struct: ParamSpecOverride noCode: true struct: ParamSpecParam noCode: true struct: ParamSpecPointer noCode: true struct: ParamSpecString noCode: true struct: ParamSpecUChar noCode: true struct: ParamSpecUInt noCode: true struct: ParamSpecUInt64 noCode: true struct: ParamSpecULong noCode: true struct: ParamSpecUnichar noCode: true struct: ParamSpecValueArray noCode: true struct: ParamSpecVariant noCode: true struct: Signals import: gobject.DClosure import: std.traits move: signal_handler_disconnect Signals handler_disconnect noCode: handler_disconnect code: start /** * Connects a callback to a signal for a particular object. * * The handler will be called before the default handler of the signal. * * Params: * instance = the instance to connect to. * detailedSignal = a string of the form "signal-name::detail". * callback = the callback to connect. * connectFlags = a combination of ConnectFlags. * * Returns: the handler ID, of type gulong (always greater than 0 for successful connections) */ public static gulong connect(T)(ObjectG instance, string detailedSignal, T callback, ConnectFlags connectFlags = cast(ConnectFlags)0) if ( isCallable!T && !is(T == GCallback) ) { bool after = (connectFlags & ConnectFlags.AFTER) != false; bool swap = (connectFlags & ConnectFlags.SWAPPED) != false; DClosure closure = new DClosure(callback, swap); gulong id = Signals.connectClosure(instance, detailedSignal, closure, after); instance.signals[id] = closure; return id; } deprecated public static gulong connectData(void* instanc, string detailedSignal, GCallback cHandler, Object data, GClosureNotify destroyData, GConnectFlags connectFlags) { return g_signal_connect_data(instanc, Str.toStringz(detailedSignal), cHandler, cast(void*)data, destroyData, connectFlags); } /** * Disconnects a handler from an instance so it will not be called during * any future or currently ongoing emissions of the signal it has been * connected to. The @handler_id becomes invalid and may be reused. * * The @handler_id has to be a valid signal handler id, connected to a * signal of @instance. * * Params: * instance = The instance to remove the signal handler from. * handlerId = Handler id of the handler to be disconnected. */ public static void handlerDisconnect(ObjectG instance, gulong handlerId) { instance.signals.remove(handlerId); g_signal_handler_disconnect((instance is null) ? null : instance.getObjectGStruct(), handlerId); } /** * Connects a GCallback function to a signal for a particular object. * * The handler will be called before the default handler of the signal. * * See [memory management of signal handlers][signal-memory-management] for * details on how to handle the return value and memory management of @data. * * Params: * instance = the instance to connect to. * detailedSignal = a string of the form "signal-name::detail". * cHandler = the GCallback to connect. * data = data to pass to cHandler calls. * * Returns: the handler ID, of type gulong (always greater than 0 for successful connections) */ public static gulong connect(ObjectG instanc, string detailedSignal, GCallback cHandler, void* data) { return g_signal_connect_data((instanc is null) ? null : instanc.getObjectGStruct(), Str.toStringz(detailedSignal), cHandler, data, null, cast(ConnectFlags)0); } code: end struct: Type import: gobject.ObjectG code: start public static T* getInstanceClass(T)(ObjectG obj) { return cast(T*) (cast(GTypeInstance*)obj.getObjectGStruct()).gClass; } /** * Get the unique name that is assigned to the Objects type. * Returns: Static type name or NULL. */ public static string name(ObjectG obj) { GType type = (cast(GTypeInstance*)obj.getObjectGStruct()).gClass.gType; return name(type); } code: end struct: Value import: gobject.Type import: std.traits code: start /** */ public this() { this(new GValue); } /** */ this(GOBJECT)(GOBJECT obj) if ( is(GOBJECT == class) && hasMember!(GOBJECT, "getType") ) { this(); init(GOBJECT.getType()); static if ( is(GOBJECT : ObjectG) ) { setObject(obj); } else { if ( Type.isA(gValue.gType, GType.BOXED) ) setBoxed(obj.tupleof[0]); else setPointer(obj.tupleof[0]); } } /** */ this(string value) { this(); init(GType.STRING); setString(value); } /** */ this(BOOL)(BOOL value) if( isBoolean!BOOL ) { this(); init(GType.BOOLEAN); setBoolean(value); } /** */ this(CHAR)(CHAR value) if( is(CHAR == char) ) { this(); init(GType.UCHAR); setUchar(value); } /** */ this(INT)(INT value) if ( isIntegral!INT ) { this(); static if ( is(OriginalType!INT == int) ) { init(GType.INT); setInt(value); } else static if ( is(OriginalType!INT == uint) ) { init(GType.UINT); setUint(value); } else static if ( is(OriginalType!INT == long) ) { init(GType.INT64); setInt64(value); } else static if ( is(OriginalType!INT == ulong) ) { init(GType.UINT64); setUint64(value); } else { init(GType.INT); setInt(value); } } /** */ this(FLOAT)(FLOAT value) if ( isFloatingPoint!FLOAT ) { this(); static if ( is( FLOAT == float ) ) { init(GType.FLOAT); setFloat(value); } else { init(GType.DOUBLE); setDouble(value); } } /** * The GType of the contianed value. */ public @property GType gType() { return gValue.gType; } /** * Retrieves a TYPE from Value, the Value must contain the appropriate type. */ public TYPE get(TYPE)() { static if ( is(TYPE == bool) ) return getBoolean(); else static if ( is(TYPE == byte) ) return getSchar(); else static if ( is(TYPE == ubyte) || is(TYPE == char) ) return getUchar(); else static if ( is(TYPE == int) ) return getInt(); else static if ( is(TYPE == uint) ) return getUint(); else static if ( is(TYPE == long) ) return getInt64(); else static if ( is(TYPE == ulong) ) return getUint64(); else static if ( is(TYPE == float) ) return getFloat(); else static if ( is(TYPE == double) ) return getDouble(); else static if ( is(TYPE == string) ) return getString(); else static if ( is(TYPE == string[]) ) return Str.toStringArray(cast(const(char*)*)getPointer()); else static if ( is(TYPE == enum) ) return cast(TYPE)(Type.isA(gValue.gType, GType.ENUM) ? getEnum() : getFlags()); else static if ( isPointer!TYPE ) return cast(TYPE)(Type.isA(gValue.gType, GType.POINTER) ? getPointer() : (Type.isA(gValue.gType, GType.BOXED) ? getBoxed() : g_value_get_object(gValue))); else static if ( is(TYPE == interface) ) return cast(TYPE)getObject(); else static if ( is(TYPE == class) ) { static if ( is(TYPE == Variant) ) return getVariant(); else static if ( is(TYPE== ParamSpec) ) return getParam(); else static if ( is(TYPE : ObjectG) ) return cast(TYPE)getObject(); else return ObjectG.getDObject!(TYPE)(cast(typeof(TYPE.tupleof[0]))(Type.isA(gValue.gType, GType.POINTER) ? getPointer() : (Type.isA(gValue.gType, GType.BOXED) ? getBoxed() : g_value_get_object(gValue)))); } } code: end struct: WeakRef code: start /** */ this(void* object) { g_weak_ref_init(gWeakRef, object); } code: end # # Move functions defined as global into there respective classes # struct: move: boxed_copy Boxed copy move: boxed_free Boxed free move: boxed_type_register_static Boxed type_register_static move: pointer_type_register_static Boxed move: enum_complete_type_info Enums complete_type_info move: enum_get_value Enums get_value move: enum_get_value_by_name Enums get_value_by_name move: enum_get_value_by_nick Enums get_value_by_nick move: enum_register_static Enums register_static version 2.54: start move: enum_to_string Enums move: flags_to_string Enums version: end move: flags_complete_type_info Flags complete_type_info move: flags_get_first_value Flags get_first_value move: flags_get_value_by_name Flags get_value_by_name move: flags_get_value_by_nick Flags get_value_by_nick move: flags_register_static Flags register_static # ParamSpec Constructors? move: param_spec_boolean Value move: param_spec_boxed Value move: param_spec_char Value move: param_spec_double Value move: param_spec_enum Value move: param_spec_flags Value move: param_spec_float Value move: param_spec_gtype Value move: param_spec_int Value move: param_spec_int64 Value move: param_spec_long Value move: param_spec_object Value move: param_spec_override Value move: param_spec_param Value move: param_spec_pointer Value move: param_spec_string Value move: param_spec_uchar Value move: param_spec_uint Value move: param_spec_uint64 Value move: param_spec_ulong Value move: param_spec_unichar Value move: param_spec_value_array Value move: param_spec_variant Value move: param_type_register_static ParamSpec move: param_value_convert ParamSpec move: param_value_defaults ParamSpec move: param_value_set_default ParamSpec move: param_value_validate ParamSpec move: param_values_cmp ParamSpec move: signal_accumulator_first_wins Signals accumulator_first_wins move: signal_accumulator_true_handled Signals accumulator_true_handled move: signal_add_emission_hook Signals add_emission_hook move: signal_chain_from_overridden Signals chain_from_overridden move: signal_chain_from_overridden_handler Signals chain_from_overridden_handler move: signal_connect_closure Signals connect_closure move: signal_connect_closure_by_id Signals connect_closure_by_id move: signal_connect_data Signals connect_data move: signal_connect_object Signals connect_object move: signal_emit Signals emit move: signal_emit_by_name Signals emit_by_name move: signal_emit_valist Signals emit_valist move: signal_emitv Signals emitv move: signal_get_invocation_hint Signals get_invocation_hint move: signal_handler_block Signals handler_block move: signal_handler_find Signals handler_find move: signal_handler_is_connected Signals handler_is_connected move: signal_handler_unblock Signals handler_unblock move: signal_handlers_block_matched Signals handlers_block_matched move: signal_handlers_destroy Signals handlers_destroy move: signal_handlers_disconnect_matched Signals handlers_disconnect_matched move: signal_handlers_unblock_matched Signals handlers_unblock_matched move: signal_has_handler_pending Signals has_handler_pending move: signal_list_ids Signals list_ids move: signal_lookup Signals lookup move: signal_name Signals name move: signal_new Signals new move: signal_new_class_handler Signals new_class_handler move: signal_new_valist Signals new_valist move: signal_newv Signals newv move: signal_override_class_closure Signals override_class_closure move: signal_override_class_handler Signals override_class_handler move: signal_parse_name Signals parse_name move: signal_query Signals query move: signal_remove_emission_hook Signals remove_emission_ move: signal_set_va_marshaller Signals set_va_marshaller move: signal_stop_emission Signals stop_emission move: signal_stop_emission_by_name Signals stop_emission_by_name move: signal_type_cclosure_new Signals type_cclosure_new version 2.62: move: clear_signal_handler Signals move: source_set_closure Closure move: source_set_dummy_callback Closure move: strdup_value_contents Value move: type_add_class_cache_func Type add_class_cache_func move: type_add_class_private Type add_class_private move: type_add_instance_private Type add_instance_private move: type_add_interface_check Type add_interface_check move: type_add_interface_dynamic Type add_interface_dynamic move: type_add_interface_static Type add_interface_static move: type_check_class_cast Type check_class_cast move: type_check_class_is_a Type check_class_is_a move: type_check_instance Type check_instance move: type_check_instance_cast Type check_instance_cast move: type_check_instance_is_a Type check_instance_is_a move: type_check_instance_is_fundamentally_a Type check_instance_is_fundamentally_a move: type_check_is_value_type Type check_is_value_type move: type_check_value Type check_value move: type_check_value_holds Type check_value_holds move: type_children Type children move: type_create_instance Type create_instance move: type_default_interface_peek Type default_interface_peek move: type_default_interface_ref Type default_interface_ref move: type_default_interface_unref Type default_interface_unref move: type_depth Type depth move: type_ensure Type ensure move: type_free_instance Type free_instance move: type_from_name Type from_name move: type_fundamental Type fundamental move: type_fundamental_next Type fundamental_next move: type_get_plugin Type get_plugin move: type_get_qdata Type get_qdata move: type_get_type_registration_serial Type get_type_registration_serial move: type_init Type init move: type_init_with_debug_flags Type init_with_debug_flags move: type_interfaces Type interfaces move: type_is_a Type is_a move: type_name Type name move: type_name_from_class Type name_from_class move: type_name_from_instance Type name_from_instance move: type_next_base Type next_base move: type_parent Type parent move: type_qname Type qname move: type_query Type query move: type_register_dynamic Type register_dynamic move: type_register_fundamental Type register_fundamental move: type_register_static Type register_static move: type_register_static_simple Type register_static_simple move: type_remove_class_cache_func Type remove_class_cache_func move: type_remove_interface_check Type remove_interface_check move: type_set_qdata Type set_qdata move: type_test_flags Type test_flags move: type_get_instance_count Type get_instance_count #move: type_value_table_peek Type value_table_peek GlibD-2.3.0/src/APILookupGio.txt000066400000000000000000000413131400304556600162740ustar00rootroot00000000000000# 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: gio file: Gio-2.0.gir struct: Application code: start /** * The ::command-line signal is emitted on the primary instance when * a commandline is not handled locally. See g_application_run() and * the #GApplicationCommandLine documentation for more information. * * Params: * commandLine = a #GApplicationCommandLine representing the * passed commandline * * Return: An integer that is set as the exit status for the calling * process. See g_application_command_line_set_exit_status(). */ gulong addOnCommandLine(int delegate(Scoped!ApplicationCommandLine, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) { return Signals.connect(this, "command-line", dlg, connectFlags ^ ConnectFlags.SWAPPED); } /** * The ::open signal is emitted on the primary instance when there are * files to open. See g_application_open() for more information. * * Params: * files = an array of #GFiles * nFiles = the length of @files * hint = a hint provided by the calling instance */ gulong addOnOpen(void delegate(FileIF[], string, Application) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) { return Signals.connect(this, "open", delegate void (GFile* gfiles, int nFiles, string hint, Application app){ FileIF[] files = new FileIF[nFiles]; for(int i = 0; i < nFiles; i++) { files[i] = ObjectG.getDObject!FileIF((cast(GFile**)gfiles)[i]); } dlg(files, hint, app); }, connectFlags ^ ConnectFlags.SWAPPED); } code: end struct: BufferedInputStream noCode: peek_buffer code: start /** * Returns the buffer with the currently available bytes. The returned * buffer must not be modified and will become invalid when reading from * the stream or filling the buffer. * * Params: * count = a #gsize to get the number of bytes available in the buffer * * Return: read-only buffer */ public ubyte[] peekBuffer() { size_t count; auto p = g_buffered_input_stream_peek_buffer(gBufferedInputStream, &count); return (cast(ubyte*)p)[0 .. count]; } code: end struct: DataInputStream noCode: read_byte struct: DBusActionGroup import: glib.ConstructionException code: start /** * See_Also: get(). */ this(DBusConnection connection, string busName, string objectPath) { auto p = g_dbus_action_group_get((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(busName), Str.toStringz(objectPath)); if(p is null) { throw new ConstructionException("null returned by g_dbus_action_group_get"); } this(cast(GDBusActionGroup*) p, true); } code: end struct: DBusAnnotationInfo import: glib.Str noCode: lookup code: start /** * Looks up the value of an annotation. * * The cost of this function is O(n) in number of annotations. * * Params: * annotations = A %NULL-terminated array of annotations or %NULL. * name = The name of the annotation to look up. * * Return: The value or %NULL if not found. Do not free, it is owned by @annotations. * * Since: 2.26 */ public static string lookup(DBusAnnotationInfo[] annotations, string name) { GDBusAnnotationInfo*[] annotationsArray = new GDBusAnnotationInfo*[annotations.length+1]; for ( int i = 0; i < annotations.length ; i++ ) { annotationsArray[i] = annotations[i].getDBusAnnotationInfoStruct(); } annotationsArray[$-1] = null; return Str.toString(g_dbus_annotation_info_lookup(annotationsArray.ptr, Str.toStringz(name))); } code: end struct: DBusConnection alias: new newConnection noCode: new_finish noCode: new_for_address_finish code: start /** * Finishes an operation started with g_dbus_connection_new(). * * Params: * res = A GAsyncResult obtained from the GAsyncReadyCallback * passed to g_dbus_connection_new(). * address = If true finish an address. * * Throws: GException on failure. * Throws: ConstructionException GTK+ fails to create the object. * * Since: 2.26 */ public this (AsyncResultIF res, bool address = false) { GError* err = null; GDBusConnection* p; if ( address ) { p = g_dbus_connection_new_for_address_finish((res is null) ? null : res.getAsyncResultStruct(), &err); } else { p = g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); } if (err !is null) { throw new GException( new ErrorG(err) ); } if(p is null) { throw new ConstructionException("null returned by g_dbus_connection_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); } this(p, true); } code: end struct: DBusMenuModel import: glib.ConstructionException code: start /** * See_Also: get(). */ this(DBusConnection connection, string busName, string objectPath) { auto p = g_dbus_menu_model_get((connection is null) ? null : connection.getDBusConnectionStruct(), Str.toStringz(busName), Str.toStringz(objectPath)); if(p is null) { throw new ConstructionException("null returned by g_dbus_menu_model_get"); } this(cast(GDBusMenuModel*) p, true); } code: end struct: DBusObjectManagerClient alias: new newObjectManagerClient noCode: new_finish noCode: new_for_bus_finish code: start /** * Finishes an operation started with g_dbus_object_manager_client_new(). * * Params: * res = A GAsyncResult obtained from the GAsyncReadyCallback passed to the DBusObjectManager constructor. * forBus = If true finish an address. * * Throws: GException on failure. * Throws: ConstructionException GTK+ fails to create the object. * * Since: 2.30 */ public this (AsyncResultIF res, bool forBus = false) { GError* err = null; GDBusObjectManager* p; if ( forBus ) { p = g_dbus_object_manager_client_new_for_bus_finish((res is null) ? null : res.getAsyncResultStruct(), &err); } else { p = g_dbus_object_manager_client_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); } if (err !is null) { throw new GException( new ErrorG(err) ); } if(p is null) { throw new ConstructionException("null returned by g_dbus_object_manager_client_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); } this(cast(GDBusObjectManagerClient*) p, true); } code: end struct: DBusProxy alias: new newProxy noCode: new_finish noCode: new_for_bus_finish code: start /** * Finishes creating a GDBusProxy. * * Params: * res = A GAsyncResult obtained from the GAsyncReadyCallback * function passed to g_dbus_proxy_new(). * forBus = If true finish an address. * * Throws: GException on failure. * Throws: ConstructionException GTK+ fails to create the object. * * Since: 2.26 */ public this (AsyncResultIF res, bool forBus = false) { GError* err = null; GDBusProxy* p; if ( forBus ) { p = g_dbus_proxy_new_for_bus_finish((res is null) ? null : res.getAsyncResultStruct(), &err); } else { p = g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err); } if (err !is null) { throw new GException( new ErrorG(err) ); } if(p is null) { throw new ConstructionException("null returned by g_dbus_proxy_new_finish((res is null) ? null : res.getAsyncResultStruct(), &err)"); } this(p, true); } code: end version !Windows: start struct: DesktopAppInfo noCode: new_from_filename code: start /** * Creates a new #GDesktopAppInfo. * * Params: * filename = the path of a desktop file, in the GLib filename encoding * * Return: a new #GDesktopAppInfo or %NULL on error. * * Throws: ConstructionException GTK+ fails to create the object. */ public static DesktopAppInfo createFromFilename(string filename) { auto p = g_desktop_app_info_new_from_filename(Str.toStringz(filename)); if(p is null) { throw new ConstructionException("null returned by g_desktop_app_info_new_from_filename"); } return new DesktopAppInfo(p, true); } code: end version: end struct: FileAttributeInfoList array: infos n_infos struct: InetAddress noCode: new_any noCode: new_loopback code: start /** * Creates a InetAddress for the "any" address (unassigned/"don't * care") for family. * * Params: * family = the address family * loopback = If true create an InetAddress for the loopback address. * * Throws: ConstructionException GTK+ fails to create the object. * * Since: 2.22 */ public this (GSocketFamily family, bool loopback = false) { GInetAddress* p; if ( loopback ) { p = g_inet_address_new_loopback(family); } else { p = g_inet_address_new_any(family); } if(p is null) { throw new ConstructionException("null returned by g_inet_address_new_any(family)"); } this(p, true); } code: end struct: NoExternal noCode: true noExternal: true struct: IOModule move: load NoExternal move: unload NoExternal move: query NoExternal struct: MenuItem noCode: new_section noCode: new_submenu struct: OutputStream out: vprintf error struct: PollableUtils namespace: struct: Resource alias: _register register alias: _unregister unregister struct: SimpleAsyncResult noCode: new_take_error struct: SimpleProxyResolver array: new ignore_hosts array: set_ignore_hosts ignore_hosts struct: Socket ref: receive buffer ref: receive_from buffer out: receive_message messages out: receive_message num_messages struct: SubprocessLauncher array: set_environ env struct: ThemedIcon noCode: new struct: TlsPassword out: get_value length array: get_value Return length array: set_value value length array: set_value_full value length version !Windows: start struct: UnixMountEntry class: UnixMountEntry struct: UnixSocketAddress noCode: new_abstract version: end struct: VolumeMonitor import: glib.ConstructionException noCode: get code: start /** * Gets the volume monitor used by gio. * * Return: a reference to the #GVolumeMonitor used by gio. Call * g_object_unref() when done with it. */ public this() { auto p = g_volume_monitor_get(); if(p is null) { throw new ConstructionException("g_volume_monitor_get()"); } this(cast(GVolumeMonitor*) p, true); } code: end struct: move: bus_get DBusConnection get move: bus_get_finish DBusConnection get_finish move: bus_get_sync DBusConnection get_sync move: bus_own_name DBusNames own_name move: bus_own_name_on_connection DBusNames own_name_on_connection move: bus_own_name_on_connection_with_closures DBusNames own_name_on_connection_with_closures move: bus_own_name_with_closures DBusNames own_name_with_closures move: bus_unown_name DBusNames unown_name move: bus_unwatch_name DBusNames unwatch_name move: bus_watch_name DBusNames watch_name move: bus_watch_name_on_connection DBusNames watch_name_on_connection move: bus_watch_name_on_connection_with_closures DBusNames watch_name_on_connection_with_closures move: bus_watch_name_with_closures DBusNames watch_name_with_closures move: content_type_can_be_executable ContentType can_be_executable move: content_type_equals ContentType equals move: content_type_from_mime_type ContentType from_mime_type move: content_type_get_description ContentType get_description move: content_type_get_generic_icon_name ContentType get_generic_icon_name move: content_type_get_icon ContentType get_icon move: content_type_get_mime_type ContentType get_mime_type move: content_type_get_symbolic_icon ContentType get_symbolic_icon move: content_type_guess ContentType type_guess move: content_type_guess_for_tree ContentType guess_for_tree move: content_type_is_a ContentType is_a move: content_type_is_unknown ContentType is_unknown move: content_types_get_registered ContentType version 2.52: move: content_type_is_mime_type ContentType is_mime_type version 2.60: start move: content_type_get_mime_dirs ContentType get_mime_dirs move: content_type_set_mime_dirs ContentType set_mime_dirs version: end move: dbus_error_encode_gerror DBusError encode_gerror move: dbus_error_get_remote_error DBusError get_remote_error move: dbus_error_is_remote_error DBusError is_remote_error move: dbus_error_new_for_dbus_error DBusError new_for_dbus_error move: dbus_error_quark DBusError quark move: dbus_error_register_error DBusError register_error move: dbus_error_register_error_domain DBusError register_error_domain move: dbus_error_strip_remote_error DBusError strip_remote_error move: dbus_error_unregister_error DBusError unregister_error move: dbus_address_escape_value DBusUtilities address_escape_value move: dbus_address_get_for_bus_sync DBusUtilities address_get_for_bus_sync move: dbus_address_get_stream DBusUtilities address_get_stream move: dbus_address_get_stream_finish DBusUtilities address_get_stream_finish move: dbus_address_get_stream_sync DBusUtilities address_get_stream_sync move: dbus_generate_guid DBusUtilities generate_guid move: dbus_gvalue_to_gvariant DBusUtilities gvalue_to_gvariant move: dbus_gvariant_to_gvalue DBusUtilities gvariant_to_gvalue move: dbus_is_address DBusUtilities is_address move: dbus_is_guid DBusUtilities is_guid move: dbus_is_interface_name DBusUtilities is_interface_name move: dbus_is_member_name DBusUtilities is_member_name move: dbus_is_name DBusUtilities is_name move: dbus_is_supported_address DBusUtilities is_supported_address move: dbus_is_unique_name DBusUtilities is_unique_name struct: DBusUtilities out: address_get_stream_finish out_guid out: address_get_stream_sync out_guid move: io_error_from_errno ErrorGIO move: io_error_quark ErrorGIO move: io_modules_load_all_in_directory IOModule load_all_in_directory move: io_modules_load_all_in_directory_with_scope IOModule load_all_in_directory_with_scope move: io_modules_scan_all_in_directory IOModule scan_all_in_directory move: io_modules_scan_all_in_directory_with_scope IOModule scan_all_in_directory_with_scope move: io_scheduler_cancel_all_jobs IOSchedulerJob cancel_all_jobs move: io_scheduler_push_job IOSchedulerJob push_job move: pollable_source_new PollableUtils move: pollable_source_new_full PollableUtils move: pollable_stream_read PollableUtils move: pollable_stream_write PollableUtils move: pollable_stream_write_all PollableUtils move: resources_enumerate_children Resource move: resources_get_info Resource move: resources_lookup_data Resource move: resources_open_stream Resource move: resources_register Resource _register move: resources_unregister Resource _unregister move: keyfile_settings_backend_new SettingsBackend move: memory_settings_backend_new SettingsBackend move: null_settings_backend_new SettingsBackend move: simple_async_report_error_in_idle SimpleAsyncResult move: simple_async_report_gerror_in_idle SimpleAsyncResult move: simple_async_report_take_gerror_in_idle SimpleAsyncResult version !Windows: start move: unix_is_mount_path_system_internal UnixMountEntry is_mount_path_system_internal move: unix_mount_at UnixMountEntry at move: unix_mount_compare UnixMountEntry compare move: unix_mount_free UnixMountEntry free move: unix_mount_get_device_path UnixMountEntry get_device_path move: unix_mount_get_fs_type UnixMountEntry get_fs_type move: unix_mount_get_mount_path UnixMountEntry get_mount_path move: unix_mount_guess_can_eject UnixMountEntry guess_can_eject move: unix_mount_guess_icon UnixMountEntry guess_icon move: unix_mount_guess_name UnixMountEntry guess_name move: unix_mount_guess_should_display UnixMountEntry guess_should_display move: unix_mount_guess_symbolic_icon UnixMountEntry guess_symbolic_icon move: unix_mount_is_readonly UnixMountEntry is_readonly move: unix_mount_is_system_internal UnixMountEntry is_system_internal move: unix_mount_points_changed_since UnixMountEntry points_changed_since move: unix_mount_points_get UnixMountEntry mount_points_get move: unix_mounts_changed_since UnixMountEntry mounts_changed_since move: unix_mounts_get UnixMountEntry mounts_get version 2.54: start move: unix_mount_copy UnixMountEntry copy move: unix_mount_for UnixMountEntry mount_for version: end version 2.58: move: unix_mount_get_options UnixMountEntry get_options version 2.60: move: unix_mount_get_root_path UnixMountEntry get_root_path version: end GlibD-2.3.0/src/gtkd/000077500000000000000000000000001400304556600142205ustar00rootroot00000000000000GlibD-2.3.0/src/gtkd/Implement.d000066400000000000000000000354761400304556600163360ustar00rootroot00000000000000/* * 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 */ module gtkd.Implement; import std.algorithm; import std.traits; import std.meta; import std.range; import std.string; import std.uni; import std.conv; import gobject.c.types; /** * This template generates the boilerplate needed to override * GTK functions from D. * * Example: * -------------------------- * class MyApplication : Application * { * import gtkd.Implement; * import gobject.c.functions : g_object_newv; * * mixin ImplementClass!GtkApplication; * * this() * { * //TODO: sort out the constructor. * super(cast(GtkApplication*)g_object_newv(getType(), 0, null), true); * * setApplicationId("org.gtkd.demo.popupmenu"); * setFlags(GApplicationFlags.FLAGS_NONE); * } * * override void activate() * { * new PopupMenuDemo(this); * } * } * -------------------------- */ mixin template ImplementClass(Class) { mixin(ImplementClassImpl!(Class, typeof(this))()); } /** * This template generates the boilerplate needed to implement a * GTK interface in D. * * Base is the Gtk struct for the base class, and Iface is the * Gtk Iface struct for the interface. * * In your constructor you will need to instantiate the Gtk class * by calling the ObjectG costructor: `super(getType(), null);` * * If you are using ImplementInterface in conjunction with ImplementClass * you will need to mixin ImplementClass before mixing in any interfaces. */ mixin template ImplementInterface(Base, Iface) { mixin(ImplementInterfaceImpl!(Base, Iface, typeof(this))()); } template ImplementClassImpl(Klass, Impl) { string ImplementClassImpl() { string result; result ~= "import glib.Str;\n"~ "import gobject.Type : Type;\n"~ "import gobject.c.functions : g_type_class_peek_parent, g_object_get_data;\n"; if ( !is(Klass == gobject.c.types.GObject) ) result ~= "import "~ getTypeImport!Klass() ~": "~ getTypeFunction!Klass()[0..$-2] ~";\n"; if ( !hasMember!(Impl, toCamelCase!Impl()) ) { result ~= "\nstruct "~ toPascalCase!Impl() ~"\n"~ "{\n"~ "\t"~ Klass.stringof ~" parentInstance;\n"~ "}\n\n"; result ~= "struct "~ toPascalCase!Impl() ~"Class\n"~ "{\n"~ "\t"~ Klass.stringof ~"Class parentClass;\n"~ "}\n\n"; result ~= "protected "~ toPascalCase!Impl() ~"* "~ toCamelCase!Impl() ~";\n"~ "protected static "~ Klass.stringof ~"Class* parentClass = null;\n\n"; result ~= "protected override void* getStruct()\n"~ "{\n"~ "\treturn cast(void*)gObject;\n"~ "}\n\n"; } if ( !implements!Impl("getType") ) { result ~= "public static GType getType()\n"~ "{\n"~ "\timport std.algorithm : startsWith;\n\n"~ "\tGType "~ toCamelCase!Impl() ~"Type = Type.fromName(\""~ toPascalCase!Impl() ~"\");\n\n"~ "\tif ("~ toCamelCase!Impl() ~"Type == GType.INVALID)\n"~ "\t{\n"~ "\t\t"~ toCamelCase!Impl() ~"Type = Type.registerStaticSimple(\n"~ "\t\t\t"~ getTypeFunction!Klass() ~",\n"~ "\t\t\t\""~ toPascalCase!Impl() ~"\",\n"~ "\t\t\tcast(uint)"~ toPascalCase!Impl() ~"Class.sizeof,\n"~ "\t\t\tcast(GClassInitFunc) &"~ toCamelCase!Impl() ~"ClassInit,\n"~ "\t\t\tcast(uint)"~ toPascalCase!Impl() ~".sizeof, null, cast(GTypeFlags)0);\n\n"~ "\t\tforeach ( member; __traits(derivedMembers, "~ Impl.stringof ~") )\n"~ "\t\t{\n"~ "\t\t\tstatic if ( member.startsWith(\"_implementInterface\") )\n"~ "\t\t\t\t__traits(getMember, "~ Impl.stringof ~", member)("~ toCamelCase!Impl() ~"Type);\n"~ "\t\t}\n"~ "\t}\n\n"~ "\treturn "~ toCamelCase!Impl() ~"Type;\n"~ "}\n\n"; } result ~= "extern(C)\n{\n"; if ( !implements!Impl(toCamelCase!Impl() ~"ClassInit") ) { result ~= "static void "~ toCamelCase!Impl() ~"ClassInit (void* klass)\n"~ "{\n"~ "\tparentClass = cast("~ Klass.stringof ~"Class*) g_type_class_peek_parent(klass);\n"; result ~= setFunctionPointers!(getClass!Klass)(); result ~= "}\n\n"; } result ~= getWrapFunctions!(getClass!Klass)(); result ~= "}"; return result; } string setFunctionPointers(GtkClass)() { string result; alias names = FieldNameTuple!GtkClass; foreach ( i, member; Fields!GtkClass ) { static if ( names[i] == "parentClass" ) { result ~= "\t"~ fullyQualifiedName!member ~"* "~ toCamelCase!member() ~" = cast("~ fullyQualifiedName!member ~"*)klass;\n"; result ~= setFunctionPointers!member(); } else if ( isCallable!member && implements!Impl(names[i]) && !implements!Impl(toCamelCase!Impl() ~ names[i].capitalizeFirst) ) //TODO: __traits(isOverrideFunction, Foo.foo) ? { result ~= "\t"~ toCamelCase!GtkClass() ~"."~ names[i] ~" = &"~ toCamelCase!Impl() ~ names[i].capitalizeFirst ~";\n"; } } result ~= "\n"; return result; } string getWrapFunctions(GtkClass)() { string result; alias names = FieldNameTuple!GtkClass; foreach ( i, member; Fields!GtkClass ) { static if ( names[i] == "parentClass" ) { result ~= getWrapFunctions!member(); } else static if ( isCallable!member && implements!Impl(names[i]) && !implements!Impl(toCamelCase!Impl() ~ names[i].capitalizeFirst) ) //TODO: __traits(isOverrideFunction, Foo.foo) ? { result ~= getWrapFunction!(Impl, member, names[i]); } } return result; } template getClass(Instance) { mixin("import "~ getClassImport!Instance() ~"; alias getClass = "~ Instance.stringof ~"Class;"); } private string getClassImport(Klass)() { return fullyQualifiedName!Klass.replace("."~ Klass.stringof, ""); } } template ImplementInterfaceImpl(Base, Klass, Impl) { string ImplementInterfaceImpl() { string result; result ~= "import glib.Str;\n"~ "import gobject.Type : Type;\n"~ "import gobject.c.functions : g_type_class_peek_parent, g_object_get_data;\n"; if ( !is(Base == gobject.c.types.GObject) ) result ~= "import "~ getTypeImport!Base() ~": "~ getTypeFunction!Base()[0..$-2] ~";\n"; result ~= "import "~ getTypeImport!Klass() ~" : "~ getTypeFunction!Klass()[0..$-2] ~";\n\n"; if ( !hasMember!(Impl, toCamelCase!Impl()) ) { result ~= "\nstruct "~ toPascalCase!Impl() ~"\n"~ "{\n"~ "\t"~ Base.stringof ~" parentInstance;\n"~ "}\n\n"; result ~= "struct "~ toPascalCase!Impl() ~"Class\n"~ "{\n"~ "\t"~ Base.stringof ~"Class parentClass;\n"~ "}\n\n"; result ~= "protected "~ toPascalCase!Impl() ~"* "~ toCamelCase!Impl() ~";\n"~ "protected static "~ Base.stringof ~"Class* parentClass = null;\n\n"; result ~= "protected override void* getStruct()\n"~ "{\n"~ "\treturn cast(void*)gObject;\n"~ "}\n\n"; if ( is(Base == gobject.c.types.GObject) ) { result ~= "public this()\n"~ "{\n"~ "\tauto p = super(getType(), null);\n"~ "\t"~ toCamelCase!Impl() ~" = cast("~ toPascalCase!Impl() ~"*) p.getObjectGStruct();\n"~ "}\n\n"; } } if ( !implements!Impl("getType") ) { result ~= "public static GType getType()\n"~ "{\n"~ "\tGType "~ toCamelCase!Impl() ~"Type = Type.fromName(\""~ toPascalCase!Impl() ~"\");\n\n"~ "\tif ("~ toCamelCase!Impl() ~"Type == GType.INVALID)\n"~ "\t{\n"~ "\t\t"~ toCamelCase!Impl() ~"Type = Type.registerStaticSimple(\n"~ "\t\t\t"~ getTypeFunction!Base() ~",\n"~ "\t\t\t\""~ toPascalCase!Impl() ~"\",\n"~ "\t\t\tcast(uint)"~ toPascalCase!Impl() ~"Class.sizeof,\n"~ "\t\t\tcast(GClassInitFunc) &"~ toCamelCase!Impl() ~"ClassInit,\n"~ "\t\t\tcast(uint)"~ toPascalCase!Impl() ~".sizeof, null, cast(GTypeFlags)0);\n\n"~ "\t\tforeach ( member; __traits(derivedMembers, "~ Impl.stringof ~") )\n"~ "\t\t{\n"~ "\t\t\tstatic if ( member.startsWith(\"_implementInterface\") )\n"~ "\t\t\t\t__traits(getMember, "~ Impl.stringof ~", member)("~ toCamelCase!Impl() ~"Type);\n"~ "\t\t}\n"~ "\t}\n\n"~ "\treturn "~ toCamelCase!Impl() ~"Type;\n"~ "}\n\n"; } result ~= "static void _implementInterface"~ Klass.stringof ~"(GType type)\n"~ "{\n"~ "\tGInterfaceInfo "~ Klass.stringof ~"Info =\n"~ "\t{\n"~ "\t\tcast(GInterfaceInitFunc) &"~ toCamelCase!Klass() ~"Init,\n"~ "\t\tnull,\n"~ "\t\tnull\n"~ "\t};\n"~ "\tType.addInterfaceStatic(type, "~ getTypeFunction!Klass() ~", &"~ Klass.stringof ~"Info);\n"~ "};\n\n"; result ~= "extern(C)\n{\n"; if ( !implements!Impl(toCamelCase!Impl() ~"ClassInit") ) { result ~= "static void "~ toCamelCase!Impl() ~"ClassInit (void* klass)\n"~ "{\n"~ "\tparentClass = cast("~ Base.stringof ~"Class*) g_type_class_peek_parent(klass);\n"~ "}\n\n"; } if ( !implements!Impl(toCamelCase!Klass() ~"Init") ) { result ~= "static void "~ toCamelCase!Klass() ~"Init ("~ Klass.stringof ~" *iface)\n"~ "{\n"; auto names = FieldNameTuple!Klass; foreach ( i, member; Fields!Klass ) { if ( isCallable!member && implements!Impl(names[i]) && (!implements!Impl("addOn"~ names[i].capitalizeFirst) || implements!Impl(toCamelCase!Impl() ~ names[i].capitalizeFirst) ) ) { result ~= "\tiface."~ names[i] ~" = &"~ toCamelCase!Impl() ~ names[i].capitalizeFirst ~";\n"; } } result ~= "}\n\n"; } alias names = FieldNameTuple!Klass; foreach ( i, member; Fields!Klass ) { if ( isCallable!member && implements!Impl(names[i]) && !implements!Impl(toCamelCase!Impl() ~ names[i].capitalizeFirst) && !implements!Impl("addOn"~ names[i].capitalizeFirst) ) { result ~= getWrapFunction!(Impl, member, names[i]); } } result ~= "}"; return result; } } private string getTypeFunction(Iface)() { string result; if ( is(Iface == gobject.c.types.GObject) ) return "GType.OBJECT"; else { foreach ( i, char c; Iface.stringof ) { if ( c.isUpper && i > 0 ) result ~= "_"~c; else result ~= c; } return result.toLower.replace("_iface", "")~ "_get_type()"; } } private string getTypeImport(Iface)() { return fullyQualifiedName!Iface.replace("types."~ Iface.stringof, "functions"); } private string getWrapFunction(Impl, Member, string name)() { string result; static if ( isCallable!Member ) { alias Params = Parameters!Member; alias STC = ParameterStorageClass; auto ParamStorage = [STC.none, ParameterStorageClassTuple!(__traits(getMember, Impl, name))]; auto ParamNames = ["iface", ParameterIdentifierTuple!(__traits(getMember, Impl, name))]; alias DParamTypes = AliasSeq!(void, Parameters!(__traits(getMember, Impl, name))); result ~= "static "~ ReturnType!Member.stringof ~" "~ toCamelCase!Impl() ~ name.capitalizeFirst ~"("; foreach ( i, param; Params ) { if ( i > 0 ) result ~= ", "; result ~= param.stringof ~" "~ ParamNames[i]; } result ~= ")\n"~ "{\n"; if ( implements!Impl("get"~ Impl.stringof ~"Struct") && implements!Impl("getStruct") ) result ~= "\tauto impl = ObjectG.getDObject!("~ Impl.stringof ~")(cast("~ toPascalCase!Impl() ~"*)iface);\n"; else result ~= "\tauto impl = cast("~ Impl.stringof ~")g_object_get_data(cast(GObject*)iface, \"GObject\".ptr);\n"; foreach ( i, param; Params ) { if ( ParamStorage[i] == STC.out_ && isGtkdType!(DParamTypes[i]) ) result ~= "\t"~ DParamTypes[i].stringof ~" d_"~ ParamNames[i] ~";\n"; else if ( ParamStorage[i] == STC.ref_ && isGtkdType!(DParamTypes[i]) ) result ~= "\t"~ DParamTypes[i].stringof ~" d_"~ ParamNames[i] ~" = "~ ParamNames[i] ~".get"~ DParamTypes[i].stringof ~"Struct();\n"; } if ( is(ReturnType!Member == void) ) result ~= "\n\timpl."~ name ~"("; else result ~= "\n\tauto ret = impl."~ name ~"("; foreach ( i, param; Params ) { if ( i == 0 ) continue; else { if ( i > 1 ) result ~= ", "; if ( (ParamStorage[i] == STC.out_ || ParamStorage[i] == STC.ref_) && isGtkdType!(DParamTypes[i]) ) result ~= "d_"~ ParamNames[i]; else if ( isGtkdType!(DParamTypes[i]) ) result ~= "ObjectG.getDObject!("~ DParamTypes[i].stringof ~")("~ ParamNames[i] ~")"; else result ~= ParamNames[i]; } } result ~= ");\n\n"; foreach ( i, param; Params ) { if ( (ParamStorage[i] == STC.out_ || ParamStorage[i] == STC.ref_) && isGtkdType!(DParamTypes[i]) ) { result ~= "\tif ( d_"~ ParamNames[i] ~" !is null )\n"~ "\t\t"~ ParamNames[i] ~" = d_"~ ParamNames[i] ~".get"~ DParamTypes[i].stringof ~"Struct();\n"; } } if ( isGtkdType!(ReturnType!(__traits(getMember, Impl, name))) && isPointer!(ReturnType!Member) ) result ~= "\treturn ret.get"~ (ReturnType!(__traits(getMember, Impl, name))).stringof ~"Struct();\n"; else if ( !is(ReturnType!Member == void) ) result ~= "\treturn ret;\n"; result ~= "}\n\n"; } return result; } private string toCamelCase(Type)() { string result; foreach (i, word; to!string(fullyQualifiedName!Type).split(".")) { if ( i == 0 ) word = word[0 .. 1].toLower ~ word[1 .. $]; else word = word.capitalizeFirst; result ~= word; } return result; } private string toPascalCase(Type)() { string result; foreach (word; to!string(fullyQualifiedName!Type).split(".")) { result ~= word.capitalizeFirst; } return result; } private template isGtkdType(T) { static if ( __traits(compiles, new T(cast(typeof(T.tupleof[0]))null, true)) ) enum bool isGtkdType = hasMember!(T, "get"~ T.stringof ~"Struct"); else enum bool isGtkdType = false; } private bool implements(Impl)(string member) { return (cast(string[])[__traits(derivedMembers, Impl)]).canFind(member); } private string capitalizeFirst(string str) { if ( str.empty ) return str; else if ( str.length == 1 ) return str.toUpper; else return str[0 .. 1].toUpper ~ str[1 .. $]; } GlibD-2.3.0/src/gtkd/Loader.d000066400000000000000000000233441400304556600156010ustar00rootroot00000000000000/* * 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 */ module gtkd.Loader; import std.algorithm : canFind; import std.stdio; import std.string; import gtkd.paths; public struct Linker { private static void*[string] loadedLibraries; private static string[][string] loadFailures; extern(C) static void unsupportedSymbol() { throw new Error("The function you are calling is not pressent in your version of GTK+."); } /* * Links the provided symbol * Params: * funct = The function we are linking * symbol = The name of the symbol to link * libraries = One or more libraries to search for the symbol */ deprecated("Use the LIBRARY_* symbols defined for each package, instead of gtkd.paths.LIBRARY") public static void link(T)(ref T funct, string symbol, LIBRARY[] libraries ...) { funct = cast(T)getSymbol(symbol, libraries); } /* * Links the provided symbol * Params: * funct = The function we are linking * symbol = The name of the symbol to link * libraries = One or more libraries to search for the symbol */ public static void link(T)(ref T funct, string symbol, const string[] libraries ...) { funct = cast(T)getSymbol(symbol, libraries); } /* * Gets a simbol from one of the provided libraries * Params: * symbol = The name of the symbol to link * libraries = One or more libraries to search for the symbol */ deprecated("Use the LIBRARY_* symbols defined for each package, instead of gtkd.paths.LIBRARY") public static void* getSymbol(string symbol, LIBRARY[] libraries ...) { string[] libStr = new string[libraries.length]; foreach (i, library; libraries ) { libStr[i] = importLibs[library]; } return getSymbol(symbol, libStr); } /* * Gets a simbol from one of the provided libraries * Params: * symbol = The name of the symbol to link * libraries = One or more libraries to search for the symbol */ public static void* getSymbol(string symbol, const string[] libraries ...) { void* handle; foreach ( library; libraries ) { if( !(library in loadedLibraries) ) loadLibrary(library); handle = pGetSymbol(loadedLibraries[library], symbol); if ( handle !is null ) break; } if ( handle is null ) { foreach ( library; libraries ) loadFailures[library] ~= symbol; handle = &unsupportedSymbol; } return handle; } /* * Loads a library */ public static void loadLibrary(string library) { void* handle; if ( library.canFind(';') ) { foreach ( lib; library.split(';') ) { handle = pLoadLibrary(lib); if ( handle ) break; } } else { handle = pLoadLibrary(library); } if ( handle is null ) throw new Exception("Library load failed ("~ library ~"): "~ getErrorMessage()); loadedLibraries[library] = handle; } /* * Unload a library */ deprecated("Use the LIBRARY_* symbols defined for each package, instead of gtkd.paths.LIBRARY") public static void unloadLibrary(LIBRARY library) { unloadLibrary( importLibs[library] ); } /* * Unload a library */ public static void unloadLibrary(string library) { pUnloadLibrary(loadedLibraries[library]); loadedLibraries.remove(library); } ///Ditto public static void unloadLibrary(const string[] libraries) { foreach ( lib; libraries ) { unloadLibrary(lib); } } /** * Checks if any symbol failed to load * Returns: true if ALL symbols are loaded */ public static bool isPerfectLoad() { return loadFailures.keys.length == 0; } /** * Gets all libraries loaded. * returns: An array with the loaded libraries */ public static string[] getLoadLibraries() { return loadedLibraries.keys; } /** * Print all libraries loaded. */ public static void dumpLoadLibraries() { foreach ( lib; getLoadLibraries() ) { writefln("Loaded lib = %s", lib); } } /** * Checks if a library is loaded. * Returns: true is the library was loaded sucsessfully. */ deprecated("Use the LIBRARY_* symbols defined for each package, instead of gtkd.paths.LIBRARY") public static bool isLoaded(LIBRARY library) { return isLoaded(importLibs[library]); } /** * Checks if a library is loaded. * Returns: true is the library was loaded sucsessfully. */ public static bool isLoaded(string library) { if ( library in loadedLibraries ) return true; else return false; } ///Ditto public static bool isLoaded(const string[] libraries) { return isLoaded(libraries[0]); } /** * Gets all the failed loads for a specific library. * returns: An array of the names hat failed to load for a specific library * or null if none was found */ deprecated("Use the LIBRARY_* symbols defined for each package, instead of gtkd.paths.LIBRARY") public static string[] getLoadFailures(LIBRARY library) { return getLoadFailures(importLibs[library]); } /** * Gets all the failed loads for a specific library. * returns: An array of the names hat failed to load for a specific library * or null if none was found */ public static string[] getLoadFailures(string library) { if ( library in loadFailures ) return loadFailures[library]; else return null; } ///Ditto. public static string[] getLoadFailures(const string[] libraries) { string[] failures; foreach ( lib; libraries ) { failures ~= getLoadFailures(lib); } return failures; } /** * Print all symbols that failed to load */ public static void dumpFailedLoads() { foreach ( library; loadedLibraries.keys ) { foreach ( symbol; getLoadFailures(library) ) { writefln("failed (%s) %s", library, symbol); } } } static ~this() { foreach ( library; loadedLibraries.keys ) unloadLibrary(library); } } // Platform specific implementation below. version(Windows) { import core.sys.windows.winbase : LoadLibraryA, GetProcAddress, FreeLibrary, GetLastError, FormatMessageA, FORMAT_MESSAGE_FROM_SYSTEM, FORMAT_MESSAGE_ARGUMENT_ARRAY; import core.sys.windows.winnt : LANG_NEUTRAL, IMAGE_FILE_MACHINE_AMD64, IMAGE_FILE_MACHINE_I386; extern(Windows) { int SetDllDirectoryA(const(char)* path); } private void* pLoadLibrary(string libraryName) { setDllPath(); return LoadLibraryA(cast(char*)toStringz(libraryName)); } private void* pGetSymbol(void* handle, string symbol) { return GetProcAddress(handle, cast(char*)toStringz(symbol)); } private alias FreeLibrary pUnloadLibrary; private string getErrorMessage() { char[] buffer = new char[2048]; buffer[0] = '\0'; FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY, null, GetLastError(), LANG_NEUTRAL, buffer.ptr, cast(uint)buffer.length, cast(char**)["\0".ptr].ptr); return buffer.ptr.fromStringz.idup; } private void setDllPath() { static bool isSet; if ( isSet ) return; string gtkPath = getGtkPath(); if ( gtkPath.length > 0 ) SetDllDirectoryA((gtkPath~'\0').ptr); isSet = true; } private string getGtkPath() { import std.algorithm; import std.path; import std.process; import std.file; foreach (path; splitter(environment.get("PATH"), ';')) { string dllPath = buildNormalizedPath(path, "libgtk-3-0.dll"); if ( !exists(dllPath) ) continue; if ( checkArchitecture(dllPath) ) return path; } return null; } private bool checkArchitecture(string dllPath) { import std.stdio; File dll = File(dllPath); dll.seek(0x3c); int offset = dll.rawRead(new int[1])[0]; dll.seek(offset); uint peHead = dll.rawRead(new uint[1])[0]; //Not a PE Header. if( peHead != 0x00004550) return false; ushort type = dll.rawRead(new ushort[1])[0]; version(Win32) { if ( type == IMAGE_FILE_MACHINE_I386 ) return true; } else version(Win64) { if ( type == IMAGE_FILE_MACHINE_AMD64 ) return true; } return false; } } else { import core.sys.posix.dlfcn : dlopen, dlerror, dlsym, dlclose, RTLD_NOW, RTLD_GLOBAL; import std.path : buildPath; private string lastError; version(OSX) { string basePath() { import std.process; static string path; if (path !is null) return path; path = environment.get("GTK_BASEPATH"); if(!path){ path=environment.get("HOMEBREW_ROOT"); if(path){ path=path.buildPath("lib"); } } return path; } } else { enum basePath = ""; } private void* pLoadLibrary(string libraryName, int flag = RTLD_NOW) { void* handle = dlopen(cast(char*)toStringz(basePath.buildPath(libraryName)), flag | RTLD_GLOBAL); if(!handle){ lastError = dlerror().fromStringz.idup; } // clear the error buffer dlerror(); return handle; } private void* pGetSymbol(void* libraryHandle, string symbol) { void* symbolHandle = dlsym(libraryHandle, cast(char*)toStringz(symbol)); // clear the error buffer dlerror(); return symbolHandle; } private int pUnloadLibrary(void* libraryHandle) { return dlclose(libraryHandle); } private string getErrorMessage() { scope(exit) lastError = null; return lastError; } } GlibD-2.3.0/src/gtkd/paths.d000066400000000000000000000112051400304556600155030ustar00rootroot00000000000000/* * 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 * * paths.d -- list of libraries that will be dynamically linked with gtkD * * Added: John Reimer -- 2004-12-20 * Updated: 2005-02-21 changed names; added version(linux) * Updated: 2005-05-05 updated Linux support * Updated: 2008-02-16 Tango support */ module gtkd.paths; /* * Define the Libraries that gtkD will be using. * This is a growable list, as long as the programmer * also adds to the importLibs list. */ enum LIBRARY { ATK, CAIRO, GDK, GDKPIXBUF, GLIB, GMODULE, GOBJECT, GIO, GTHREAD, GTK, PANGO, PANGOCAIRO, GLGDK, GLGTK, GDA, GSV, GSV1, GSTREAMER, GSTINTERFACES, VTE, PEAS, RSVG, } version (Windows) { const string[LIBRARY.max+1] importLibs = [ LIBRARY.ATK: "libatk-1.0-0.dll", LIBRARY.CAIRO: "libcairo-2.dll", LIBRARY.GDK: "libgdk-3-0.dll", LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0-0.dll", LIBRARY.GLIB: "libglib-2.0-0.dll", LIBRARY.GMODULE: "libgmodule-2.0-0.dll", LIBRARY.GOBJECT: "libgobject-2.0-0.dll", LIBRARY.GIO: "libgio-2.0-0.dll", LIBRARY.GTHREAD: "libgthread-2.0-0.dll", LIBRARY.GTK: "libgtk-3-0.dll", LIBRARY.PANGO: "libpango-1.0-0.dll", LIBRARY.PANGOCAIRO: "libpangocairo-1.0-0.dll", LIBRARY.GLGDK: "libgdkglext-3.0-0.dll", LIBRARY.GLGTK: "libgtkglext-3.0-0.dll", LIBRARY.GDA: "libgda-4.0-4.dll", LIBRARY.GSV: "libgtksourceview-3.0-0.dll", LIBRARY.GSV1: "libgtksourceview-3.0-1.dll", LIBRARY.GSTREAMER: "libgstreamer-1.0.dll", LIBRARY.GSTINTERFACES: "libgstvideo-1.0.dll", LIBRARY.VTE: "libvte-2.91.dll", LIBRARY.PEAS: "libpeas-1.0.dll", LIBRARY.RSVG: "librsvg-2-2.dll", ]; } else version(darwin) { const string[LIBRARY.max+1] importLibs = [ LIBRARY.ATK: "libatk-1.0.dylib", LIBRARY.CAIRO: "libcairo.dylib", LIBRARY.GDK: "libgdk-3.0.dylib", LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0.dylib", LIBRARY.GLIB: "libglib-2.0.dylib", LIBRARY.GMODULE: "libgmodule-2.0.dylib", LIBRARY.GOBJECT: "libgobject-2.0.dylib", LIBRARY.GIO: "libgio-2.0.dylib", LIBRARY.GTHREAD: "libgthread-2.0.dylib", LIBRARY.GTK: "libgtk-3.0.dylib", LIBRARY.PANGO: "libpango-1.0.dylib", LIBRARY.PANGOCAIRO: "libpangocairo-1.0.dylib", LIBRARY.GLGDK: "libgdkglext-3.0.dylib", LIBRARY.GLGTK: "libgtkglext-3.0.dylib", LIBRARY.GDA: "libgda-2.dylib", LIBRARY.GSV: "libgtksourceview-3.0.dylib", LIBRARY.GSV1: "libgtksourceview-3.0.dylib", LIBRARY.GSTREAMER: "libgstreamer-1.0.dylib", LIBRARY.GSTINTERFACES: "libgstvideo-1.0.dylib", LIBRARY.VTE: "libvte-2.91.dylib", LIBRARY.PEAS: "libpeas-1.0.dylib", LIBRARY.RSVG: "librsvg-2.dylib", ]; } else { const string[LIBRARY.max+1] importLibs = [ LIBRARY.ATK: "libatk-1.0.so.0", LIBRARY.CAIRO: "libcairo.so.2", LIBRARY.GDK: "libgdk-3.so.0", LIBRARY.GDKPIXBUF: "libgdk_pixbuf-2.0.so.0", LIBRARY.GLIB: "libglib-2.0.so.0", LIBRARY.GMODULE: "libgmodule-2.0.so.0", LIBRARY.GOBJECT: "libgobject-2.0.so.0", LIBRARY.GIO: "libgio-2.0.so.0", LIBRARY.GTHREAD: "libgthread-2.0.so.0", LIBRARY.GTK: "libgtk-3.so.0", LIBRARY.PANGO: "libpango-1.0.so.0", LIBRARY.PANGOCAIRO: "libpangocairo-1.0.so.0", LIBRARY.GLGDK: "libgdkglext-3.0.so.0", LIBRARY.GLGTK: "libgtkglext-3.0.so.0", LIBRARY.GDA: "libgda-4.0.so.4", LIBRARY.GSV: "libgtksourceview-3.0.so.0", LIBRARY.GSV1: "libgtksourceview-3.0.so.1", LIBRARY.GSTREAMER: "libgstreamer-1.0.so.0", LIBRARY.GSTINTERFACES: "libgstvideo-1.0.so.0", LIBRARY.VTE: "libvte-2.91.so.0", LIBRARY.PEAS: "libpeas-1.0.so.0", LIBRARY.RSVG: "librsvg-2.so.2", ]; } GlibD-2.3.0/tests/000077500000000000000000000000001400304556600136425ustar00rootroot00000000000000GlibD-2.3.0/tests/gobject/000077500000000000000000000000001400304556600152575ustar00rootroot00000000000000GlibD-2.3.0/tests/gobject/DClosureTest.d000066400000000000000000000031141400304556600200030ustar00rootroot00000000000000/* * 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 */ import gobject.DClosure; import gobject.Value; import gio.FileInfo; static void foo() {} struct Baz { void opCall() {} } void main() { DClosure closure; FileInfo info = new FileInfo(); void bar() {} Baz baz; closure = new DClosure(&foo); closure = new DClosure(&bar); closure = new DClosure(baz); bool test(char c, int i, float f, string s, FileInfo o) { assert(c == 't'); assert(i == 10); assert(f == 0x1.99999ap-3f); assert(s == "test"); assert(o is info); return true; } closure = new DClosure(&test); Value[] params = [new Value('t'), new Value(10), new Value(0x1.99999ap-3f), new Value("test"), new Value(info)]; Value ret = new Value(); ret.init(GType.BOOLEAN); closure.invoke(ret, params, null); assert(ret.gType == GType.BOOLEAN); assert(ret.get!bool == true); } GlibD-2.3.0/tests/gobject/ObjectGTest.d000066400000000000000000000021331400304556600176000ustar00rootroot00000000000000/* * 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 */ import gobject.ObjectG; import gobject.c.functions; import gio.Cancellable; void main() { //Check if the toggleRef is correctly set/removed when casting using ObjectG.opCast. ObjectG obj = new ObjectG( cast(GObject*)g_object_new(Cancellable.getType(), null, null) ); Cancellable can = cast(Cancellable)obj; } GlibD-2.3.0/tests/gobject/ValueTest.d000066400000000000000000000022721400304556600173430ustar00rootroot00000000000000/* * 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 */ import gobject.Value; import gio.IconIF; import gio.ThemedIcon; void main() { Value val = new Value(true); assert(val.get!bool()); val = new Value(42); assert(val.get!int() == 42); val = new Value(1.12); assert(val.get!double() == 1.12); ThemedIcon icon = new ThemedIcon("gnome-dev-cdrom-audio"); val = new Value(icon); assert(val.get!ThemedIcon() is icon); assert(val.get!IconIF() is icon); } GlibD-2.3.0/tests/gobject/meson.build000066400000000000000000000012401400304556600174160ustar00rootroot00000000000000dclosure_test = executable( 'dclosure_test', 'DClosureTest.d', include_directories: [gir_bind_dir], dependencies: [glib_dep, gobject_dep, gio_dep], link_with: [glibd] ) test('gobject_dclosure_test', dclosure_test) objectg_test = executable( 'objectg_test', 'ObjectGTest.d', include_directories: [gir_bind_dir], dependencies: [glib_dep, gobject_dep, gio_dep], link_with: [glibd] ) test('gobject_objectg_test', objectg_test, env: ['G_DEBUG=fatal-warnings']) value_test = executable( 'value_test', 'ValueTest.d', include_directories: [gir_bind_dir], dependencies: [glib_dep, gobject_dep, gio_dep], link_with: [glibd] ) test('gobject_value_test', value_test) GlibD-2.3.0/tests/meson.build000066400000000000000000000000231400304556600157770ustar00rootroot00000000000000 subdir('gobject')