0f3f4cc324b3836ecbee26ae9f032e579a511340
[platform/upstream/glib.git] / docs / reference / gobject / tmpl / objects.sgml
1 <!-- ##### SECTION Title ##### -->
2 GObject
3
4 <!-- ##### SECTION Short_Description ##### -->
5 The base object type
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9
10 </para>
11
12 <!-- ##### SECTION See_Also ##### -->
13 <para>
14
15 </para>
16
17 <!-- ##### STRUCT GObject ##### -->
18 <para>
19 All the fields in the <structname>GObject</structname> structure are private 
20 to the #GObject implementation and should never be accessed directly.
21 </para>
22
23
24 <!-- ##### SIGNAL GObject::notify ##### -->
25 <para>
26 The notify signal is emitted on an object when one of its properties 
27 has been changed. Note that getting this signal doesn't guarantee that the
28 value of the property has actually changed, it may also be emitted when
29 the setter for the property is called to reinstate the previous value.
30 </para>
31
32 @gobject: the object which received the signal.
33 @pspec: the #GParamSpec of the property which changed
34
35 <!-- ##### STRUCT GObjectClass ##### -->
36 <para>
37 The class structure for the <structname>GObject</structname> type.
38 </para>
39
40 @g_type_class: the parent class
41 @constructor:  the @constructor function is called by g_object_new () to 
42   complete the object initialization after all the construction properties are
43   set. The first thing a @constructor implementation must do is chain up to the
44   @constructor of the parent class. Overriding @constructor should be rarely 
45   needed.
46 @set_property: the generic setter for all properties of this type. Should be
47   overridden for every type with properties. Implementations of @set_property
48   don't need to emit property change notification explicitly, this is handled
49   by the type system.
50 @get_property: the generic getter for all properties of this type. Should be
51   overridden for every type with properties.
52 @dispose: the @dispose function is supposed to drop all references to other 
53   objects, but keep the instance otherwise intact, so that client method 
54   invocations still work. It may be run multiple times (due to reference 
55   loops). Before returning, @dispose should chain up to the @dispose method 
56   of the parent class.
57 @finalize: instance finalization function, should finish the finalization of 
58   the instance begun in @dispose and chain up to the @finalize method of the 
59   parent class.
60 @dispatch_properties_changed: emits property change notification for a bunch
61   of properties. Overriding @dispatch_properties_changed should be rarely 
62   needed.
63 @notify: the class closure for the notify signal
64
65 <!-- ##### STRUCT GObjectConstructParam ##### -->
66 <para>
67 The <structname>GObjectConstructParam</structname> struct is an auxiliary 
68 structure used to hand #GParamSpec/#GValue pairs to the @constructor of
69 a #GObjectClass.
70 </para>
71
72 @pspec: the #GParamSpec of the construct parameter
73 @value: the value to set the parameter to
74
75 <!-- ##### USER_FUNCTION GObjectGetPropertyFunc ##### -->
76 <para>
77 The type of the @get_property function of #GObjectClass. 
78 </para>
79
80 @object: a #GObject
81 @property_id: the numeric id under which the property was registered with
82    g_object_class_install_property().
83 @value: a #GValue to return the property value in
84 @pspec: the #GParamSpec describing the property
85
86
87 <!-- ##### USER_FUNCTION GObjectSetPropertyFunc ##### -->
88 <para>
89 The type of the @set_property function of #GObjectClass. 
90 </para>
91
92 @object: a #GObject
93 @property_id: the numeric id under which the property was registered with
94    g_object_class_install_property().
95 @value: the new value for the property
96 @pspec: the #GParamSpec describing the property
97
98
99 <!-- ##### USER_FUNCTION GObjectFinalizeFunc ##### -->
100 <para>
101 The type of the @finalize function of #GObjectClass.
102 </para>
103
104 @object: the #GObject being finalized
105
106
107 <!-- ##### MACRO G_TYPE_IS_OBJECT ##### -->
108 <para>
109 Returns a boolean value of %FALSE or %TRUE indicating whether
110 the passed in type id is a %G_TYPE_OBJECT or derived from it.
111 </para>
112
113 @type: Type id to check for is a %G_TYPE_OBJECT relationship.
114 @Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT.
115
116
117 <!-- ##### MACRO G_OBJECT ##### -->
118 <para>
119 Casts a #GObject or derived pointer into a (GObject*) pointer.
120 Depending on the current debugging level, this function may invoke
121 certain runtime checks to identify invalid casts.
122 </para>
123
124 @object: Object which is subject to casting.
125
126
127 <!-- ##### MACRO G_IS_OBJECT ##### -->
128 <para>
129 Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.
130 </para>
131
132 @object: Instance to check for being a %G_TYPE_OBJECT.
133
134
135 <!-- ##### MACRO G_OBJECT_CLASS ##### -->
136 <para>
137 Casts a derived #GObjectClass structure into a #GObjectClass structure.
138 </para>
139
140 @class: a valid #GObjectClass
141
142
143 <!-- ##### MACRO G_IS_OBJECT_CLASS ##### -->
144 <para>
145 Checks whether @class "is a" valid #GObjectClass structure of type
146 %G_TYPE_OBJECT or derived.
147 </para>
148
149 @class: a #GObjectClass
150
151
152 <!-- ##### MACRO G_OBJECT_GET_CLASS ##### -->
153 <para>
154 Returns the class structure associated to a #GObject instance.
155 </para>
156
157 @object: a #GObject instance.
158
159
160 <!-- ##### MACRO G_OBJECT_TYPE ##### -->
161 <para>
162 Return the type id of an object.
163 </para>
164
165 @object: Object to return the type id for.
166 @Returns: Type id of @object.
167
168
169 <!-- ##### MACRO G_OBJECT_TYPE_NAME ##### -->
170 <para>
171 Returns the name of an object's type.
172 </para>
173
174 @object: Object to return the type name for.
175 @Returns: Type name of @object. The string is owned by the type system and 
176 should not be freed.
177
178
179 <!-- ##### MACRO G_OBJECT_CLASS_TYPE ##### -->
180 <para>
181 Return the type id of a class structure.
182 </para>
183
184 @class: a valid #GObjectClass
185 @Returns: Type id of @class.
186
187
188 <!-- ##### MACRO G_OBJECT_CLASS_NAME ##### -->
189 <para>
190 Return the name of a class structure's type.
191 </para>
192
193 @class: a valid #GObjectClass
194 @Returns: Type name of @class. The string is owned by the type system and 
195 should not be freed.
196
197
198 <!-- ##### FUNCTION g_object_class_install_property ##### -->
199 <para>
200 Installs a new property. This is usually done in the class initializer.
201 </para>
202
203 @oclass: a #GObjectClass
204 @property_id: the id for the new property
205 @pspec: the #GParamSpec for the new property
206
207
208 <!-- ##### FUNCTION g_object_class_find_property ##### -->
209 <para>
210 Looks up the #GParamSpec for a property of a class.
211 </para>
212
213 @oclass: a #GObjectClass
214 @property_name: the name of the property to look up
215 @Returns: the #GParamSpec for the property, or %NULL if the class doesn't have
216 a property of that name
217
218
219 <!-- ##### FUNCTION g_object_class_list_properties ##### -->
220 <para>
221 Returns an array of #GParamSpec* for all properties of a class.
222 </para>
223
224 @oclass: a #GObjectClass
225 @n_properties: return location for the length of the returned array
226 @Returns: an array of #GParamSpec* which should be freed after use
227
228
229 <!-- ##### FUNCTION g_object_class_override_property ##### -->
230 <para>
231 Registers @property_id as referring to a property with the
232 name @name in a parent class or in an interface implemented
233 by @oclass. This allows this class to <firstterm>override</firstterm>
234 a property implementation in a parent class or to provide
235 the implementation of a property from an interface.
236 </para>
237 <note>
238 <para>
239 Internally, overriding is implemented by creating a property of type
240 #GParamSpecOverride; generally operations that query the properties of
241 the object class, such as g_object_class_find_property() or
242 g_object_class_list_properties() will return the overridden
243 property. However, in one case, the @construct_properties argument of
244 the @constructor virtual function, the #GParamSpecOverride is passed
245 instead, so that the @param_id field of the #GParamSpec will be
246 correct.  For virtually all uses, this makes no difference. If you
247 need to get the overridden property, you can call
248 g_param_spec_get_redirect_target().
249 </para>
250 </note>
251
252 @oclass: a #GObjectClass
253 @property_id: the new property ID
254 @name: the name of a property registered in a parent class or
255        in an interface of this class.
256
257
258 <!-- ##### FUNCTION g_object_interface_install_property ##### -->
259 <para>
260 Add a property to an interface; this is only useful for interfaces
261 that are added to GObject-derived types. Adding a property to an
262 interface forces all objects classes with that interface to have a
263 compatible property. The compatible property could be a newly
264 created #GParamSpec, but normally
265 g_object_class_override_property() will be used so that the object
266 class only needs to provide an implementation and inherits the
267 property description, default value, bounds, and so forth from the
268 interface property.
269 </para>
270 <para>
271 This function is meant to be called from the interface's default
272 vtable initialization function (the @class_init member of
273 #GTypeInfo.) It must not be called after after @class_init has
274 been called for any object types implementing this interface.
275 </para>
276
277 @g_iface: any interface vtable for the interface, or the default
278  vtable for the interface.
279 @pspec: the #GParamSpec for the new property
280 @Since: 2.4
281
282
283 <!-- ##### FUNCTION g_object_interface_find_property ##### -->
284 <para>
285 Find the #GParamSpec with the given name for an
286 interface. Generally, the interface vtable passed in as @g_iface
287 will be the default vtable from g_type_default_interface_ref(), or,
288 if you know the interface has already been loaded,
289 g_type_default_interface_peek().
290 </para>
291
292 @g_iface: any interface vtable for the interface, or the default
293   vtable for the interface
294 @property_name: name of a property to lookup.
295 @Returns: the #GParamSpec for the property of the
296   interface with the name @property_name, or %NULL
297   if no such property exists.
298 @Since: 2.4
299
300
301 <!-- ##### FUNCTION g_object_interface_list_properties ##### -->
302 <para>
303 Lists the properties of an interface.Generally, the interface
304 vtable passed in as @g_iface will be the default vtable from
305 g_type_default_interface_ref(), or, if you know the interface has
306 already been loaded, g_type_default_interface_peek().
307 </para>
308
309 @g_iface: any interface vtable for the interface, or the default
310  vtable for the interface
311 @n_properties_p: location to store number of properties returned.
312 @Returns: a pointer to an array of pointers to #GParamSpec structures.
313   The paramspecs are owned by GLib, but the array should
314   be freed with g_free() when you are done with it.
315 @Since: 2.4
316
317
318 <!-- ##### FUNCTION g_object_new ##### -->
319 <para>
320 Creates a new instance of a #GObject subtype and sets its properties.
321 </para>
322 <para>
323 Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY) 
324 which are not explicitly specified are set to their default values.
325 </para>
326
327 @object_type: the type id of the #GObject subtype to instantiate
328 @first_property_name: the name of the first property
329 @Varargs: the value of the first property, followed optionally by more
330      name/value pairs, followed by %NULL
331 @Returns: a new instance of @object_type
332
333
334 <!-- ##### FUNCTION g_object_newv ##### -->
335 <para>
336 Creates a new instance of a #GObject subtype and sets its properties.
337 </para>
338 <para>
339 Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY) 
340 which are not explicitly specified are set to their default values.
341 </para>
342
343 @object_type: the type id of the #GObject subtype to instantiate
344 @n_parameters: the length of the @parameters array
345 @parameters: an array of #GParameter
346 @Returns: a new instance of @object_type
347
348
349 <!-- ##### STRUCT GParameter ##### -->
350 <para>
351 The <structname>GParameter</structname> struct is an auxiliary structure used
352 to hand parameter name/value pairs to g_object_newv().
353 </para>
354
355 @name: the parameter name
356 @value: the parameter value
357
358 <!-- ##### FUNCTION g_object_ref ##### -->
359 <para>
360 Increases the reference count of @object.
361 </para>
362
363 @object: a #GObject
364 @Returns: @object
365
366
367 <!-- ##### FUNCTION g_object_unref ##### -->
368 <para>
369 Decreases the reference count if @object.
370 When its reference count drops to 0, the object is finalized (i.e. its memory is freed).
371 </para>
372
373 @object: a #GObject
374
375
376 <!-- ##### USER_FUNCTION GWeakNotify ##### -->
377 <para>
378 A #GWeakNotify function can be added to an object as a callback that gets
379 triggered when the object is finalized. Since the object is already being
380 finalized when the #GWeakNotify is called, there's not much you could do 
381 with the object, apart from e.g. using its adress as hash-index or the like. 
382 </para>
383
384 @data: data that was provided when the weak reference was established
385 @where_the_object_was: the object being finalized
386
387
388 <!-- ##### FUNCTION g_object_weak_ref ##### -->
389 <para>
390 Adds a weak reference callback to an object. Weak references are used for
391 notification when an object is finalized. They are called "weak references" 
392 because they allow you to safely hold a pointer to an object without calling 
393 g_object_ref() (g_object_ref() adds a strong reference, that is, forces the 
394 object to stay alive).
395 </para>
396
397 @object: #GObject to reference weakly
398 @notify: callback to invoke before the object is freed
399 @data: extra data to pass to notify
400
401
402 <!-- ##### FUNCTION g_object_weak_unref ##### -->
403 <para>
404 Removes a weak reference callback to an object.
405 </para>
406
407 @object: #GObject to remove a weak reference from
408 @notify: callback to search for
409 @data: data to search for
410
411
412 <!-- ##### FUNCTION g_object_add_weak_pointer ##### -->
413 <para>
414 Adds a weak reference from weak_pointer to @object to indicate that
415 the pointer located at @weak_pointer_location is only valid during the 
416 lifetime of @object. When the @object is finalized, @weak_pointer will 
417 be set to %NULL.
418 </para>
419
420 @object: The object that should be weak referenced.
421 @weak_pointer_location: The memory address of a pointer.
422
423
424 <!-- ##### FUNCTION g_object_remove_weak_pointer ##### -->
425 <para>
426 Removes a weak reference from @object that was previously added
427 using g_object_add_weak_pointer(). The @weak_pointer_location has
428 to match the one used with g_object_add_weak_pointer().
429 </para>
430
431 @object: The object that is weak referenced.
432 @weak_pointer_location: The memory address of a pointer.
433
434
435 <!-- ##### FUNCTION g_object_connect ##### -->
436 <para>
437 A convenience function to connect multiple signals at once.
438 </para>
439 <para>
440 The signal specs expected by this function have the form
441 "modifier::signal_name", where modifier can be one of the following:
442 <variablelist>
443 <varlistentry>
444 <term>signal</term>
445 <listitem><para>
446 equivalent to <literal>g_signal_connect_data (...)</literal>
447 </para></listitem>
448 </varlistentry>
449 <varlistentry>
450 <term>object_signal</term>
451 <term>object-signal</term>
452 <listitem><para>
453 equivalent to <literal>g_signal_connect_object (...)</literal>
454 </para></listitem>
455 </varlistentry>
456 <varlistentry>
457 <term>swapped_signal</term>
458 <term>swapped-signal</term>
459 <listitem><para>
460 equivalent to <literal>g_signal_connect_data (..., G_CONNECT_SWAPPED)</literal>
461 </para></listitem>
462 </varlistentry>
463 <varlistentry>
464 <term>swapped_object_signal</term>
465 <term>swapped-object-signal</term>
466 <listitem><para>
467 equivalent to <literal>g_signal_connect_object (..., G_CONNECT_SWAPPED)</literal>
468 </para></listitem>
469 </varlistentry>
470 <varlistentry>
471 <term>signal_after</term>
472 <term>signal-after</term>
473 <listitem><para>
474 equivalent to <literal>g_signal_connect_data (..., G_CONNECT_AFTER)</literal>
475 </para></listitem>
476 </varlistentry>
477 <varlistentry>
478 <term>object_signal_after</term>
479 <term>object-signal-after</term>
480 <listitem><para>
481 equivalent to <literal>g_signal_connect_object (..., G_CONNECT_AFTER)</literal>
482 </para></listitem>
483 </varlistentry>
484 <varlistentry>
485 <term>swapped_signal_after</term>
486 <term>swapped-signal-after</term>
487 <listitem><para>
488 equivalent to <literal>g_signal_connect_data (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)</literal>
489 </para></listitem>
490 </varlistentry>
491 <varlistentry>
492 <term>swapped_object_signal_after</term>
493 <term>swapped-object-signal-after</term>
494 <listitem><para>
495 equivalent to <literal>g_signal_connect_object (..., G_CONNECT_SWAPPED | G_CONNECT_AFTER)</literal>
496 </para></listitem>
497 </varlistentry>
498 </variablelist>
499 </para>
500 <informalexample>
501 <programlisting>
502   menu->toplevel = g_object_connect (g_object_new (GTK_TYPE_WINDOW,
503                                                    "type", GTK_WINDOW_POPUP,
504                                                    "child", menu,
505                                                    NULL),
506                                      "signal::event", gtk_menu_window_event, menu,
507                                      "signal::size_request", gtk_menu_window_size_request, menu,
508                                      "signal::destroy", gtk_widget_destroyed, &amp;menu-&gt;toplevel,
509                                      NULL);
510 </programlisting>
511 </informalexample>
512
513 @object: a #GObject
514 @signal_spec: the spec for the first signal
515 @Varargs: #GCallback for the first signal, followed by data for the first signal, 
516           followed optionally by more signal spec/callback/data triples, 
517           followed by %NULL
518 @Returns: @object
519
520
521 <!-- ##### FUNCTION g_object_disconnect ##### -->
522 <para>
523 A convenience function to disconnect multiple signals at once.
524 </para>
525 <para>
526 The signal specs expected by this function have the form "any_signal", which
527 means to disconnect any signal with matching callback and data, or 
528 "any_signal::signal_name", which only disconnects the signal named "signal_name". 
529 </para>
530
531 @object: a #GObject
532 @signal_spec: the spec for the first signal
533 @Varargs: #GCallback for the first signal, followed by data for the first signal, 
534           followed optionally by more signal spec/callback/data triples, 
535           followed by %NULL
536
537
538 <!-- ##### FUNCTION g_object_set ##### -->
539 <para>
540 Sets properties on an object.
541 </para>
542
543 @object: a #GObject
544 @first_property_name: name of the first property to set
545 @Varargs: value for the first property, followed optionally by more
546           name/value pairs, followed by %NULL
547
548
549 <!-- ##### FUNCTION g_object_get ##### -->
550 <para>
551 Gets properties of an object.
552 </para>
553 <para>
554 In general, a copy is made of the property contents and the caller is
555 responsible for freeing the memory in the appropriate manner for the type, 
556 for instance by calling g_free() or g_object_unref().
557 </para>
558 <example>
559 <title>Using g_object_get(<!-- -->)</title>
560 <para>
561 An example of using g_object_get() to get the contents
562 of three properties - one of type #G_TYPE_INT,
563 one of type #G_TYPE_STRING, and one of type #G_TYPE_OBJECT:
564 </para>
565 <programlisting>
566  gint intval;
567  gchar *strval;
568  GObject *objval; 
569  
570  g_object_get (my_object,
571                "intproperty", &amp;intval,
572                "strproperty", &amp;strval,
573                "objproperty", &amp;objval,
574                NULL);
575
576  /* Do something with intval, strval, objval */
577  
578  g_free (strval);
579  g_object_unref (objval);
580 </programlisting>
581 </example>
582
583 @object: a #GObject
584 @first_property_name: name of the first property to get
585 @Varargs: return location for the first property, followed optionally by more
586           name/return location pairs, followed by %NULL
587
588
589 <!-- ##### FUNCTION g_object_notify ##### -->
590 <para>
591 Emits a "notify" signal for the property @property_name on @object. 
592 </para>
593
594 @object: a #GObject
595 @property_name: the name of a property installed on the class of @object.
596
597
598 <!-- ##### FUNCTION g_object_freeze_notify ##### -->
599 <para>
600 Stops emission of "notify" signals on @object. The signals are
601 queued until g_object_thaw_notify() is called on @object. 
602 </para>
603 <para>
604 This is necessary for accessors that modify multiple properties to prevent
605 premature notification while the object is still being modified.
606 </para>
607
608 @object: a #GObject
609
610
611 <!-- ##### FUNCTION g_object_thaw_notify ##### -->
612 <para>
613 Reverts the effect of a previous call to g_object_freeze_notify().
614 This causes all queued "notify" signals on @object to be emitted.
615 </para>
616
617 @object: a #GObject
618
619
620 <!-- ##### FUNCTION g_object_get_data ##### -->
621 <para>
622 Gets a named field from the objects table of associations (see g_object_set_data()).
623 </para>
624
625 @object: #GObject containing the associations
626 @key: name of the key for that association
627 @Returns: the data if found, or %NULL if no such data exists.
628
629
630 <!-- ##### FUNCTION g_object_set_data ##### -->
631 <para>
632 Each object carries around a table of associations from
633 strings to pointers.  This function lets you set an association.
634 </para>
635 <para>
636 If the object already had an association with that name,
637 the old association will be destroyed.
638 </para>
639
640 @object: #GObject containing the associations.
641 @key: name of the key
642 @data: data to associate with that key
643
644
645 <!-- ##### FUNCTION g_object_set_data_full ##### -->
646 <para>
647 Like g_object_set_data() except it adds notification
648 for when the association is destroyed, either by setting it 
649 to a different value or when the object is destroyed.
650 </para>
651
652 @object: #GObject containing the associations
653 @key: name of the key
654 @data: data to associate with that key
655 @destroy: function to call when the association is destroyed
656
657
658 <!-- ##### FUNCTION g_object_steal_data ##### -->
659 <para>
660 Remove a specified datum from the object's data associations,
661 without invoking the association's destroy handler.
662 </para>
663
664 @object: #GObject containing the associations
665 @key: name of the key
666 @Returns: the data if found, or %NULL if no such data exists.
667
668
669 <!-- ##### FUNCTION g_object_get_qdata ##### -->
670 <para>
671 This function gets back user data pointers stored via
672 g_object_set_qdata().
673 </para>
674
675 @object:  The GObject to get a stored user data pointer from
676 @quark:   A #GQuark, naming the user data pointer
677 @Returns: The user data pointer set, or %NULL
678
679
680 <!-- ##### FUNCTION g_object_set_qdata ##### -->
681 <para>
682 This sets an opaque, named pointer on an object.
683 The name is specified through a #GQuark (retrived e.g. via
684 g_quark_from_static_string()), and the pointer
685 can be gotten back from the @object with g_object_get_qdata()
686 until the @object is finalized.
687 Setting a previously set user data pointer, overrides (frees)
688 the old pointer set, using #NULL as pointer essentially
689 removes the data stored.
690 </para>
691
692 @object: The GObject to set store a user data pointer
693 @quark:  A #GQuark, naming the user data pointer
694 @data:   An opaque user data pointer
695
696
697 <!-- ##### FUNCTION g_object_set_qdata_full ##### -->
698 <para>
699 This function works like g_object_set_qdata(), but in addition,
700 a void (*destroy) (gpointer) function may be specified which is
701 called with @data as argument when the @object is finalized, or
702 the data is being overwritten by a call to g_object_set_qdata()
703 with the same @quark.
704 </para>
705
706 @object:  The GObject to set store a user data pointer
707 @quark:   A #GQuark, naming the user data pointer
708 @data:    An opaque user data pointer
709 @destroy: Function to invoke with @data as argument, when @data needs to be freed
710
711
712 <!-- ##### FUNCTION g_object_steal_qdata ##### -->
713 <para>
714 This function gets back user data pointers stored via
715 g_object_set_qdata() and removes the @data from object
716 without invoking it's destroy() function (if any was
717 set).
718 Usually, calling this function is only required to update
719 user data pointers with a destroy notifier, for example:
720 <programlisting>
721 void
722 object_add_to_user_list (GObject     *object,
723                          const gchar *new_string)
724 {
725   /* the quark, naming the object data */
726   GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
727   /* retrive the old string list */
728   GList *list = g_object_steal_qdata (object, quark_string_list);
729   
730   /* prepend new string */
731   list = g_list_prepend (list, g_strdup (new_string));
732   /* this changed 'list', so we need to set it again */
733   g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
734 }
735 static void
736 free_string_list (gpointer data)
737 {
738   GList *node, *list = data;
739   
740   for (node = list; node; node = node->next)
741     g_free (node->data);
742   g_list_free (list);
743 }
744 </programlisting>
745 Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata()
746 would have left the destroy function set, and thus the partial string list would
747 have been freed upon g_object_set_qdata_full().
748 </para>
749
750 @object:  The GObject to get a stored user data pointer from
751 @quark:   A #GQuark, naming the user data pointer
752 @Returns: The user data pointer set, or %NULL
753
754
755 <!-- ##### FUNCTION g_object_set_property ##### -->
756 <para>
757 Sets a property on an object.
758 </para>
759
760 @object: a #GObject
761 @property_name: the name of the property to set
762 @value: the value
763
764
765 <!-- ##### FUNCTION g_object_get_property ##### -->
766 <para>
767 Gets a property of an object.
768 </para>
769 <para>
770 In general, a copy is made of the property contents and the caller is
771 responsible for freeing the memory by calling g_value_unset().
772 </para>
773 <para>
774 Note that g_object_get_property() is really intended for language
775 bindings, g_object_get() is much more convenient for C programming.
776 </para>
777
778 @object: a #GObject
779 @property_name: the name of the property to get
780 @value: return location for the property value
781
782
783 <!-- ##### FUNCTION g_object_new_valist ##### -->
784 <para>
785 Creates a new instance of a #GObject subtype and sets its properties.
786 </para>
787 <para>
788 Construction parameters (see #G_PARAM_CONSTRUCT, #G_PARAM_CONSTRUCT_ONLY) 
789 which are not explicitly specified are set to their default values.
790 </para>
791
792 @object_type: the type id of the #GObject subtype to instantiate
793 @first_property_name: the name of the first property
794 @var_args: the value of the first property, followed optionally by more
795      name/value pairs, followed by %NULL
796 @Returns: a new instance of @object_type
797
798
799 <!-- ##### FUNCTION g_object_set_valist ##### -->
800 <para>
801 Sets properties on an object.
802 </para>
803
804 @object: a #GObject
805 @first_property_name: name of the first property to set
806 @var_args: value for the first property, followed optionally by more
807            name/value pairs, followed by %NULL
808
809
810 <!-- ##### FUNCTION g_object_get_valist ##### -->
811 <para>
812 Gets properties of an object. 
813 </para>
814 <para>
815 In general, a copy is made of the property contents and the caller is
816 responsible for freeing the memory in the appropriate manner for the type, 
817 for instance by calling g_free() or g_object_unref().
818 </para>
819 <para>
820 See g_object_get().
821 </para>
822
823 @object: a #GObject
824 @first_property_name: name of the first property to get
825 @var_args: return location for the first property, followed optionally by more
826            name/return location pairs, followed by %NULL
827
828
829 <!-- ##### FUNCTION g_object_watch_closure ##### -->
830 <para>
831 This function essentially limits the life time of the @closure
832 to the life time of the object. That is, when the object is finalized,
833 the @closure is invalidated by calling g_closure_invalidate() on it,
834 in order to prevent invocations of the closure with a finalized 
835 (nonexisting) object. Also, g_object_ref() and g_object_unref() are added
836 as marshal guards to the @closure, to ensure that an extra reference
837 count is held on @object during invocation of the @closure.
838 Usually, this function will be called on closures that use this @object
839 as closure data.
840 </para>
841
842 @object:  GObject restricting lifetime of @closure
843 @closure: GClosure to watch
844
845
846 <!-- ##### FUNCTION g_object_run_dispose ##### -->
847 <para>
848 Releases all references to other objects. This can be used to break 
849 reference cycles.
850 </para>
851 <note><para>
852 This functions should only be called from object system implementations.
853 </para></note>
854
855 @object: a #GObject
856
857
858 <!-- ##### MACRO G_OBJECT_WARN_INVALID_PROPERTY_ID ##### -->
859 <para>
860 This macros should be used to emit a standard warning about unexpected 
861 properties in set_property() and get_property() implementations.
862 </para>
863
864 @object: the #GObject on which set_property() or get_property() was called
865 @property_id: the numeric id of the property
866 @pspec: the #GParamSpec of the property
867
868