1 <!-- ##### SECTION Title ##### -->
4 <!-- ##### SECTION Short_Description ##### -->
7 <!-- ##### SECTION Long_Description ##### -->
9 GObject is the fundamental type providing the common attributes and methods
10 for all object types in GTK+, Pango and other libraries based on GObject.
11 The GObject class provides methods for object construction and destruction,
12 property access methods, and signal support.
13 Signals are described in detail in <xref linkend="gobject-Signals"/>.
15 <para id="floating-ref">
16 #GInitiallyUnowned is derived from #GObject. The only difference between
17 the two is that the initial reference of a #GInitiallyUnowned is flagged
18 as a <firstterm>floating</firstterm> reference.
19 This means that it is not specifically claimed to be "owned" by
20 any code portion. The main motivation for providing floating references is
21 C convenience. In particular, it allows code to be written as:
22 <example><programlisting>
23 container = create_container();
24 container_add_child (container, create_child());
25 </programlisting></example>
26 If <function>container_add_child()</function> will g_object_ref_sink() the
27 passed in child, no reference of the newly created child is leaked.
28 Without floating references, <function>container_add_child()</function>
29 can only g_object_ref() the new child, so to implement this code without
30 reference leaks, it would have to be written as:
31 <example><programlisting>
33 container = create_container();
34 child = create_child();
35 container_add_child (container, child);
36 g_object_unref (child);
37 </programlisting></example>
38 The floating reference can be converted into
39 an ordinary reference by calling g_object_ref_sink().
40 For already sunken objects (objects that don't have a floating reference
41 anymore), g_object_ref_sink() is equivalent to g_object_ref() and returns
43 Since floating references are useful almost exclusively for C convenience,
44 language bindings that provide automated reference and memory ownership
45 maintenance (such as smart pointers or garbage collection) therefore don't
46 need to expose floating references in their API.
49 Some object implementations may need to save an objects floating state
50 across certain code portions (an example is #GtkMenu), to achive this, the
51 following sequence can be used:
54 <example><programlisting>
55 /* save floating state */
56 gboolean was_floating = g_object_is_floating (object);
57 g_object_ref_sink (object);
58 /* protected code portion */
60 /* restore floating state */
62 g_object_force_floating (object);
63 g_obejct_unref (object); /* release previously acquired reference */
64 </programlisting></example>
66 <!-- ##### SECTION See_Also ##### -->
68 #GParamSpecObject, g_param_spec_object()
71 <!-- ##### SECTION Stability_Level ##### -->
74 <!-- ##### STRUCT GObject ##### -->
76 All the fields in the <structname>GObject</structname> structure are private
77 to the #GObject implementation and should never be accessed directly.
81 <!-- ##### SIGNAL GObject::notify ##### -->
83 The notify signal is emitted on an object when one of its properties
84 has been changed. Note that getting this signal doesn't guarantee that the
85 value of the property has actually changed, it may also be emitted when
86 the setter for the property is called to reinstate the previous value.
89 @pspec: the #GParamSpec of the property which changed
91 @gobject: the object which received the signal.
93 <!-- ##### STRUCT GObjectClass ##### -->
95 The class structure for the <structname>GObject</structname> type.
98 <title>Implementing singletons using a constructor</title>
100 static MySingleton *the_singleton = NULL;
103 my_singleton_constructor (GType type,
104 guint n_construct_params,
105 GObjectConstructParam *construct_params)
111 object = G_OBJECT_CLASS (parent_class)->constructor (type,
114 the_singleton = MY_SINGLETON (object);
117 object = g_object_ref (G_OBJECT (the_singleton));
121 </programlisting></example>
123 @g_type_class: the parent class
124 @constructor: the @constructor function is called by g_object_new () to
125 complete the object initialization after all the construction properties are
126 set. The first thing a @constructor implementation must do is chain up to the
127 @constructor of the parent class. Overriding @constructor should be rarely
128 needed, e.g. to handle construct properties, or to implement singletons.
129 @set_property: the generic setter for all properties of this type. Should be
130 overridden for every type with properties. Implementations of @set_property
131 don't need to emit property change notification explicitly, this is handled
133 @get_property: the generic getter for all properties of this type. Should be
134 overridden for every type with properties.
135 @dispose: the @dispose function is supposed to drop all references to other
136 objects, but keep the instance otherwise intact, so that client method
137 invocations still work. It may be run multiple times (due to reference
138 loops). Before returning, @dispose should chain up to the @dispose method
140 @finalize: instance finalization function, should finish the finalization of
141 the instance begun in @dispose and chain up to the @finalize method of the
143 @dispatch_properties_changed: emits property change notification for a bunch
144 of properties. Overriding @dispatch_properties_changed should be rarely
146 @notify: the class closure for the notify signal
148 <!-- ##### STRUCT GObjectConstructParam ##### -->
150 The <structname>GObjectConstructParam</structname> struct is an auxiliary
151 structure used to hand #GParamSpec/#GValue pairs to the @constructor of
155 @pspec: the #GParamSpec of the construct parameter
156 @value: the value to set the parameter to
158 <!-- ##### USER_FUNCTION GObjectGetPropertyFunc ##### -->
160 The type of the @get_property function of #GObjectClass.
164 @property_id: the numeric id under which the property was registered with
165 g_object_class_install_property().
166 @value: a #GValue to return the property value in
167 @pspec: the #GParamSpec describing the property
170 <!-- ##### USER_FUNCTION GObjectSetPropertyFunc ##### -->
172 The type of the @set_property function of #GObjectClass.
176 @property_id: the numeric id under which the property was registered with
177 g_object_class_install_property().
178 @value: the new value for the property
179 @pspec: the #GParamSpec describing the property
182 <!-- ##### USER_FUNCTION GObjectFinalizeFunc ##### -->
184 The type of the @finalize function of #GObjectClass.
187 @object: the #GObject being finalized
190 <!-- ##### MACRO G_TYPE_IS_OBJECT ##### -->
192 Returns a boolean value of %FALSE or %TRUE indicating whether
193 the passed in type id is a %G_TYPE_OBJECT or derived from it.
196 @type: Type id to check for is a %G_TYPE_OBJECT relationship.
197 @Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT.
200 <!-- ##### MACRO G_OBJECT ##### -->
202 Casts a #GObject or derived pointer into a (GObject*) pointer.
203 Depending on the current debugging level, this function may invoke
204 certain runtime checks to identify invalid casts.
207 @object: Object which is subject to casting.
210 <!-- ##### MACRO G_IS_OBJECT ##### -->
212 Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.
215 @object: Instance to check for being a %G_TYPE_OBJECT.
218 <!-- ##### MACRO G_OBJECT_CLASS ##### -->
220 Casts a derived #GObjectClass structure into a #GObjectClass structure.
223 @class: a valid #GObjectClass
226 <!-- ##### MACRO G_IS_OBJECT_CLASS ##### -->
228 Checks whether @class "is a" valid #GObjectClass structure of type
229 %G_TYPE_OBJECT or derived.
232 @class: a #GObjectClass
235 <!-- ##### MACRO G_OBJECT_GET_CLASS ##### -->
237 Returns the class structure associated to a #GObject instance.
240 @object: a #GObject instance.
243 <!-- ##### MACRO G_OBJECT_TYPE ##### -->
245 Return the type id of an object.
248 @object: Object to return the type id for.
249 @Returns: Type id of @object.
252 <!-- ##### MACRO G_OBJECT_TYPE_NAME ##### -->
254 Returns the name of an object's type.
257 @object: Object to return the type name for.
258 @Returns: Type name of @object. The string is owned by the type system and
262 <!-- ##### MACRO G_OBJECT_CLASS_TYPE ##### -->
264 Return the type id of a class structure.
267 @class: a valid #GObjectClass
268 @Returns: Type id of @class.
271 <!-- ##### MACRO G_OBJECT_CLASS_NAME ##### -->
273 Return the name of a class structure's type.
276 @class: a valid #GObjectClass
277 @Returns: Type name of @class. The string is owned by the type system and
281 <!-- ##### FUNCTION g_object_class_install_property ##### -->
283 Installs a new property. This is usually done in the class initializer.
286 @oclass: a #GObjectClass
287 @property_id: the id for the new property
288 @pspec: the #GParamSpec for the new property
291 <!-- ##### FUNCTION g_object_class_find_property ##### -->
293 Looks up the #GParamSpec for a property of a class.
296 @oclass: a #GObjectClass
297 @property_name: the name of the property to look up
298 @Returns: the #GParamSpec for the property, or %NULL if the class doesn't have
299 a property of that name
302 <!-- ##### FUNCTION g_object_class_list_properties ##### -->
304 Returns an array of #GParamSpec* for all properties of a class.
307 @oclass: a #GObjectClass
308 @n_properties: return location for the length of the returned array
309 @Returns: an array of #GParamSpec* which should be freed after use
312 <!-- ##### FUNCTION g_object_class_override_property ##### -->
314 Registers @property_id as referring to a property with the
315 name @name in a parent class or in an interface implemented
316 by @oclass. This allows this class to <firstterm>override</firstterm>
317 a property implementation in a parent class or to provide
318 the implementation of a property from an interface.
322 Internally, overriding is implemented by creating a property of type
323 #GParamSpecOverride; generally operations that query the properties of
324 the object class, such as g_object_class_find_property() or
325 g_object_class_list_properties() will return the overridden
326 property. However, in one case, the @construct_properties argument of
327 the @constructor virtual function, the #GParamSpecOverride is passed
328 instead, so that the @param_id field of the #GParamSpec will be
329 correct. For virtually all uses, this makes no difference. If you
330 need to get the overridden property, you can call
331 g_param_spec_get_redirect_target().
335 @oclass: a #GObjectClass
336 @property_id: the new property ID
337 @name: the name of a property registered in a parent class or
338 in an interface of this class.
341 <!-- ##### FUNCTION g_object_interface_install_property ##### -->
343 Add a property to an interface; this is only useful for interfaces
344 that are added to GObject-derived types. Adding a property to an
345 interface forces all objects classes with that interface to have a
346 compatible property. The compatible property could be a newly
347 created #GParamSpec, but normally
348 g_object_class_override_property() will be used so that the object
349 class only needs to provide an implementation and inherits the
350 property description, default value, bounds, and so forth from the
354 This function is meant to be called from the interface's default
355 vtable initialization function (the @class_init member of
356 #GTypeInfo.) It must not be called after after @class_init has
357 been called for any object types implementing this interface.
360 @g_iface: any interface vtable for the interface, or the default
361 vtable for the interface.
362 @pspec: the #GParamSpec for the new property
366 <!-- ##### FUNCTION g_object_interface_find_property ##### -->
368 Find the #GParamSpec with the given name for an
369 interface. Generally, the interface vtable passed in as @g_iface
370 will be the default vtable from g_type_default_interface_ref(), or,
371 if you know the interface has already been loaded,
372 g_type_default_interface_peek().
375 @g_iface: any interface vtable for the interface, or the default
376 vtable for the interface
377 @property_name: name of a property to lookup.
378 @Returns: the #GParamSpec for the property of the
379 interface with the name @property_name, or %NULL
380 if no such property exists.
384 <!-- ##### FUNCTION g_object_interface_list_properties ##### -->
386 Lists the properties of an interface.Generally, the interface
387 vtable passed in as @g_iface will be the default vtable from
388 g_type_default_interface_ref(), or, if you know the interface has
389 already been loaded, g_type_default_interface_peek().
392 @g_iface: any interface vtable for the interface, or the default
393 vtable for the interface
394 @n_properties_p: location to store number of properties returned.
395 @Returns: a pointer to an array of pointers to #GParamSpec structures.
396 The paramspecs are owned by GLib, but the array should
397 be freed with g_free() when you are done with it.
401 <!-- ##### FUNCTION g_object_new ##### -->
403 Creates a new instance of a #GObject subtype and sets its properties.
406 Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY)
407 which are not explicitly specified are set to their default values.
410 @object_type: the type id of the #GObject subtype to instantiate
411 @first_property_name: the name of the first property
412 @Varargs: the value of the first property, followed optionally by more
413 name/value pairs, followed by %NULL
414 @Returns: a new instance of @object_type
417 <!-- ##### FUNCTION g_object_newv ##### -->
419 Creates a new instance of a #GObject subtype and sets its properties.
422 Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY)
423 which are not explicitly specified are set to their default values.
426 @object_type: the type id of the #GObject subtype to instantiate
427 @n_parameters: the length of the @parameters array
428 @parameters: an array of #GParameter
429 @Returns: a new instance of @object_type
432 <!-- ##### STRUCT GParameter ##### -->
434 The <structname>GParameter</structname> struct is an auxiliary structure used
435 to hand parameter name/value pairs to g_object_newv().
438 @name: the parameter name
439 @value: the parameter value
441 <!-- ##### FUNCTION g_object_ref ##### -->
443 Increases the reference count of @object.
447 @Returns: the same @object
450 <!-- ##### FUNCTION g_object_unref ##### -->
452 Decreases the reference count of @object.
453 When its reference count drops to 0, the object is finalized
454 (i.e. its memory is freed).
460 <!-- ##### FUNCTION g_object_ref_sink ##### -->
462 Increase the reference count of @object, and possibly remove the
463 <link linkend="floating-ref">floating</link> reference, if @object
464 has a floating reference.
467 In other words, if the object is floating, then this call "assumes
468 ownership" of the floating reference, converting it to a normal reference
469 by clearing the floating flag while leaving the reference count unchanged.
470 If the object is not floating, then this call adds a new normal reference
471 increasing the reference count by one.
479 <!-- ##### TYPEDEF GInitiallyUnowned ##### -->
481 All the fields in the <structname>GInitiallyUnowned</structname> structure
482 are private to the #GInitiallyUnowned implementation and should never be
487 <!-- ##### TYPEDEF GInitiallyUnownedClass ##### -->
489 The class structure for the <structname>GInitiallyUnowned</structname> type.
493 <!-- ##### MACRO G_TYPE_INITIALLY_UNOWNED ##### -->
495 The type for #GInitiallyUnowned.
500 <!-- ##### FUNCTION g_object_is_floating ##### -->
502 Checks wether @object has a <link linkend="floating-ref">floating</link>
507 @Returns: %TRUE if @object has a floating reference
511 <!-- ##### FUNCTION g_object_force_floating ##### -->
513 This function is intended for #GObject implementations to re-enforce a
514 <link linkend="floating-ref">floating</link> object reference.
515 Doing this is seldomly required, all
516 #GInitiallyUnowned<!-- -->s are created with a floating reference which
517 usually just needs to be sunken by calling g_object_ref_sink().
524 <!-- ##### USER_FUNCTION GWeakNotify ##### -->
526 A #GWeakNotify function can be added to an object as a callback that gets
527 triggered when the object is finalized. Since the object is already being
528 finalized when the #GWeakNotify is called, there's not much you could do
529 with the object, apart from e.g. using its adress as hash-index or the like.
532 @data: data that was provided when the weak reference was established
533 @where_the_object_was: the object being finalized
536 <!-- ##### FUNCTION g_object_weak_ref ##### -->
538 Adds a weak reference callback to an object. Weak references are used for
539 notification when an object is finalized. They are called "weak references"
540 because they allow you to safely hold a pointer to an object without calling
541 g_object_ref() (g_object_ref() adds a strong reference, that is, forces the
542 object to stay alive).
545 @object: #GObject to reference weakly
546 @notify: callback to invoke before the object is freed
547 @data: extra data to pass to notify
550 <!-- ##### FUNCTION g_object_weak_unref ##### -->
552 Removes a weak reference callback to an object.
555 @object: #GObject to remove a weak reference from
556 @notify: callback to search for
557 @data: data to search for
560 <!-- ##### FUNCTION g_object_add_weak_pointer ##### -->
562 Adds a weak reference from weak_pointer to @object to indicate that
563 the pointer located at @weak_pointer_location is only valid during the
564 lifetime of @object. When the @object is finalized, @weak_pointer will
568 @object: The object that should be weak referenced.
569 @weak_pointer_location: The memory address of a pointer.
572 <!-- ##### FUNCTION g_object_remove_weak_pointer ##### -->
574 Removes a weak reference from @object that was previously added
575 using g_object_add_weak_pointer(). The @weak_pointer_location has
576 to match the one used with g_object_add_weak_pointer().
579 @object: The object that is weak referenced.
580 @weak_pointer_location: The memory address of a pointer.
583 <!-- ##### USER_FUNCTION GToggleNotify ##### -->
585 A callback function used for notification when the state
586 of a toggle reference changes. See g_object_add_toggle_ref().
589 @data: Callback data passed to g_object_add_toggle_ref()
590 @object: The object on which g_object_add_toggle_ref() was called.
591 @is_last_ref: %TRUE if the toggle reference is now the
592 last reference to the object. %FALSE if the toggle
593 reference was the last reference and there are now other
597 <!-- ##### FUNCTION g_object_add_toggle_ref ##### -->
599 Increases the reference count of the object by one and sets a
600 callback to be called when all other references to the object are
601 dropped, or when this is already the last reference to the object
602 and another reference is established.
605 This functionality is intended for binding @object to a proxy
606 object managed by another memory manager. This is done with two
607 paired references: the strong reference added by
608 g_object_add_toggle_ref() and a reverse reference to the proxy
609 object which is either a strong reference or weak reference.
612 The setup is that when there are no other references to @object,
613 only a weak reference is held in the reverse direction from @object
614 to the proxy object, but when there are other references held to
615 @object, a strong reference is held. The @notify callback is called
616 when the reference from @object to the proxy object should be
617 <firstterm>toggled</firstterm> from strong to weak (@is_last_ref
618 true) or weak to strong (@is_last_ref false).
621 Since a (normal) reference must be held to the object before
622 calling g_object_toggle_ref(), the initial state of the reverse
623 link is always strong.
626 Multiple toggle references may be added to the same gobject,
627 however if there are multiple toggle references to an object, none
628 of them will ever be notified until all but one are removed. For
629 this reason, you should only ever use a toggle reference if there
630 is important state in the proxy object.
634 @notify: a function to call when this reference is the
635 last reference to the object, or is no longer
637 @data: data to pass to @notify
641 <!-- ##### FUNCTION g_object_remove_toggle_ref ##### -->
643 Removes a reference added with g_object_add_toggle_ref(). The
644 reference count of the object is decreased by one.
648 @notify: a function to call when this reference is the
649 last reference to the object, or is no longer
651 @data: data to pass to @notify
655 <!-- ##### FUNCTION g_object_connect ##### -->
657 A convenience function to connect multiple signals at once.
660 The signal specs expected by this function have the form
661 "modifier::signal_name", where modifier can be one of the following:
666 equivalent to <literal>g_signal_connect_data (...)</literal>
670 <term>object_signal</term>
671 <term>object-signal</term>
673 equivalent to <literal>g_signal_connect_object (...)</literal>
677 <term>swapped_signal</term>
678 <term>swapped-signal</term>
680 equivalent to <literal>g_signal_connect_data (..., G_CONNECT_SWAPPED)</literal>
684 <term>swapped_object_signal</term>
685 <term>swapped-object-signal</term>
687 equivalent to <literal>g_signal_connect_object (..., G_CONNECT_SWAPPED)</literal>
691 <term>signal_after</term>
692 <term>signal-after</term>
694 equivalent to <literal>g_signal_connect_data (..., G_CONNECT_AFTER)</literal>
698 <term>object_signal_after</term>
699 <term>object-signal-after</term>
701 equivalent to <literal>g_signal_connect_object (..., G_CONNECT_AFTER)</literal>
705 <term>swapped_signal_after</term>
706 <term>swapped-signal-after</term>
708 equivalent to <literal>g_signal_connect_data (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)</literal>
712 <term>swapped_object_signal_after</term>
713 <term>swapped-object-signal-after</term>
715 equivalent to <literal>g_signal_connect_object (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)</literal>
722 menu->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
723 "type", GTK_WINDOW_POPUP,
726 "signal::event", gtk_menu_window_event, menu,
727 "signal::size_request", gtk_menu_window_size_request, menu,
728 "signal::destroy", gtk_widget_destroyed, &menu->toplevel,
734 @signal_spec: the spec for the first signal
735 @Varargs: #GCallback for the first signal, followed by data for the first signal,
736 followed optionally by more signal spec/callback/data triples,
741 <!-- ##### FUNCTION g_object_disconnect ##### -->
743 A convenience function to disconnect multiple signals at once.
746 The signal specs expected by this function have the form "any_signal", which
747 means to disconnect any signal with matching callback and data, or
748 "any_signal::signal_name", which only disconnects the signal named "signal_name".
752 @signal_spec: the spec for the first signal
753 @Varargs: #GCallback for the first signal, followed by data for the first signal,
754 followed optionally by more signal spec/callback/data triples,
758 <!-- ##### FUNCTION g_object_set ##### -->
760 Sets properties on an object.
764 @first_property_name: name of the first property to set
765 @Varargs: value for the first property, followed optionally by more
766 name/value pairs, followed by %NULL
769 <!-- ##### FUNCTION g_object_get ##### -->
771 Gets properties of an object.
774 In general, a copy is made of the property contents and the caller is
775 responsible for freeing the memory in the appropriate manner for the type,
776 for instance by calling g_free() or g_object_unref().
779 <title>Using g_object_get(<!-- -->)</title>
781 An example of using g_object_get() to get the contents
782 of three properties - one of type #G_TYPE_INT,
783 one of type #G_TYPE_STRING, and one of type #G_TYPE_OBJECT:
790 g_object_get (my_object,
791 "intproperty", &intval,
792 "strproperty", &strval,
793 "objproperty", &objval,
796 /* Do something with intval, strval, objval */
799 g_object_unref (objval);
804 @first_property_name: name of the first property to get
805 @Varargs: return location for the first property, followed optionally by more
806 name/return location pairs, followed by %NULL
809 <!-- ##### FUNCTION g_object_notify ##### -->
811 Emits a "notify" signal for the property @property_name on @object.
815 @property_name: the name of a property installed on the class of @object.
818 <!-- ##### FUNCTION g_object_freeze_notify ##### -->
820 Stops emission of "notify" signals on @object. The signals are
821 queued until g_object_thaw_notify() is called on @object.
824 This is necessary for accessors that modify multiple properties to prevent
825 premature notification while the object is still being modified.
831 <!-- ##### FUNCTION g_object_thaw_notify ##### -->
833 Reverts the effect of a previous call to g_object_freeze_notify().
834 This causes all queued "notify" signals on @object to be emitted.
840 <!-- ##### FUNCTION g_object_get_data ##### -->
842 Gets a named field from the objects table of associations (see g_object_set_data()).
845 @object: #GObject containing the associations
846 @key: name of the key for that association
847 @Returns: the data if found, or %NULL if no such data exists.
850 <!-- ##### FUNCTION g_object_set_data ##### -->
852 Each object carries around a table of associations from
853 strings to pointers. This function lets you set an association.
856 If the object already had an association with that name,
857 the old association will be destroyed.
860 @object: #GObject containing the associations.
861 @key: name of the key
862 @data: data to associate with that key
865 <!-- ##### FUNCTION g_object_set_data_full ##### -->
867 Like g_object_set_data() except it adds notification
868 for when the association is destroyed, either by setting it
869 to a different value or when the object is destroyed.
872 @object: #GObject containing the associations
873 @key: name of the key
874 @data: data to associate with that key
875 @destroy: function to call when the association is destroyed
878 <!-- ##### FUNCTION g_object_steal_data ##### -->
880 Remove a specified datum from the object's data associations,
881 without invoking the association's destroy handler.
884 @object: #GObject containing the associations
885 @key: name of the key
886 @Returns: the data if found, or %NULL if no such data exists.
889 <!-- ##### FUNCTION g_object_get_qdata ##### -->
891 This function gets back user data pointers stored via
892 g_object_set_qdata().
895 @object: The GObject to get a stored user data pointer from
896 @quark: A #GQuark, naming the user data pointer
897 @Returns: The user data pointer set, or %NULL
900 <!-- ##### FUNCTION g_object_set_qdata ##### -->
902 This sets an opaque, named pointer on an object.
903 The name is specified through a #GQuark (retrived e.g. via
904 g_quark_from_static_string()), and the pointer
905 can be gotten back from the @object with g_object_get_qdata()
906 until the @object is finalized.
907 Setting a previously set user data pointer, overrides (frees)
908 the old pointer set, using #NULL as pointer essentially
909 removes the data stored.
912 @object: The GObject to set store a user data pointer
913 @quark: A #GQuark, naming the user data pointer
914 @data: An opaque user data pointer
917 <!-- ##### FUNCTION g_object_set_qdata_full ##### -->
919 This function works like g_object_set_qdata(), but in addition,
920 a void (*destroy) (gpointer) function may be specified which is
921 called with @data as argument when the @object is finalized, or
922 the data is being overwritten by a call to g_object_set_qdata()
923 with the same @quark.
926 @object: The GObject to set store a user data pointer
927 @quark: A #GQuark, naming the user data pointer
928 @data: An opaque user data pointer
929 @destroy: Function to invoke with @data as argument, when @data needs to be freed
932 <!-- ##### FUNCTION g_object_steal_qdata ##### -->
934 This function gets back user data pointers stored via
935 g_object_set_qdata() and removes the @data from object
936 without invoking it's destroy() function (if any was
938 Usually, calling this function is only required to update
939 user data pointers with a destroy notifier, for example:
942 object_add_to_user_list (GObject *object,
943 const gchar *new_string)
945 /* the quark, naming the object data */
946 GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
947 /* retrive the old string list */
948 GList *list = g_object_steal_qdata (object, quark_string_list);
950 /* prepend new string */
951 list = g_list_prepend (list, g_strdup (new_string));
952 /* this changed 'list', so we need to set it again */
953 g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
956 free_string_list (gpointer data)
958 GList *node, *list = data;
960 for (node = list; node; node = node->next)
965 Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata()
966 would have left the destroy function set, and thus the partial string list would
967 have been freed upon g_object_set_qdata_full().
970 @object: The GObject to get a stored user data pointer from
971 @quark: A #GQuark, naming the user data pointer
972 @Returns: The user data pointer set, or %NULL
975 <!-- ##### FUNCTION g_object_set_property ##### -->
977 Sets a property on an object.
981 @property_name: the name of the property to set
985 <!-- ##### FUNCTION g_object_get_property ##### -->
987 Gets a property of an object.
990 In general, a copy is made of the property contents and the caller is
991 responsible for freeing the memory by calling g_value_unset().
994 Note that g_object_get_property() is really intended for language
995 bindings, g_object_get() is much more convenient for C programming.
999 @property_name: the name of the property to get
1000 @value: return location for the property value
1003 <!-- ##### FUNCTION g_object_new_valist ##### -->
1005 Creates a new instance of a #GObject subtype and sets its properties.
1008 Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY)
1009 which are not explicitly specified are set to their default values.
1012 @object_type: the type id of the #GObject subtype to instantiate
1013 @first_property_name: the name of the first property
1014 @var_args: the value of the first property, followed optionally by more
1015 name/value pairs, followed by %NULL
1016 @Returns: a new instance of @object_type
1019 <!-- ##### FUNCTION g_object_set_valist ##### -->
1021 Sets properties on an object.
1025 @first_property_name: name of the first property to set
1026 @var_args: value for the first property, followed optionally by more
1027 name/value pairs, followed by %NULL
1030 <!-- ##### FUNCTION g_object_get_valist ##### -->
1032 Gets properties of an object.
1035 In general, a copy is made of the property contents and the caller is
1036 responsible for freeing the memory in the appropriate manner for the type,
1037 for instance by calling g_free() or g_object_unref().
1044 @first_property_name: name of the first property to get
1045 @var_args: return location for the first property, followed optionally by more
1046 name/return location pairs, followed by %NULL
1049 <!-- ##### FUNCTION g_object_watch_closure ##### -->
1051 This function essentially limits the life time of the @closure
1052 to the life time of the object. That is, when the object is finalized,
1053 the @closure is invalidated by calling g_closure_invalidate() on it,
1054 in order to prevent invocations of the closure with a finalized
1055 (nonexisting) object. Also, g_object_ref() and g_object_unref() are added
1056 as marshal guards to the @closure, to ensure that an extra reference
1057 count is held on @object during invocation of the @closure.
1058 Usually, this function will be called on closures that use this @object
1062 @object: GObject restricting lifetime of @closure
1063 @closure: GClosure to watch
1066 <!-- ##### FUNCTION g_object_run_dispose ##### -->
1068 Releases all references to other objects. This can be used to break
1072 This functions should only be called from object system implementations.
1078 <!-- ##### MACRO G_OBJECT_WARN_INVALID_PROPERTY_ID ##### -->
1080 This macros should be used to emit a standard warning about unexpected
1081 properties in set_property() and get_property() implementations.
1084 @object: the #GObject on which set_property() or get_property() was called
1085 @property_id: the numeric id of the property
1086 @pspec: the #GParamSpec of the property