I've no idea here...
[gtkD.git] / src / gobject / ObjectG.d
blobbc1b88d4f64ca5482fc72eaab11dbfbc1248ef2f
1 /*
2 * This file is part of duit.
4 * duit 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 * duit 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 duit; 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 * local aliases:
57 module gobject.ObjectG;
59 private import gobject.gobjecttypes;
61 private import lib.gobject;
63 private import gobject.ParamSpec;
64 private import gobject.Value;
65 private import gobject.Closure;
66 private import std.gc;
67 private import glib.Str;
69 /**
70 * Description
71 * GObject is the fundamental type providing the common attributes and methods
72 * for all object types in GTK+, Pango and other libraries based on GObject.
73 * The GObject class provides methods for object construction and destruction,
74 * property access methods, and signal support.
75 * Signals are described in detail in Signals(3).
76 * GInitiallyUnowned is derived from GObject. The only difference between
77 * the two is that the initial reference of a GInitiallyUnowned is flagged
78 * as a floating reference.
79 * This means that it is not specifically claimed to be "owned" by
80 * any code portion. The main motivation for providing floating references is
81 * C convenience. In particular, it allows code to be written as:
82 * Example1.
83 * container = create_container();
84 * container_add_child (container, create_child());
85 * If container_add_child() will g_object_ref_sink() the
86 * passed in child, no reference of the newly created child is leaked.
87 * Without floating references, container_add_child()
88 * can only g_object_ref() the new child, so to implement this code without
89 * reference leaks, it would have to be written as:
90 * Example2.
91 * Child *child;
92 * container = create_container();
93 * child = create_child();
94 * container_add_child (container, child);
95 * g_object_unref (child);
96 * The floating reference can be converted into
97 * an ordinary reference by calling g_object_ref_sink().
98 * For already sunken objects (objects that don't have a floating reference
99 * anymore), g_object_ref_sink() is equivalent to g_object_ref() and returns
100 * a new reference.
101 * Since floating references are useful almost exclusively for C convenience,
102 * language bindings that provide automated reference and memory ownership
103 * maintenance (such as smart pointers or garbage collection) therefore don't
104 * need to expose floating references in their API.
105 * Some object implementations may need to save an objects floating state
106 * across certain code portions (an example is GtkMenu), to achive this, the
107 * following sequence can be used:
108 * Example3.
109 * /+* save floating state +/
110 * gboolean was_floating = g_object_is_floating (object);
111 * g_object_ref_sink (object);
112 * /+* protected code portion +/
113 * ...;
114 * /+* restore floating state +/
115 * if (was_floating)
116 * g_object_force_floating (object);
117 * g_obejct_unref (object); /+* release previously acquired reference +/
119 public class ObjectG
122 /** the main Gtk struct */
123 protected GObject* gObject;
126 public GObject* getObjectGStruct()
128 return gObject;
132 /** the main Gtk struct as a void* */
133 protected void* getStruct()
135 return cast(void*)gObject;
140 * Sets our main struct and passes store it on the gobject.
141 * Add a gabage collector root to the gtk+ struct so it doesn't get collect
143 public this (GObject* gObject)
145 this.gObject = gObject;
146 if ( gObject !is null )
148 //writefln("ObjectG.this\n");
149 setDataFull("GObject",this);
154 * Sets a pointer on this object's has table
155 * @param key the data identifier
156 * @param data a pointer
158 public: void setDataFull(char[] key, gpointer data)
160 //writefln("setData objectG=%X data=%X type %s",gObject,data,key);
161 std.gc.addRoot(data);
162 g_object_set_data_full(gObject, Str.toStringz(key), data, cast(GDestroyNotify)&destroyNotify);
165 extern(C)
167 static void destroyNotify(gpointer* data)
169 //writefln("objectg.destroy entry");
170 //writefln("objectg.destroy");
171 //writefln("removing gc.root to %s",data);
172 std.gc.removeRoot(data);
173 //writefln("objectg.destroy exit");
177 //debug = objectstore;
179 //debug(objectstore)
181 // private import std.stdio;
184 // /**
185 // * Maps Gtk structures to Duit Objects
186 // */
187 // private static ObjectStore objectStore;
189 // /**
190 // * Creates the statis ObjectStore object
191 // */
192 // static this()
193 // {
194 // objectStore = new ObjectStore();
195 // }
197 // /**
198 // * Sets our main struct and passes store it on the gobject.
199 // * Adds a gabage collector root to the gtk+ struct so it doesn't get collect
200 // * adds the object to the objectStore
201 // */
202 // public this (GObject* gObject)
203 // {
204 // this.gObject = gObject;
205 // if ( gObject !is null )
206 // {
207 // //writefln("ObjectG.this\n");
208 // objectStore.putObject(this, gObject);
209 // setDestroyNotify("GObject",gObject);
210 // }
211 // }
215 // /**
216 // * Maintains the map from Gtk structures to Duit objects
217 // */
218 // private static class ObjectStore
219 // {
220 // static ObjectG[void*] objectStore;
222 // /**
223 // * Puts a new gtk struct to Duit objects
224 // */
225 // void putObject(ObjectG objectG, GObject* gtkStruct)
226 // {
227 // objectStore[gtkStruct] = objectG;
228 // debug(objectstore)
229 // {
230 // writefln("ObjectStore.putObject gtkStruct = %s (total=%s)", gtkStruct, objectStore.length);
231 // }
232 // }
234 // /**
235 // * Gets a Duit object from a gtk struct.
236 // * Returns: the Duit object or null if not found
237 // */
238 // ObjectG getObject(GObject* gtkStruct)
239 // {
240 // ObjectG objectG = null;
241 // synchronized ( this )
242 // {
243 // if ( gtkStruct in objectStore )
244 // {
245 // objectG = objectStore[gtkStruct];
246 // }
247 // }
248 // debug(objectstore)
249 // {
250 // //writefln("ObjectStore.removeObject objectStore.length = %s", objectStore.length);
251 // //writefln("ObjectStore.getObject gtkStruct = %s", gtkStruct);
252 // if ( objectG is null )
253 // {
254 // writefln("ObjectStore.getObject not found");
255 // }
256 // else
257 // {
258 // writefln("ObjectStore.getObject %s (total = %s)", objectG, objectStore.length);
259 // }
260 // }
261 // return objectG;
262 // }
264 // /**
265 // * Removes an entry from the gtk struct to Duit object map
266 // */
267 // void removeObject(GObject* gtkStruct)
268 // {
269 // debug(objectstore)
270 // {
271 // writefln("ObjectStore.removeObject gtkStruct = %s", gtkStruct);
272 // ObjectG objectG = getObject(gtkStruct);
273 // if ( objectG is null )
274 // {
275 // writefln("ObjectStore.removeObject not found");
276 // }
277 // else
278 // {
279 // writefln("ObjectStore.removeObject %s",
280 // objectG);
281 // }
282 // }
283 // objectStore.remove(gtkStruct);
284 // //objectStore.rehash;
285 // debug(objectstore)
286 // {
287 // writefln("ObjectStore.removeObject objectStore.length = %s", objectStore.length);
288 // }
289 // }
290 // }
292 // /**
293 // * Gets a Duit object from a Gtk Structure if the Duit object was already created for the structure
294 // */
295 // public static ObjectG getStoredObject(GObject* gtkStruct)
296 // {
297 // return objectStore.getObject(gtkStruct);
298 // }
300 // /**
301 // * Sets a pointer on this object's has table
302 // * @param key the data identifier
303 // * @param data a pointer
304 // */
305 // private void setDestroyNotify(char[] key, gpointer data)
306 // {
307 // //writefln("setData objectG=%X data=%X type %s",gObject,data,key);
308 // //std.gc.addRoot(data);
310 // g_object_set_data_full(gObject, Str.toStringz(key), data, cast(GDestroyNotify)&destroyNotify);
311 // }
313 // private extern(C)
314 // {
315 // static void destroyNotify(gpointer data)
316 // {
317 // //printf("objectg.destroy entry\n");
318 // //printf("objectg.destroy\n");
319 // //writefln("removing gc.root to %s",data);
320 // //std.gc.removeRoot(data);
322 // objectStore.removeObject(cast(GObject*)data);
323 // //objectStore.removeObject(cast(GObject*)*data);
325 // //printf("objectg.destroy exit\n");
326 // }
327 // }
328 public void setProperty(char[] propertyName, int value)
330 setProperty(propertyName, new Value(value));
333 public void setProperty(char[] propertyName, char[] value)
335 setProperty(propertyName, new Value(value));
342 // imports for the signal processing
343 private import gobject.Signals;
344 private import gdk.gdktypes;
345 int[char[]] connectedSignals;
347 void delegate(ParamSpec, ObjectG)[] onNotifyListeners;
348 void addOnNotify(void delegate(ParamSpec, ObjectG) dlg)
350 if ( !("notify" in connectedSignals) )
352 Signals.connectData(
353 getStruct(),
354 "notify",
355 cast(GCallback)&callBackNotify,
356 this,
357 null,
358 cast(ConnectFlags)0);
359 connectedSignals["notify"] = 1;
361 onNotifyListeners ~= dlg;
363 extern(C) static void callBackNotify(GObject* gobjectStruct, GParamSpec* arg1, ObjectG objectG)
365 bit consumed = false;
367 foreach ( void delegate(ParamSpec, ObjectG) dlg ; objectG.onNotifyListeners )
369 dlg(new ParamSpec(arg1), objectG);
372 return consumed;
393 * Installs a new property. This is usually done in the class initializer.
394 * oclass:
395 * a GObjectClass
396 * property_id:
397 * the id for the new property
398 * pspec:
399 * the GParamSpec for the new property
401 public static void classInstallProperty(GObjectClass* oclass, uint propertyId, ParamSpec pspec)
403 // void g_object_class_install_property (GObjectClass *oclass, guint property_id, GParamSpec *pspec);
404 g_object_class_install_property(oclass, propertyId, (pspec is null) ? null : pspec.getParamSpecStruct());
408 * Looks up the GParamSpec for a property of a class.
409 * oclass:
410 * a GObjectClass
411 * property_name:
412 * the name of the property to look up
413 * Returns:
414 * the GParamSpec for the property, or NULL if the class doesn't have
415 * a property of that name
417 public static ParamSpec classFindProperty(GObjectClass* oclass, char[] propertyName)
419 // GParamSpec* g_object_class_find_property (GObjectClass *oclass, const gchar *property_name);
420 return new ParamSpec( g_object_class_find_property(oclass, Str.toStringz(propertyName)) );
424 * Returns an array of GParamSpec* for all properties of a class.
425 * oclass:
426 * a GObjectClass
427 * n_properties:
428 * return location for the length of the returned array
429 * Returns:
430 * an array of GParamSpec* which should be freed after use
432 public static GParamSpec** classListProperties(GObjectClass* oclass, uint* nProperties)
434 // GParamSpec** g_object_class_list_properties (GObjectClass *oclass, guint *n_properties);
435 return g_object_class_list_properties(oclass, nProperties);
439 * Registers property_id as referring to a property with the
440 * name name in a parent class or in an interface implemented
441 * by oclass. This allows this class to override
442 * a property implementation in a parent class or to provide
443 * the implementation of a property from an interface.
444 * Note
445 * Internally, overriding is implemented by creating a property of type
446 * GParamSpecOverride; generally operations that query the properties of
447 * the object class, such as g_object_class_find_property() or
448 * g_object_class_list_properties() will return the overridden
449 * property. However, in one case, the construct_properties argument of
450 * the constructor virtual function, the GParamSpecOverride is passed
451 * instead, so that the param_id field of the GParamSpec will be
452 * correct. For virtually all uses, this makes no difference. If you
453 * need to get the overridden property, you can call
454 * g_param_spec_get_redirect_target().
455 * oclass:
456 * a GObjectClass
457 * property_id:
458 * the new property ID
459 * name:
460 * the name of a property registered in a parent class or
461 * in an interface of this class.
463 public static void classOverrideProperty(GObjectClass* oclass, uint propertyId, char[] name)
465 // void g_object_class_override_property (GObjectClass *oclass, guint property_id, const gchar *name);
466 g_object_class_override_property(oclass, propertyId, Str.toStringz(name));
470 * Add a property to an interface; this is only useful for interfaces
471 * that are added to GObject-derived types. Adding a property to an
472 * interface forces all objects classes with that interface to have a
473 * compatible property. The compatible property could be a newly
474 * created GParamSpec, but normally
475 * g_object_class_override_property() will be used so that the object
476 * class only needs to provide an implementation and inherits the
477 * property description, default value, bounds, and so forth from the
478 * interface property.
479 * This function is meant to be called from the interface's default
480 * vtable initialization function (the class_init member of
481 * GTypeInfo.) It must not be called after after class_init has
482 * been called for any object types implementing this interface.
483 * g_iface:
484 * any interface vtable for the interface, or the default
485 * vtable for the interface.
486 * pspec:
487 * the GParamSpec for the new property
488 * Since 2.4
490 public static void interfaceInstallProperty(void* gIface, ParamSpec pspec)
492 // void g_object_interface_install_property (gpointer g_iface, GParamSpec *pspec);
493 g_object_interface_install_property(gIface, (pspec is null) ? null : pspec.getParamSpecStruct());
497 * Find the GParamSpec with the given name for an
498 * interface. Generally, the interface vtable passed in as g_iface
499 * will be the default vtable from g_type_default_interface_ref(), or,
500 * if you know the interface has already been loaded,
501 * g_type_default_interface_peek().
502 * g_iface:
503 * any interface vtable for the interface, or the default
504 * vtable for the interface
505 * property_name:
506 * name of a property to lookup.
507 * Returns:
508 * the GParamSpec for the property of the
509 * interface with the name property_name, or NULL
510 * if no such property exists.
511 * Since 2.4
513 public static ParamSpec interfaceFindProperty(void* gIface, char[] propertyName)
515 // GParamSpec* g_object_interface_find_property (gpointer g_iface, const gchar *property_name);
516 return new ParamSpec( g_object_interface_find_property(gIface, Str.toStringz(propertyName)) );
520 * Lists the properties of an interface.Generally, the interface
521 * vtable passed in as g_iface will be the default vtable from
522 * g_type_default_interface_ref(), or, if you know the interface has
523 * already been loaded, g_type_default_interface_peek().
524 * g_iface:
525 * any interface vtable for the interface, or the default
526 * vtable for the interface
527 * n_properties_p:
528 * location to store number of properties returned.
529 * Returns:
530 * a pointer to an array of pointers to GParamSpec structures.
531 * The paramspecs are owned by GLib, but the array should
532 * be freed with g_free() when you are done with it.
533 * Since 2.4
535 public static GParamSpec** interfaceListProperties(void* gIface, uint* nPropertiesP)
537 // GParamSpec** g_object_interface_list_properties (gpointer g_iface, guint *n_properties_p);
538 return g_object_interface_list_properties(gIface, nPropertiesP);
542 * Creates a new instance of a GObject subtype and sets its properties.
543 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
544 * which are not explicitly specified are set to their default values.
545 * object_type:
546 * the type id of the GObject subtype to instantiate
547 * first_property_name:
548 * the name of the first property
549 * ...:
550 * the value of the first property, followed optionally by more
551 * name/value pairs, followed by NULL
552 * Returns:
553 * a new instance of object_type
555 public this (GType objectType, char[] firstPropertyName, ... )
557 // gpointer g_object_new (GType object_type, const gchar *first_property_name, ...);
558 this(cast(GObject*)g_object_new(objectType, Str.toStringz(firstPropertyName)) );
562 * Creates a new instance of a GObject subtype and sets its properties.
563 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
564 * which are not explicitly specified are set to their default values.
565 * object_type:
566 * the type id of the GObject subtype to instantiate
567 * n_parameters:
568 * the length of the parameters array
569 * parameters:
570 * an array of GParameter
571 * Returns:
572 * a new instance of object_type
574 public this (GType objectType, uint nParameters, GParameter* parameters)
576 // gpointer g_object_newv (GType object_type, guint n_parameters, GParameter *parameters);
577 this(cast(GObject*)g_object_newv(objectType, nParameters, parameters) );
582 * Increases the reference count of object.
583 * object:
584 * a GObject
585 * Returns:
586 * the same object
588 public static void* ref(void* object)
590 // gpointer g_object_ref (gpointer object);
591 return g_object_ref(object);
595 * Decreases the reference count of object.
596 * When its reference count drops to 0, the object is finalized
597 * (i.e. its memory is freed).
598 * object:
599 * a GObject
601 public static void unref(void* object)
603 // void g_object_unref (gpointer object);
604 g_object_unref(object);
608 * Increase the reference count of object, and possibly remove the
609 * floating reference, if object
610 * has a floating reference.
611 * In other words, if the object is floating, then this call "assumes
612 * ownership" of the floating reference, converting it to a normal reference
613 * by clearing the floating flag while leaving the reference count unchanged.
614 * If the object is not floating, then this call adds a new normal reference
615 * increasing the reference count by one.
616 * object:
617 * a GObject
618 * Returns:
619 * object
620 * Since 2.10
622 public static void* refSink(void* object)
624 // gpointer g_object_ref_sink (gpointer object);
625 return g_object_ref_sink(object);
632 * Checks wether object has a floating
633 * reference.
634 * object:
635 * a GObject
636 * Returns:
637 * TRUE if object has a floating reference
638 * Since 2.10
640 public static int isFloating(void* object)
642 // gboolean g_object_is_floating (gpointer object);
643 return g_object_is_floating(object);
647 * This function is intended for GObject implementations to re-enforce a
648 * floating object reference.
649 * Doing this is seldomly required, all
650 * GInitiallyUnowneds are created with a floating reference which
651 * usually just needs to be sunken by calling g_object_ref_sink().
652 * object:
653 * a GObject
654 * Since 2.10
656 public void forceFloating()
658 // void g_object_force_floating (GObject *object);
659 g_object_force_floating(gObject);
664 * Adds a weak reference callback to an object. Weak references are used for
665 * notification when an object is finalized. They are called "weak references"
666 * because they allow you to safely hold a pointer to an object without calling
667 * g_object_ref() (g_object_ref() adds a strong reference, that is, forces the
668 * object to stay alive).
669 * object:
670 * GObject to reference weakly
671 * notify:
672 * callback to invoke before the object is freed
673 * data:
674 * extra data to pass to notify
676 public void weakRef(GWeakNotify notify, void* data)
678 // void g_object_weak_ref (GObject *object, GWeakNotify notify, gpointer data);
679 g_object_weak_ref(gObject, notify, data);
683 * Removes a weak reference callback to an object.
684 * object:
685 * GObject to remove a weak reference from
686 * notify:
687 * callback to search for
688 * data:
689 * data to search for
691 public void weakUnref(GWeakNotify notify, void* data)
693 // void g_object_weak_unref (GObject *object, GWeakNotify notify, gpointer data);
694 g_object_weak_unref(gObject, notify, data);
698 * Adds a weak reference from weak_pointer to object to indicate that
699 * the pointer located at weak_pointer_location is only valid during the
700 * lifetime of object. When the object is finalized, weak_pointer will
701 * be set to NULL.
702 * object:
703 * The object that should be weak referenced.
704 * weak_pointer_location:
705 * The memory address of a pointer.
707 public void addWeakPointer(void** weakPointerLocation)
709 // void g_object_add_weak_pointer (GObject *object, gpointer *weak_pointer_location);
710 g_object_add_weak_pointer(gObject, weakPointerLocation);
714 * Removes a weak reference from object that was previously added
715 * using g_object_add_weak_pointer(). The weak_pointer_location has
716 * to match the one used with g_object_add_weak_pointer().
717 * object:
718 * The object that is weak referenced.
719 * weak_pointer_location:
720 * The memory address of a pointer.
722 public void removeWeakPointer(void** weakPointerLocation)
724 // void g_object_remove_weak_pointer (GObject *object, gpointer *weak_pointer_location);
725 g_object_remove_weak_pointer(gObject, weakPointerLocation);
730 * Increases the reference count of the object by one and sets a
731 * callback to be called when all other references to the object are
732 * dropped, or when this is already the last reference to the object
733 * and another reference is established.
734 * This functionality is intended for binding object to a proxy
735 * object managed by another memory manager. This is done with two
736 * paired references: the strong reference added by
737 * g_object_add_toggle_ref() and a reverse reference to the proxy
738 * object which is either a strong reference or weak reference.
739 * The setup is that when there are no other references to object,
740 * only a weak reference is held in the reverse direction from object
741 * to the proxy object, but when there are other references held to
742 * object, a strong reference is held. The notify callback is called
743 * when the reference from object to the proxy object should be
744 * toggled from strong to weak (is_last_ref
745 * true) or weak to strong (is_last_ref false).
746 * Since a (normal) reference must be held to the object before
747 * calling g_object_toggle_ref(), the initial state of the reverse
748 * link is always strong.
749 * Multiple toggle references may be added to the same gobject,
750 * however if there are multiple toggle references to an object, none
751 * of them will ever be notified until all but one are removed. For
752 * this reason, you should only ever use a toggle reference if there
753 * is important state in the proxy object.
754 * object:
755 * a GObject
756 * notify:
757 * a function to call when this reference is the
758 * last reference to the object, or is no longer
759 * the last reference.
760 * data:
761 * data to pass to notify
762 * Since 2.8
764 public void addToggleRef(GToggleNotify notify, void* data)
766 // void g_object_add_toggle_ref (GObject *object, GToggleNotify notify, gpointer data);
767 g_object_add_toggle_ref(gObject, notify, data);
771 * Removes a reference added with g_object_add_toggle_ref(). The
772 * reference count of the object is decreased by one.
773 * object:
774 * a GObject
775 * notify:
776 * a function to call when this reference is the
777 * last reference to the object, or is no longer
778 * the last reference.
779 * data:
780 * data to pass to notify
781 * Since 2.8
783 public void removeToggleRef(GToggleNotify notify, void* data)
785 // void g_object_remove_toggle_ref (GObject *object, GToggleNotify notify, gpointer data);
786 g_object_remove_toggle_ref(gObject, notify, data);
790 * A convenience function to connect multiple signals at once.
791 * The signal specs expected by this function have the form
792 * "modifier::signal_name", where modifier can be one of the following:
793 * signal
794 * equivalent to g_signal_connect_data (...)
795 * object_signal, object-signal
796 * equivalent to g_signal_connect_object (...)
797 * swapped_signal, swapped-signal
798 * equivalent to g_signal_connect_data (..., G_CONNECT_SWAPPED)
799 * swapped_object_signal, swapped-object-signal
800 * equivalent to g_signal_connect_object (..., G_CONNECT_SWAPPED)
801 * signal_after, signal-after
802 * equivalent to g_signal_connect_data (..., G_CONNECT_AFTER)
803 * object_signal_after, object-signal-after
804 * equivalent to g_signal_connect_object (..., G_CONNECT_AFTER)
805 * swapped_signal_after, swapped-signal-after
806 * equivalent to g_signal_connect_data (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)
807 * swapped_object_signal_after, swapped-object-signal-after
808 * equivalent to g_signal_connect_object (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)
809 * menu->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
810 * "type", GTK_WINDOW_POPUP,
811 * "child", menu,
812 * NULL),
813 * "signal::event", gtk_menu_window_event, menu,
814 * "signal::size_request", gtk_menu_window_size_request, menu,
815 * "signal::destroy", gtk_widget_destroyed, menu->toplevel,
816 * NULL);
817 * object:
818 * a GObject
819 * signal_spec:
820 * the spec for the first signal
821 * ...:
822 * GCallback for the first signal, followed by data for the first signal,
823 * followed optionally by more signal spec/callback/data triples,
824 * followed by NULL
825 * Returns:
826 * object
828 public static void* connect(void* object, char[] signalSpec, ... )
830 // gpointer g_object_connect (gpointer object, const gchar *signal_spec, ...);
831 return g_object_connect(object, Str.toStringz(signalSpec));
835 * A convenience function to disconnect multiple signals at once.
836 * The signal specs expected by this function have the form "any_signal", which
837 * means to disconnect any signal with matching callback and data, or
838 * "any_signal::signal_name", which only disconnects the signal named "signal_name".
839 * object:
840 * a GObject
841 * signal_spec:
842 * the spec for the first signal
843 * ...:
844 * GCallback for the first signal, followed by data for the first signal,
845 * followed optionally by more signal spec/callback/data triples,
846 * followed by NULL
848 public static void disconnect(void* object, char[] signalSpec, ... )
850 // void g_object_disconnect (gpointer object, const gchar *signal_spec, ...);
851 g_object_disconnect(object, Str.toStringz(signalSpec));
855 * Sets properties on an object.
856 * object:
857 * a GObject
858 * first_property_name:
859 * name of the first property to set
860 * ...:
861 * value for the first property, followed optionally by more
862 * name/value pairs, followed by NULL
864 public static void set(void* object, char[] firstPropertyName, ... )
866 // void g_object_set (gpointer object, const gchar *first_property_name, ...);
867 g_object_set(object, Str.toStringz(firstPropertyName));
871 * Gets properties of an object.
872 * In general, a copy is made of the property contents and the caller is
873 * responsible for freeing the memory in the appropriate manner for the type,
874 * for instance by calling g_free() or g_object_unref().
875 * Example5.Using g_object_get()
876 * An example of using g_object_get() to get the contents
877 * of three properties - one of type G_TYPE_INT,
878 * one of type G_TYPE_STRING, and one of type G_TYPE_OBJECT:
879 * gint intval;
880 * gchar *strval;
881 * GObject *objval;
882 * g_object_get (my_object,
883 * "intproperty", intval,
884 * "strproperty", strval,
885 * "objproperty", objval,
886 * NULL);
887 * /+* Do something with intval, strval, objval +/
888 * g_free (strval);
889 * g_object_unref (objval);
890 * object:
891 * a GObject
892 * first_property_name:
893 * name of the first property to get
894 * ...:
895 * return location for the first property, followed optionally by more
896 * name/return location pairs, followed by NULL
898 public static void get(void* object, char[] firstPropertyName, ... )
900 // void g_object_get (gpointer object, const gchar *first_property_name, ...);
901 g_object_get(object, Str.toStringz(firstPropertyName));
905 * Emits a "notify" signal for the property property_name on object.
906 * object:
907 * a GObject
908 * property_name:
909 * the name of a property installed on the class of object.
911 public void notify(char[] propertyName)
913 // void g_object_notify (GObject *object, const gchar *property_name);
914 g_object_notify(gObject, Str.toStringz(propertyName));
918 * Stops emission of "notify" signals on object. The signals are
919 * queued until g_object_thaw_notify() is called on object.
920 * This is necessary for accessors that modify multiple properties to prevent
921 * premature notification while the object is still being modified.
922 * object:
923 * a GObject
925 public void freezeNotify()
927 // void g_object_freeze_notify (GObject *object);
928 g_object_freeze_notify(gObject);
932 * Reverts the effect of a previous call to g_object_freeze_notify().
933 * This causes all queued "notify" signals on object to be emitted.
934 * object:
935 * a GObject
937 public void thawNotify()
939 // void g_object_thaw_notify (GObject *object);
940 g_object_thaw_notify(gObject);
944 * Gets a named field from the objects table of associations (see g_object_set_data()).
945 * object:
946 * GObject containing the associations
947 * key:
948 * name of the key for that association
949 * Returns:
950 * the data if found, or NULL if no such data exists.
952 public void* getData(char[] key)
954 // gpointer g_object_get_data (GObject *object, const gchar *key);
955 return g_object_get_data(gObject, Str.toStringz(key));
959 * Each object carries around a table of associations from
960 * strings to pointers. This function lets you set an association.
961 * If the object already had an association with that name,
962 * the old association will be destroyed.
963 * object:
964 * GObject containing the associations.
965 * key:
966 * name of the key
967 * data:
968 * data to associate with that key
970 public void setData(char[] key, void* data)
972 // void g_object_set_data (GObject *object, const gchar *key, gpointer data);
973 g_object_set_data(gObject, Str.toStringz(key), data);
978 * Remove a specified datum from the object's data associations,
979 * without invoking the association's destroy handler.
980 * object:
981 * GObject containing the associations
982 * key:
983 * name of the key
984 * Returns:
985 * the data if found, or NULL if no such data exists.
987 public void* stealData(char[] key)
989 // gpointer g_object_steal_data (GObject *object, const gchar *key);
990 return g_object_steal_data(gObject, Str.toStringz(key));
994 * This function gets back user data pointers stored via
995 * g_object_set_qdata().
996 * object:
997 * The GObject to get a stored user data pointer from
998 * quark:
999 * A GQuark, naming the user data pointer
1000 * Returns:
1001 * The user data pointer set, or NULL
1003 public void* getQdata(GQuark quark)
1005 // gpointer g_object_get_qdata (GObject *object, GQuark quark);
1006 return g_object_get_qdata(gObject, quark);
1010 * This sets an opaque, named pointer on an object.
1011 * The name is specified through a GQuark (retrived e.g. via
1012 * g_quark_from_static_string()), and the pointer
1013 * can be gotten back from the object with g_object_get_qdata()
1014 * until the object is finalized.
1015 * Setting a previously set user data pointer, overrides (frees)
1016 * the old pointer set, using NULL as pointer essentially
1017 * removes the data stored.
1018 * object:
1019 * The GObject to set store a user data pointer
1020 * quark:
1021 * A GQuark, naming the user data pointer
1022 * data:
1023 * An opaque user data pointer
1025 public void setQdata(GQuark quark, void* data)
1027 // void g_object_set_qdata (GObject *object, GQuark quark, gpointer data);
1028 g_object_set_qdata(gObject, quark, data);
1032 * This function works like g_object_set_qdata(), but in addition,
1033 * a void (*destroy) (gpointer) function may be specified which is
1034 * called with data as argument when the object is finalized, or
1035 * the data is being overwritten by a call to g_object_set_qdata()
1036 * with the same quark.
1037 * object:
1038 * The GObject to set store a user data pointer
1039 * quark:
1040 * A GQuark, naming the user data pointer
1041 * data:
1042 * An opaque user data pointer
1043 * destroy:
1044 * Function to invoke with data as argument, when data needs to be freed
1046 public void setQdataFull(GQuark quark, void* data, GDestroyNotify destroy)
1048 // void g_object_set_qdata_full (GObject *object, GQuark quark, gpointer data, GDestroyNotify destroy);
1049 g_object_set_qdata_full(gObject, quark, data, destroy);
1053 * This function gets back user data pointers stored via
1054 * g_object_set_qdata() and removes the data from object
1055 * without invoking it's destroy() function (if any was
1056 * set).
1057 * Usually, calling this function is only required to update
1058 * user data pointers with a destroy notifier, for example:
1059 * void
1060 * object_add_to_user_list (GObject *object,
1061 * const gchar *new_string)
1063 * /+* the quark, naming the object data +/
1064 * GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
1065 * /+* retrive the old string list +/
1066 * GList *list = g_object_steal_qdata (object, quark_string_list);
1067 * /+* prepend new string +/
1068 * list = g_list_prepend (list, g_strdup (new_string));
1069 * /+* this changed 'list', so we need to set it again +/
1070 * g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
1072 * static void
1073 * free_string_list (gpointer data)
1075 * GList *node, *list = data;
1076 * for (node = list; node; node = node->next)
1077 * g_free (node->data);
1078 * g_list_free (list);
1080 * Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata()
1081 * would have left the destroy function set, and thus the partial string list would
1082 * have been freed upon g_object_set_qdata_full().
1083 * object:
1084 * The GObject to get a stored user data pointer from
1085 * quark:
1086 * A GQuark, naming the user data pointer
1087 * Returns:
1088 * The user data pointer set, or NULL
1090 public void* stealQdata(GQuark quark)
1092 // gpointer g_object_steal_qdata (GObject *object, GQuark quark);
1093 return g_object_steal_qdata(gObject, quark);
1097 * Sets a property on an object.
1098 * object:
1099 * a GObject
1100 * property_name:
1101 * the name of the property to set
1102 * value:
1103 * the value
1105 public void setProperty(char[] propertyName, Value value)
1107 // void g_object_set_property (GObject *object, const gchar *property_name, const GValue *value);
1108 g_object_set_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1112 * Gets a property of an object.
1113 * In general, a copy is made of the property contents and the caller is
1114 * responsible for freeing the memory by calling g_value_unset().
1115 * Note that g_object_get_property() is really intended for language
1116 * bindings, g_object_get() is much more convenient for C programming.
1117 * object:
1118 * a GObject
1119 * property_name:
1120 * the name of the property to get
1121 * value:
1122 * return location for the property value
1124 public void getProperty(char[] propertyName, Value value)
1126 // void g_object_get_property (GObject *object, const gchar *property_name, GValue *value);
1127 g_object_get_property(gObject, Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
1131 * Creates a new instance of a GObject subtype and sets its properties.
1132 * Construction parameters (see G_PARAM_CONSTRUCT, G_PARAM_CONSTRUCT_ONLY)
1133 * which are not explicitly specified are set to their default values.
1134 * object_type:
1135 * the type id of the GObject subtype to instantiate
1136 * first_property_name:
1137 * the name of the first property
1138 * var_args:
1139 * the value of the first property, followed optionally by more
1140 * name/value pairs, followed by NULL
1141 * Returns:
1142 * a new instance of object_type
1144 public this (GType objectType, char[] firstPropertyName, void* varArgs)
1146 // GObject* g_object_new_valist (GType object_type, const gchar *first_property_name, va_list var_args);
1147 this(cast(GObject*)g_object_new_valist(objectType, Str.toStringz(firstPropertyName), varArgs) );
1151 * Sets properties on an object.
1152 * object:
1153 * a GObject
1154 * first_property_name:
1155 * name of the first property to set
1156 * var_args:
1157 * value for the first property, followed optionally by more
1158 * name/value pairs, followed by NULL
1160 public void setValist(char[] firstPropertyName, void* varArgs)
1162 // void g_object_set_valist (GObject *object, const gchar *first_property_name, va_list var_args);
1163 g_object_set_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1167 * Gets properties of an object.
1168 * In general, a copy is made of the property contents and the caller is
1169 * responsible for freeing the memory in the appropriate manner for the type,
1170 * for instance by calling g_free() or g_object_unref().
1171 * See g_object_get().
1172 * object:
1173 * a GObject
1174 * first_property_name:
1175 * name of the first property to get
1176 * var_args:
1177 * return location for the first property, followed optionally by more
1178 * name/return location pairs, followed by NULL
1180 public void getValist(char[] firstPropertyName, void* varArgs)
1182 // void g_object_get_valist (GObject *object, const gchar *first_property_name, va_list var_args);
1183 g_object_get_valist(gObject, Str.toStringz(firstPropertyName), varArgs);
1187 * This function essentially limits the life time of the closure
1188 * to the life time of the object. That is, when the object is finalized,
1189 * the closure is invalidated by calling g_closure_invalidate() on it,
1190 * in order to prevent invocations of the closure with a finalized
1191 * (nonexisting) object. Also, g_object_ref() and g_object_unref() are added
1192 * as marshal guards to the closure, to ensure that an extra reference
1193 * count is held on object during invocation of the closure.
1194 * Usually, this function will be called on closures that use this object
1195 * as closure data.
1196 * object:
1197 * GObject restricting lifetime of closure
1198 * closure:
1199 * GClosure to watch
1201 public void watchClosure(Closure closure)
1203 // void g_object_watch_closure (GObject *object, GClosure *closure);
1204 g_object_watch_closure(gObject, (closure is null) ? null : closure.getClosureStruct());
1208 * Releases all references to other objects. This can be used to break
1209 * reference cycles.
1210 * Note
1211 * This functions should only be called from object system implementations.
1212 * object:
1213 * a GObject
1215 public void runDispose()
1217 // void g_object_run_dispose (GObject *object);
1218 g_object_run_dispose(gObject);