I've no idea here...
[gtkD.git] / gtkD / src / gobject / ObjectG.d
blob61ed29aea4aa4e1db1a802e2e8f8bba5fa192322
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gobject-The-Base-Object-Type.html
26 * outPack = gobject
27 * outFile = ObjectG
28 * strct = GObject
29 * realStrct=
30 * ctorStrct=
31 * clss = ObjectG
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_object_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * - g_object_set_data_full
44 * imports:
45 * - gobject.ParamSpec
46 * - gobject.Value
47 * - gobject.Closure
48 * - std.gc
49 * - glib.Str
50 * structWrap:
51 * - GClosure* -> Closure
52 * - GParamSpec* -> ParamSpec
53 * - GValue* -> Value
54 * module aliases:
55 * local aliases:
58 module gobject.ObjectG;
60 version(noAssert)
62 version(Tango)
64 import tango.io.Stdout; // use the tango loging?
68 private import gtkc.gobjecttypes;
70 private import gtkc.gobject;
73 private import gobject.ParamSpec;
74 private import gobject.Value;
75 private import gobject.Closure;
76 private import glib.Str;
79 version(Tango) {
80 private import tango.core.Memory;
81 } else {
82 private import std.gc;
88 /**
89 * Description
90 * GObject is the fundamental type providing the common attributes and methods
91 * for all object types in GTK+, Pango and other libraries based on GObject.
92 * The GObject class provides methods for object construction and destruction,
93 * property access methods, and signal support.
94 * Signals are described in detail in Signals(3).
95 * GInitiallyUnowned is derived from GObject. The only difference between
96 * the two is that the initial reference of a GInitiallyUnowned is flagged
97 * as a floating reference.
98 * This means that it is not specifically claimed to be "owned" by
99 * any code portion. The main motivation for providing floating references is
100 * C convenience. In particular, it allows code to be written as:
101 * Example1.
102 * container = create_container();
103 * container_add_child (container, create_child());
104 * If container_add_child() will g_object_ref_sink() the
105 * passed in child, no reference of the newly created child is leaked.
106 * Without floating references, container_add_child()
107 * can only g_object_ref() the new child, so to implement this code without
108 * reference leaks, it would have to be written as:
109 * Example2.
110 * Child *child;
111 * container = create_container();
112 * child = create_child();
113 * container_add_child (container, child);
114 * g_object_unref (child);
115 * The floating reference can be converted into
116 * an ordinary reference by calling g_object_ref_sink().
117 * For already sunken objects (objects that don't have a floating reference
118 * anymore), g_object_ref_sink() is equivalent to g_object_ref() and returns
119 * a new reference.
120 * Since floating references are useful almost exclusively for C convenience,
121 * language bindings that provide automated reference and memory ownership
122 * maintenance (such as smart pointers or garbage collection) therefore don't
123 * need to expose floating references in their API.
124 * Some object implementations may need to save an objects floating state
125 * across certain code portions (an example is GtkMenu), to achive this, the
126 * following sequence can be used:
127 * Example3.
128 * /+* save floating state +/
129 * gboolean was_floating = g_object_is_floating (object);
130 * g_object_ref_sink (object);
131 * /+* protected code portion +/
132 * ...;
133 * /+* restore floating state +/
134 * if (was_floating)
135 * g_object_force_floating (object);
136 * g_obejct_unref (object); /+* release previously acquired reference +/
138 public class ObjectG
141 /** the main Gtk struct */
142 protected GObject* gObject;
145 public GObject* getObjectGStruct()
147 return gObject;
151 /** the main Gtk struct as a void* */
152 protected void* getStruct()
154 return cast(void*)gObject;
159 * Sets our main struct and passes store it on the gobject.
160 * Add a gabage collector root to the gtk+ struct so it doesn't get collect
162 public this (GObject* gObject)
164 this.gObject = gObject;
165 if ( gObject !is null )
167 //writefln("ObjectG.this\n");
168 setDataFull("GObject",cast(void*)this);
173 * Sets a pointer on this object's has table
174 * @param key the data identifier
175 * @param data a pointer
177 public: void setDataFull(char[] key, gpointer data)
179 //writefln("setData objectG=%X data=%X type %s",gObject,data,key);
180 version(Tango) GC.addRoot(data);
181 else std.gc.addRoot(data);
182 g_object_set_data_full(gObject, Str.toStringz(key), data, cast(GDestroyNotify)&destroyNotify);
185 extern(C)
187 static void destroyNotify(gpointer* data)
189 //writefln("objectg.destroy entry");
190 //writefln("objectg.destroy");
191 //writefln("removing gc.root to %s",data);
192 version(Tango) GC.removeRoot(data);
193 else std.gc.removeRoot(data);
194 //writefln("objectg.destroy exit");
198 //debug = objectstore;
200 //debug(objectstore)
202 // private import std.stdio;
205 // /**
206 // * Maps Gtk structures to GtkD Objects
207 // */
208 // private static ObjectStore objectStore;
210 // /**
211 // * Creates the statis ObjectStore object
212 // */
213 // static this()
214 // {
215 // objectStore = new ObjectStore();
216 // }
218 // /**
219 // * Sets our main struct and passes store it on the gobject.
220 // * Adds a gabage collector root to the gtk+ struct so it doesn't get collect
221 // * adds the object to the objectStore
222 // */
223 // public this (GObject* gObject)
224 // {
225 // this.gObject = gObject;
226 // if ( gObject !is null )
227 // {
228 // //writefln("ObjectG.this\n");
229 // objectStore.putObject(this, gObject);
230 // setDestroyNotify("GObject",gObject);
231 // }
232 // }
236 // /**
237 // * Maintains the map from Gtk structures to GtkD objects
238 // */
239 // private static class ObjectStore
240 // {
241 // static ObjectG[void*] objectStore;
243 // /**
244 // * Puts a new gtk struct to GtkD objects
245 // */
246 // void putObject(ObjectG objectG, GObject* gtkStruct)
247 // {
248 // objectStore[gtkStruct] = objectG;
249 // debug(objectstore)
250 // {
251 // writefln("ObjectStore.putObject gtkStruct = %s (total=%s)", gtkStruct, objectStore.length);
252 // }
253 // }
255 // /**
256 // * Gets a GtkD object from a gtk struct.
257 // * Returns: the GtkD object or null if not found
258 // */
259 // ObjectG getObject(GObject* gtkStruct)
260 // {
261 // ObjectG objectG = null;
262 // synchronized ( this )
263 // {
264 // if ( gtkStruct in objectStore )
265 // {
266 // objectG = objectStore[gtkStruct];
267 // }
268 // }
269 // debug(objectstore)
270 // {
271 // //writefln("ObjectStore.removeObject objectStore.length = %s", objectStore.length);
272 // //writefln("ObjectStore.getObject gtkStruct = %s", gtkStruct);
273 // if ( objectG is null )
274 // {
275 // writefln("ObjectStore.getObject not found");
276 // }
277 // else
278 // {
279 // writefln("ObjectStore.getObject %s (total = %s)", objectG, objectStore.length);
280 // }
281 // }
282 // return objectG;
283 // }
285 // /**
286 // * Removes an entry from the gtk struct to GtkD object map
287 // */
288 // void removeObject(GObject* gtkStruct)
289 // {
290 // debug(objectstore)
291 // {
292 // writefln("ObjectStore.removeObject gtkStruct = %s", gtkStruct);
293 // ObjectG objectG = getObject(gtkStruct);
294 // if ( objectG is null )
295 // {
296 // writefln("ObjectStore.removeObject not found");
297 // }
298 // else
299 // {
300 // writefln("ObjectStore.removeObject %s",
301 // objectG);
302 // }
303 // }
304 // objectStore.remove(gtkStruct);
305 // //objectStore.rehash;
306 // debug(objectstore)
307 // {
308 // writefln("ObjectStore.removeObject objectStore.length = %s", objectStore.length);
309 // }
310 // }
311 // }
313 // /**
314 // * Gets a GtkD object from a Gtk Structure if the GtkD object was already created for the structure
315 // */
316 // public static ObjectG getStoredObject(GObject* gtkStruct)
317 // {
318 // return objectStore.getObject(gtkStruct);
319 // }
321 // /**
322 // * Sets a pointer on this object's has table
323 // * @param key the data identifier
324 // * @param data a pointer
325 // */
326 // private void setDestroyNotify(char[] key, gpointer data)
327 // {
328 // //writefln("setData objectG=%X data=%X type %s",gObject,data,key);
329 // //std.gc.addRoot(data);
331 // g_object_set_data_full(gObject, Str.toStringz(key), data, cast(GDestroyNotify)&destroyNotify);
332 // }
334 // private extern(C)
335 // {
336 // static void destroyNotify(gpointer data)
337 // {
338 // //printf("objectg.destroy entry\n");
339 // //printf("objectg.destroy\n");
340 // //writefln("removing gc.root to %s",data);
341 // //std.gc.removeRoot(data);
343 // objectStore.removeObject(cast(GObject*)data);
344 // //objectStore.removeObject(cast(GObject*)*data);
346 // //printf("objectg.destroy exit\n");
347 // }
348 // }
349 public void setProperty(char[] propertyName, int value)
351 setProperty(propertyName, new Value(value));
354 public void setProperty(char[] propertyName, char[] value)
356 setProperty(propertyName, new Value(value));
359 public void setProperty(char[] propertyName, long value)
361 //We use g_object_set instead of g_object_set_property, because Value doesn't like longs and ulongs for some reason.
362 g_object_set( gObject, Str.toStringz(propertyName), value, null);
365 public void setProperty(char[] propertyName, ulong value)
367 g_object_set( gObject, Str.toStringz(propertyName), value, null);
370 public void setProperty(char[] propertyName, double value)
372 g_object_set( gObject, Str.toStringz(propertyName), value, null);
378 // imports for the signal processing
379 private import gobject.Signals;
380 private import gtkc.gdktypes;
381 int[char[]] connectedSignals;
383 void delegate(ParamSpec, ObjectG)[] onNotifyListeners;
384 void addOnNotify(void delegate(ParamSpec, ObjectG) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
386 if ( !("notify" in connectedSignals) )
388 Signals.connectData(
389 getStruct(),
390 "notify",
391 cast(GCallback)&callBackNotify,
392 cast(void*)this,
393 null,
394 connectFlags);
395 connectedSignals["notify"] = 1;
397 onNotifyListeners ~= dlg;
399 extern(C) static void callBackNotify(GObject* gobjectStruct, GParamSpec* arg1, ObjectG objectG)
401 bool consumed = false;
403 foreach ( void delegate(ParamSpec, ObjectG) dlg ; objectG.onNotifyListeners )
405 dlg(new ParamSpec(arg1), objectG);
408 return consumed;
429 * Installs a new property. This is usually done in the class initializer.
430 * oclass:
431 * a GObjectClass
432 * property_id:
433 * the id for the new property
434 * pspec:
435 * the GParamSpec for the new property
437 public static void classInstallProperty(GObjectClass* oclass, uint propertyId, ParamSpec pspec)
439 // void g_object_class_install_property (GObjectClass *oclass, guint property_id, GParamSpec *pspec);
440 g_object_class_install_property(oclass, propertyId, (pspec is null) ? null : pspec.getParamSpecStruct());
444 * Looks up the GParamSpec for a property of a class.
445 * oclass:
446 * a GObjectClass
447 * property_name:
448 * the name of the property to look up
449 * Returns:
450 * the GParamSpec for the property, or NULL if the class doesn't have
451 * a property of that name
453 public static ParamSpec classFindProperty(GObjectClass* oclass, char[] propertyName)
455 // GParamSpec* g_object_class_find_property (GObjectClass *oclass, const gchar *property_name);
456 return new ParamSpec( g_object_class_find_property(oclass, Str.toStringz(propertyName)) );
460 * Returns an array of GParamSpec* for all properties of a class.
461 * oclass:
462 * a GObjectClass
463 * n_properties:
464 * return location for the length of the returned array
465 * Returns:
466 * an array of GParamSpec* which should be freed after use
468 public static GParamSpec** classListProperties(GObjectClass* oclass, uint* nProperties)
470 // GParamSpec** g_object_class_list_properties (GObjectClass *oclass, guint *n_properties);
471 return g_object_class_list_properties(oclass, nProperties);
475 * Registers property_id as referring to a property with the
476 * name name in a parent class or in an interface implemented
477 * by oclass. This allows this class to override
478 * a property implementation in a parent class or to provide
479 * the implementation of a property from an interface.
480 * Note
481 * Internally, overriding is implemented by creating a property of type
482 * GParamSpecOverride; generally operations that query the properties of
483 * the object class, such as g_object_class_find_property() or
484 * g_object_class_list_properties() will return the overridden
485 * property. However, in one case, the construct_properties argument of
486 * the constructor virtual function, the GParamSpecOverride is passed
487 * instead, so that the param_id field of the GParamSpec will be
488 * correct. For virtually all uses, this makes no difference. If you
489 * need to get the overridden property, you can call
490 * g_param_spec_get_redirect_target().
491 * oclass:
492 * a GObjectClass
493 * property_id:
494 * the new property ID
495 * name:
496 * the name of a property registered in a parent class or
497 * in an interface of this class.
498 * Since 2.4
500 public static void classOverrideProperty(GObjectClass* oclass, uint propertyId, char[] name)
502 // void g_object_class_override_property (GObjectClass *oclass, guint property_id, const gchar *name);
503 g_object_class_override_property(oclass, propertyId, Str.toStringz(name));
507 * Add a property to an interface; this is only useful for interfaces
508 * that are added to GObject-derived types. Adding a property to an
509 * interface forces all objects classes with that interface to have a
510 * compatible property. The compatible property could be a newly
511 * created GParamSpec, but normally
512 * g_object_class_override_property() will be used so that the object
513 * class only needs to provide an implementation and inherits the
514 * property description, default value, bounds, and so forth from the
515 * interface property.
516 * This function is meant to be called from the interface's default
517 * vtable initialization function (the class_init member of
518 * GTypeInfo.) It must not be called after after class_init has
519 * been called for any object types implementing this interface.
520 * g_iface:
521 * any interface vtable for the interface, or the default
522 * vtable for the interface.
523 * pspec:
524 * the GParamSpec for the new property
525 * Since 2.4
527 public static void interfaceInstallProperty(void* gIface, ParamSpec pspec)
529 // void g_object_interface_install_property (gpointer g_iface, GParamSpec *pspec);
530 g_object_interface_install_property(gIface, (pspec is null) ? null : pspec.getParamSpecStruct());
534 * Find the GParamSpec with the given name for an
535 * interface. Generally, the interface vtable passed in as g_iface
536 * will be the default vtable from g_type_default_interface_ref(), or,
537 * if you know the interface has already been loaded,
538 * g_type_default_interface_peek().
539 * g_iface:
540 * any interface vtable for the interface, or the default
541 * vtable for the interface
542 * property_name:
543 * name of a property to lookup.
544 * Returns:
545 * the GParamSpec for the property of the
546 * interface with the name property_name, or NULL
547 * if no such property exists.
548 * Since 2.4
550 public static ParamSpec interfaceFindProperty(void* gIface, char[] propertyName)
552 // GParamSpec* g_object_interface_find_property (gpointer g_iface, const gchar *property_name);
553 return new ParamSpec( g_object_interface_find_property(gIface, Str.toStringz(propertyName)) );
557 * Lists the properties of an interface.Generally, the interface
558 * vtable passed in as g_iface will be the default vtable from
559 * g_type_default_interface_ref(), or, if you know the interface has
560 * already been loaded, g_type_default_interface_peek().
561 * g_iface:
562 * any interface vtable for the interface, or the default
563 * vtable for the interface
564 * n_properties_p:
565 * location to store number of properties returned.
566 * Returns:
567 * a pointer to an array of pointers to GParamSpec structures.
568 * The paramspecs are owned by GLib, but the array should
569 * be freed with g_free() when you are done with it.
570 * Since 2.4
572 public static GParamSpec** interfaceListProperties(void* gIface, uint* nPropertiesP)
574 // GParamSpec** g_object_interface_list_properties (gpointer g_iface, guint *n_properties_p);
575 return g_object_interface_list_properties(gIface, nPropertiesP);
579 * Creates a new instance of a GObject subtype and sets its properties.
580 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
581 * which are not explicitly specified are set to their default values.
582 * object_type:
583 * the type id of the GObject subtype to instantiate
584 * first_property_name:
585 * the name of the first property
586 * ...:
587 * the value of the first property, followed optionally by more
588 * name/value pairs, followed by NULL
589 * Returns:
590 * a new instance of object_type
592 public this (GType objectType, char[] firstPropertyName, ... )
594 // gpointer g_object_new (GType object_type, const gchar *first_property_name, ...);
595 this(cast(GObject*)g_object_new(objectType, Str.toStringz(firstPropertyName)) );
599 * Creates a new instance of a GObject subtype and sets its properties.
600 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
601 * which are not explicitly specified are set to their default values.
602 * object_type:
603 * the type id of the GObject subtype to instantiate
604 * n_parameters:
605 * the length of the parameters array
606 * parameters:
607 * an array of GParameter
608 * Returns:
609 * a new instance of object_type
611 public this (GType objectType, uint nParameters, GParameter* parameters)
613 // gpointer g_object_newv (GType object_type, guint n_parameters, GParameter *parameters);
614 this(cast(GObject*)g_object_newv(objectType, nParameters, parameters) );
619 * Increases the reference count of object.
620 * object:
621 * a GObject
622 * Returns:
623 * the same object
625 public static void* doref(void* object)
627 // gpointer g_object_ref (gpointer object);
628 return g_object_ref(object);
632 * Decreases the reference count of object.
633 * When its reference count drops to 0, the object is finalized
634 * (i.e. its memory is freed).
635 * object:
636 * a GObject
638 public static void unref(void* object)
640 // void g_object_unref (gpointer object);
641 g_object_unref(object);
645 * Increase the reference count of object, and possibly remove the
646 * floating reference, if object
647 * has a floating reference.
648 * In other words, if the object is floating, then this call "assumes
649 * ownership" of the floating reference, converting it to a normal reference
650 * by clearing the floating flag while leaving the reference count unchanged.
651 * If the object is not floating, then this call adds a new normal reference
652 * increasing the reference count by one.
653 * object:
654 * a GObject
655 * Returns:
656 * object
657 * Since 2.10
659 public static void* refSink(void* object)
661 // gpointer g_object_ref_sink (gpointer object);
662 return g_object_ref_sink(object);
669 * Checks wether object has a floating
670 * reference.
671 * object:
672 * a GObject
673 * Returns:
674 * TRUE if object has a floating reference
675 * Since 2.10
677 public static int isFloating(void* object)
679 // gboolean g_object_is_floating (gpointer object);
680 return g_object_is_floating(object);
684 * This function is intended for GObject implementations to re-enforce a
685 * floating object reference.
686 * Doing this is seldomly required, all
687 * GInitiallyUnowneds are created with a floating reference which
688 * usually just needs to be sunken by calling g_object_ref_sink().
689 * object:
690 * a GObject
691 * Since 2.10
693 public void forceFloating()
695 // void g_object_force_floating (GObject *object);
696 g_object_force_floating(gObject);
701 * Adds a weak reference callback to an object. Weak references are used for
702 * notification when an object is finalized. They are called "weak references"
703 * because they allow you to safely hold a pointer to an object without calling
704 * g_object_ref() (g_object_ref() adds a strong reference, that is, forces the
705 * object to stay alive).
706 * object:
707 * GObject to reference weakly
708 * notify:
709 * callback to invoke before the object is freed
710 * data:
711 * extra data to pass to notify
713 public void weakRef(GWeakNotify notify, void* data)
715 // void g_object_weak_ref (GObject *object, GWeakNotify notify, gpointer data);
716 g_object_weak_ref(gObject, notify, data);
720 * Removes a weak reference callback to an object.
721 * object:
722 * GObject to remove a weak reference from
723 * notify:
724 * callback to search for
725 * data:
726 * data to search for
728 public void weakUnref(GWeakNotify notify, void* data)
730 // void g_object_weak_unref (GObject *object, GWeakNotify notify, gpointer data);
731 g_object_weak_unref(gObject, notify, data);
735 * Adds a weak reference from weak_pointer to object to indicate that
736 * the pointer located at weak_pointer_location is only valid during the
737 * lifetime of object. When the object is finalized, weak_pointer will
738 * be set to NULL.
739 * object:
740 * The object that should be weak referenced.
741 * weak_pointer_location:
742 * The memory address of a pointer.
744 public void addWeakPointer(void** weakPointerLocation)
746 // void g_object_add_weak_pointer (GObject *object, gpointer *weak_pointer_location);
747 g_object_add_weak_pointer(gObject, weakPointerLocation);
751 * Removes a weak reference from object that was previously added
752 * using g_object_add_weak_pointer(). The weak_pointer_location has
753 * to match the one used with g_object_add_weak_pointer().
754 * object:
755 * The object that is weak referenced.
756 * weak_pointer_location:
757 * The memory address of a pointer.
759 public void removeWeakPointer(void** weakPointerLocation)
761 // void g_object_remove_weak_pointer (GObject *object, gpointer *weak_pointer_location);
762 g_object_remove_weak_pointer(gObject, weakPointerLocation);
767 * Increases the reference count of the object by one and sets a
768 * callback to be called when all other references to the object are
769 * dropped, or when this is already the last reference to the object
770 * and another reference is established.
771 * This functionality is intended for binding object to a proxy
772 * object managed by another memory manager. This is done with two
773 * paired references: the strong reference added by
774 * g_object_add_toggle_ref() and a reverse reference to the proxy
775 * object which is either a strong reference or weak reference.
776 * The setup is that when there are no other references to object,
777 * only a weak reference is held in the reverse direction from object
778 * to the proxy object, but when there are other references held to
779 * object, a strong reference is held. The notify callback is called
780 * when the reference from object to the proxy object should be
781 * toggled from strong to weak (is_last_ref
782 * true) or weak to strong (is_last_ref false).
783 * Since a (normal) reference must be held to the object before
784 * calling g_object_toggle_ref(), the initial state of the reverse
785 * link is always strong.
786 * Multiple toggle references may be added to the same gobject,
787 * however if there are multiple toggle references to an object, none
788 * of them will ever be notified until all but one are removed. For
789 * this reason, you should only ever use a toggle reference if there
790 * is important state in the proxy object.
791 * object:
792 * a GObject
793 * notify:
794 * a function to call when this reference is the
795 * last reference to the object, or is no longer
796 * the last reference.
797 * data:
798 * data to pass to notify
799 * Since 2.8
801 public void addToggleRef(GToggleNotify notify, void* data)
803 // void g_object_add_toggle_ref (GObject *object, GToggleNotify notify, gpointer data);
804 g_object_add_toggle_ref(gObject, notify, data);
808 * Removes a reference added with g_object_add_toggle_ref(). The
809 * reference count of the object is decreased by one.
810 * object:
811 * a GObject
812 * notify:
813 * a function to call when this reference is the
814 * last reference to the object, or is no longer
815 * the last reference.
816 * data:
817 * data to pass to notify
818 * Since 2.8
820 public void removeToggleRef(GToggleNotify notify, void* data)
822 // void g_object_remove_toggle_ref (GObject *object, GToggleNotify notify, gpointer data);
823 g_object_remove_toggle_ref(gObject, notify, data);
827 * A convenience function to connect multiple signals at once.
828 * The signal specs expected by this function have the form
829 * "modifier::signal_name", where modifier can be one of the following:
830 * signal
831 * equivalent to g_signal_connect_data (...)
832 * object_signal, object-signal
833 * equivalent to g_signal_connect_object (...)
834 * swapped_signal, swapped-signal
835 * equivalent to g_signal_connect_data (..., G_CONNECT_SWAPPED)
836 * swapped_object_signal, swapped-object-signal
837 * equivalent to g_signal_connect_object (..., G_CONNECT_SWAPPED)
838 * signal_after, signal-after
839 * equivalent to g_signal_connect_data (..., G_CONNECT_AFTER)
840 * object_signal_after, object-signal-after
841 * equivalent to g_signal_connect_object (..., G_CONNECT_AFTER)
842 * swapped_signal_after, swapped-signal-after
843 * equivalent to g_signal_connect_data (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)
844 * swapped_object_signal_after, swapped-object-signal-after
845 * equivalent to g_signal_connect_object (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)
846 * menu->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
847 * "type", GTK_WINDOW_POPUP,
848 * "child", menu,
849 * NULL),
850 * "signal::event", gtk_menu_window_event, menu,
851 * "signal::size_request", gtk_menu_window_size_request, menu,
852 * "signal::destroy", gtk_widget_destroyed, menu->toplevel,
853 * NULL);
854 * object:
855 * a GObject
856 * signal_spec:
857 * the spec for the first signal
858 * ...:
859 * GCallback for the first signal, followed by data for the first signal,
860 * followed optionally by more signal spec/callback/data triples,
861 * followed by NULL
862 * Returns:
863 * object
865 public static void* connect(void* object, char[] signalSpec, ... )
867 // gpointer g_object_connect (gpointer object, const gchar *signal_spec, ...);
868 return g_object_connect(object, Str.toStringz(signalSpec));
872 * A convenience function to disconnect multiple signals at once.
873 * The signal specs expected by this function have the form "any_signal", which
874 * means to disconnect any signal with matching callback and data, or
875 * "any_signal::signal_name", which only disconnects the signal named "signal_name".
876 * object:
877 * a GObject
878 * signal_spec:
879 * the spec for the first signal
880 * ...:
881 * GCallback for the first signal, followed by data for the first signal,
882 * followed optionally by more signal spec/callback/data triples,
883 * followed by NULL
885 public static void disconnect(void* object, char[] signalSpec, ... )
887 // void g_object_disconnect (gpointer object, const gchar *signal_spec, ...);
888 g_object_disconnect(object, Str.toStringz(signalSpec));
892 * Sets properties on an object.
893 * object:
894 * a GObject
895 * first_property_name:
896 * name of the first property to set
897 * ...:
898 * value for the first property, followed optionally by more
899 * name/value pairs, followed by NULL
901 public static void set(void* object, char[] firstPropertyName, ... )
903 // void g_object_set (gpointer object, const gchar *first_property_name, ...);
904 g_object_set(object, Str.toStringz(firstPropertyName));
908 * Gets properties of an object.
909 * In general, a copy is made of the property contents and the caller is
910 * responsible for freeing the memory in the appropriate manner for the type,
911 * for instance by calling g_free() or g_object_unref().
912 * Example5.Using g_object_get()
913 * An example of using g_object_get() to get the contents
914 * of three properties - one of type G_TYPE_INT,
915 * one of type G_TYPE_STRING, and one of type G_TYPE_OBJECT:
916 * gint intval;
917 * gchar *strval;
918 * GObject *objval;
919 * g_object_get (my_object,
920 * "intproperty", intval,
921 * "strproperty", strval,
922 * "objproperty", objval,
923 * NULL);
924 * /+* Do something with intval, strval, objval +/
925 * g_free (strval);
926 * g_object_unref (objval);
927 * object:
928 * a GObject
929 * first_property_name:
930 * name of the first property to get
931 * ...:
932 * return location for the first property, followed optionally by more
933 * name/return location pairs, followed by NULL
935 public static void get(void* object, char[] firstPropertyName, ... )
937 // void g_object_get (gpointer object, const gchar *first_property_name, ...);
938 g_object_get(object, Str.toStringz(firstPropertyName));
942 * Emits a "notify" signal for the property property_name on object.
943 * object:
944 * a GObject
945 * property_name:
946 * the name of a property installed on the class of object.
948 public void notify(char[] propertyName)
950 // void g_object_notify (GObject *object, const gchar *property_name);
951 g_object_notify(gObject, Str.toStringz(propertyName));
955 * Stops emission of "notify" signals on object. The signals are
956 * queued until g_object_thaw_notify() is called on object.
957 * This is necessary for accessors that modify multiple properties to prevent
958 * premature notification while the object is still being modified.
959 * object:
960 * a GObject
962 public void freezeNotify()
964 // void g_object_freeze_notify (GObject *object);
965 g_object_freeze_notify(gObject);
969 * Reverts the effect of a previous call to g_object_freeze_notify().
970 * This causes all queued "notify" signals on object to be emitted.
971 * object:
972 * a GObject
974 public void thawNotify()
976 // void g_object_thaw_notify (GObject *object);
977 g_object_thaw_notify(gObject);
981 * Gets a named field from the objects table of associations (see g_object_set_data()).
982 * object:
983 * GObject containing the associations
984 * key:
985 * name of the key for that association
986 * Returns:
987 * the data if found, or NULL if no such data exists.
989 public void* getData(char[] key)
991 // gpointer g_object_get_data (GObject *object, const gchar *key);
992 return g_object_get_data(gObject, Str.toStringz(key));
996 * Each object carries around a table of associations from
997 * strings to pointers. This function lets you set an association.
998 * If the object already had an association with that name,
999 * the old association will be destroyed.
1000 * object:
1001 * GObject containing the associations.
1002 * key:
1003 * name of the key
1004 * data:
1005 * data to associate with that key
1007 public void setData(char[] key, void* data)
1009 // void g_object_set_data (GObject *object, const gchar *key, gpointer data);
1010 g_object_set_data(gObject, Str.toStringz(key), data);
1015 * Remove a specified datum from the object's data associations,
1016 * without invoking the association's destroy handler.
1017 * object:
1018 * GObject containing the associations
1019 * key:
1020 * name of the key
1021 * Returns:
1022 * the data if found, or NULL if no such data exists.
1024 public void* stealData(char[] key)
1026 // gpointer g_object_steal_data (GObject *object, const gchar *key);
1027 return g_object_steal_data(gObject, Str.toStringz(key));
1031 * This function gets back user data pointers stored via
1032 * g_object_set_qdata().
1033 * object:
1034 * The GObject to get a stored user data pointer from
1035 * quark:
1036 * A GQuark, naming the user data pointer
1037 * Returns:
1038 * The user data pointer set, or NULL
1040 public void* getQdata(GQuark quark)
1042 // gpointer g_object_get_qdata (GObject *object, GQuark quark);
1043 return g_object_get_qdata(gObject, quark);
1047 * This sets an opaque, named pointer on an object.
1048 * The name is specified through a GQuark (retrived e.g. via
1049 * g_quark_from_static_string()), and the pointer
1050 * can be gotten back from the object with g_object_get_qdata()
1051 * until the object is finalized.
1052 * Setting a previously set user data pointer, overrides (frees)
1053 * the old pointer set, using NULL as pointer essentially
1054 * removes the data stored.
1055 * object:
1056 * The GObject to set store a user data pointer
1057 * quark:
1058 * A GQuark, naming the user data pointer
1059 * data:
1060 * An opaque user data pointer
1062 public void setQdata(GQuark quark, void* data)
1064 // void g_object_set_qdata (GObject *object, GQuark quark, gpointer data);
1065 g_object_set_qdata(gObject, quark, data);
1069 * This function works like g_object_set_qdata(), but in addition,
1070 * a void (*destroy) (gpointer) function may be specified which is
1071 * called with data as argument when the object is finalized, or
1072 * the data is being overwritten by a call to g_object_set_qdata()
1073 * with the same quark.
1074 * object:
1075 * The GObject to set store a user data pointer
1076 * quark:
1077 * A GQuark, naming the user data pointer
1078 * data:
1079 * An opaque user data pointer
1080 * destroy:
1081 * Function to invoke with data as argument, when data needs to be freed
1083 public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
1085 // void g_object_set_qdata_full (GObject *object, GQuark quark, gpointer data, GDestroyNotify destroy);
1086 g_object_set_qdata_full(gObject, quark, data, destroy);
1090 * This function gets back user data pointers stored via
1091 * g_object_set_qdata() and removes the data from object
1092 * without invoking it's destroy() function (if any was
1093 * set).
1094 * Usually, calling this function is only required to update
1095 * user data pointers with a destroy notifier, for example:
1096 * void
1097 * object_add_to_user_list (GObject *object,
1098 * const gchar *new_string)
1100 * /+* the quark, naming the object data +/
1101 * GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
1102 * /+* retrive the old string list +/
1103 * GList *list = g_object_steal_qdata (object, quark_string_list);
1104 * /+* prepend new string +/
1105 * list = g_list_prepend (list, g_strdup (new_string));
1106 * /+* this changed 'list', so we need to set it again +/
1107 * g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
1109 * static void
1110 * free_string_list (gpointer data)
1112 * GList *node, *list = data;
1113 * for (node = list; node; node = node->next)
1114 * g_free (node->data);
1115 * g_list_free (list);
1117 * Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata()
1118 * would have left the destroy function set, and thus the partial string list would
1119 * have been freed upon g_object_set_qdata_full().
1120 * object:
1121 * The GObject to get a stored user data pointer from
1122 * quark:
1123 * A GQuark, naming the user data pointer
1124 * Returns:
1125 * The user data pointer set, or NULL
1127 public void* stealQdata(GQuark quark)
1129 // gpointer g_object_steal_qdata (GObject *object, GQuark quark);
1130 return g_object_steal_qdata(gObject, quark);
1134 * Sets a property on an object.
1135 * object:
1136 * a GObject
1137 * property_name:
1138 * the name of the property to set
1139 * value:
1140 * the value
1142 public void setProperty(char[] propertyName, Value value)
1144 // void g_object_set_property (GObject *object, const gchar *property_name, const GValue *value);
1145 g_object_set_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1149 * Gets a property of an object.
1150 * In general, a copy is made of the property contents and the caller is
1151 * responsible for freeing the memory by calling g_value_unset().
1152 * Note that g_object_get_property() is really intended for language
1153 * bindings, g_object_get() is much more convenient for C programming.
1154 * object:
1155 * a GObject
1156 * property_name:
1157 * the name of the property to get
1158 * value:
1159 * return location for the property value
1161 public void getProperty(char[] propertyName, Value value)
1163 // void g_object_get_property (GObject *object, const gchar *property_name, GValue *value);
1164 g_object_get_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1168 * Creates a new instance of a GObject subtype and sets its properties.
1169 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
1170 * which are not explicitly specified are set to their default values.
1171 * object_type:
1172 * the type id of the GObject subtype to instantiate
1173 * first_property_name:
1174 * the name of the first property
1175 * var_args:
1176 * the value of the first property, followed optionally by more
1177 * name/value pairs, followed by NULL
1178 * Returns:
1179 * a new instance of object_type
1181 public this (GType objectType, char[] firstPropertyName, void* varArgs)
1183 // GObject* g_object_new_valist (GType object_type, const gchar *first_property_name, va_list var_args);
1184 this(cast(GObject*)g_object_new_valist(objectType, Str.toStringz(firstPropertyName), varArgs) );
1188 * Sets properties on an object.
1189 * object:
1190 * a GObject
1191 * first_property_name:
1192 * name of the first property to set
1193 * var_args:
1194 * value for the first property, followed optionally by more
1195 * name/value pairs, followed by NULL
1197 public void setValist(char[] firstPropertyName, void* varArgs)
1199 // void g_object_set_valist (GObject *object, const gchar *first_property_name, va_list var_args);
1200 g_object_set_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1204 * Gets properties of an object.
1205 * In general, a copy is made of the property contents and the caller is
1206 * responsible for freeing the memory in the appropriate manner for the type,
1207 * for instance by calling g_free() or g_object_unref().
1208 * See g_object_get().
1209 * object:
1210 * a GObject
1211 * first_property_name:
1212 * name of the first property to get
1213 * var_args:
1214 * return location for the first property, followed optionally by more
1215 * name/return location pairs, followed by NULL
1217 public void getValist(char[] firstPropertyName, void* varArgs)
1219 // void g_object_get_valist (GObject *object, const gchar *first_property_name, va_list var_args);
1220 g_object_get_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1224 * This function essentially limits the life time of the closure
1225 * to the life time of the object. That is, when the object is finalized,
1226 * the closure is invalidated by calling g_closure_invalidate() on it,
1227 * in order to prevent invocations of the closure with a finalized
1228 * (nonexisting) object. Also, g_object_ref() and g_object_unref() are added
1229 * as marshal guards to the closure, to ensure that an extra reference
1230 * count is held on object during invocation of the closure.
1231 * Usually, this function will be called on closures that use this object
1232 * as closure data.
1233 * object:
1234 * GObject restricting lifetime of closure
1235 * closure:
1236 * GClosure to watch
1238 public void watchClosure(Closure closure)
1240 // void g_object_watch_closure (GObject *object, GClosure *closure);
1241 g_object_watch_closure(gObject, (closure is null) ? null : closure.getClosureStruct());
1245 * Releases all references to other objects. This can be used to break
1246 * reference cycles.
1247 * Note
1248 * This functions should only be called from object system implementations.
1249 * object:
1250 * a GObject
1252 public void runDispose()
1254 // void g_object_run_dispose (GObject *object);
1255 g_object_run_dispose(gObject);