Install an invalidation notifier for GClosure in g_source_set_closure()
[platform/upstream/glib.git] / gobject / gobject.h
1 /* GObject - GLib Type, Object, Parameter and Signal Library
2  * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General
15  * Public License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 #ifndef __G_OBJECT_H__
20 #define __G_OBJECT_H__
21
22 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
23 #error "Only <glib-object.h> can be included directly."
24 #endif
25
26 #include        <gobject/gtype.h>
27 #include        <gobject/gvalue.h>
28 #include        <gobject/gparam.h>
29 #include        <gobject/gclosure.h>
30 #include        <gobject/gsignal.h>
31 #include        <gobject/gboxed.h>
32
33 G_BEGIN_DECLS
34
35 /* --- type macros --- */
36 /**
37  * G_TYPE_IS_OBJECT:
38  * @type: Type id to check
39  * 
40  * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it.
41  * 
42  * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT.
43  */
44 #define G_TYPE_IS_OBJECT(type)      (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
45 /**
46  * G_OBJECT:
47  * @object: Object which is subject to casting.
48  * 
49  * Casts a #GObject or derived pointer into a (GObject*) pointer.
50  * Depending on the current debugging level, this function may invoke
51  * certain runtime checks to identify invalid casts.
52  */
53 #define G_OBJECT(object)            (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
54 /**
55  * G_OBJECT_CLASS:
56  * @class: a valid #GObjectClass
57  * 
58  * Casts a derived #GObjectClass structure into a #GObjectClass structure.
59  */
60 #define G_OBJECT_CLASS(class)       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
61 /**
62  * G_IS_OBJECT:
63  * @object: Instance to check for being a %G_TYPE_OBJECT.
64  * 
65  * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.
66  */
67 #define G_IS_OBJECT(object)         (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
68 /**
69  * G_IS_OBJECT_CLASS:
70  * @class: a #GObjectClass
71  * 
72  * Checks whether @class "is a" valid #GObjectClass structure of type
73  * %G_TYPE_OBJECT or derived.
74  */
75 #define G_IS_OBJECT_CLASS(class)    (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
76 /**
77  * G_OBJECT_GET_CLASS:
78  * @object: a #GObject instance.
79  * 
80  * Get the class structure associated to a #GObject instance.
81  *
82  * Returns: pointer to object class structure.
83  */
84 #define G_OBJECT_GET_CLASS(object)  (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
85 /**
86  * G_OBJECT_TYPE:
87  * @object: Object to return the type id for.
88  * 
89  * Get the type id of an object.
90  * 
91  * Returns: Type id of @object.
92  */
93 #define G_OBJECT_TYPE(object)       (G_TYPE_FROM_INSTANCE (object))
94 /**
95  * G_OBJECT_TYPE_NAME:
96  * @object: Object to return the type name for.
97  * 
98  * Get the name of an object's type.
99  * 
100  * Returns: Type name of @object. The string is owned by the type system and 
101  *  should not be freed.
102  */
103 #define G_OBJECT_TYPE_NAME(object)  (g_type_name (G_OBJECT_TYPE (object)))
104 /**
105  * G_OBJECT_CLASS_TYPE:
106  * @class: a valid #GObjectClass
107  * 
108  * Get the type id of a class structure.
109  * 
110  * Returns: Type id of @class.
111  */
112 #define G_OBJECT_CLASS_TYPE(class)  (G_TYPE_FROM_CLASS (class))
113 /**
114  * G_OBJECT_CLASS_NAME:
115  * @class: a valid #GObjectClass
116  * 
117  * Return the name of a class structure's type.
118  * 
119  * Returns: Type name of @class. The string is owned by the type system and 
120  *  should not be freed.
121  */
122 #define G_OBJECT_CLASS_NAME(class)  (g_type_name (G_OBJECT_CLASS_TYPE (class)))
123 /**
124  * G_VALUE_HOLDS_OBJECT:
125  * @value: a valid #GValue structure
126  * 
127  * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT.
128  * 
129  * Returns: %TRUE on success.
130  */
131 #define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
132
133 /* --- type macros --- */
134 /**
135  * G_TYPE_INITIALLY_UNOWNED:
136  * 
137  * The type for #GInitiallyUnowned.
138  */
139 #define G_TYPE_INITIALLY_UNOWNED              (g_initially_unowned_get_type())
140 /**
141  * G_INITIALLY_UNOWNED:
142  * @object: Object which is subject to casting.
143  * 
144  * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*) 
145  * pointer. Depending on the current debugging level, this function may invoke
146  * certain runtime checks to identify invalid casts.
147  */
148 #define G_INITIALLY_UNOWNED(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))
149 /**
150  * G_INITIALLY_UNOWNED_CLASS:
151  * @class: a valid #GInitiallyUnownedClass
152  * 
153  * Casts a derived #GInitiallyUnownedClass structure into a
154  * #GInitiallyUnownedClass structure.
155  */
156 #define G_INITIALLY_UNOWNED_CLASS(class)      (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
157 /**
158  * G_IS_INITIALLY_UNOWNED:
159  * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED.
160  * 
161  * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED.
162  */
163 #define G_IS_INITIALLY_UNOWNED(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))
164 /**
165  * G_IS_INITIALLY_UNOWNED_CLASS:
166  * @class: a #GInitiallyUnownedClass
167  * 
168  * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type
169  * %G_TYPE_INITIALLY_UNOWNED or derived.
170  */
171 #define G_IS_INITIALLY_UNOWNED_CLASS(class)   (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))
172 /**
173  * G_INITIALLY_UNOWNED_GET_CLASS:
174  * @object: a #GInitiallyUnowned instance.
175  * 
176  * Get the class structure associated to a #GInitiallyUnowned instance.
177  *
178  * Returns: pointer to object class structure.
179  */
180 #define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
181 /* GInitiallyUnowned ia a GObject with initially floating reference count */
182
183
184 /* --- typedefs & structures --- */
185 typedef struct _GObject                  GObject;
186 typedef struct _GObjectClass             GObjectClass;
187 typedef struct _GObject                  GInitiallyUnowned;
188 typedef struct _GObjectClass             GInitiallyUnownedClass;
189 typedef struct _GObjectConstructParam    GObjectConstructParam;
190 /**
191  * GObjectGetPropertyFunc:
192  * @object: a #GObject
193  * @property_id: the numeric id under which the property was registered with
194  *  g_object_class_install_property().
195  * @value: a #GValue to return the property value in
196  * @pspec: the #GParamSpec describing the property
197  * 
198  * The type of the @get_property function of #GObjectClass. 
199  */
200 typedef void (*GObjectGetPropertyFunc)  (GObject      *object,
201                                          guint         property_id,
202                                          GValue       *value,
203                                          GParamSpec   *pspec);
204 /**
205  * GObjectSetPropertyFunc:
206  * @object: a #GObject
207  * @property_id: the numeric id under which the property was registered with
208  *  g_object_class_install_property().
209  * @value: the new value for the property
210  * @pspec: the #GParamSpec describing the property
211  * 
212  * The type of the @set_property function of #GObjectClass. 
213  */
214 typedef void (*GObjectSetPropertyFunc)  (GObject      *object,
215                                          guint         property_id,
216                                          const GValue *value,
217                                          GParamSpec   *pspec);
218 /**
219  * GObjectFinalizeFunc:
220  * @object: the #GObject being finalized
221  * 
222  * The type of the @finalize function of #GObjectClass.
223  */
224 typedef void (*GObjectFinalizeFunc)     (GObject      *object);
225 /**
226  * GWeakNotify:
227  * @data: data that was provided when the weak reference was established
228  * @where_the_object_was: the object being finalized
229  * 
230  * A #GWeakNotify function can be added to an object as a callback that gets
231  * triggered when the object is finalized. Since the object is already being
232  * finalized when the #GWeakNotify is called, there's not much you could do 
233  * with the object, apart from e.g. using its address as hash-index or the like. 
234  */
235 typedef void (*GWeakNotify)             (gpointer      data,
236                                          GObject      *where_the_object_was);
237 /**
238  * GObject:
239  * 
240  * All the fields in the <structname>GObject</structname> structure are private 
241  * to the #GObject implementation and should never be accessed directly.
242  */
243 struct  _GObject
244 {
245   GTypeInstance  g_type_instance;
246   
247   /*< private >*/
248   volatile guint ref_count;
249   GData         *qdata;
250 };
251 /**
252  * GObjectClass:
253  * @g_type_class: the parent class
254  * @constructor: the @constructor function is called by g_object_new () to 
255  *  complete the object initialization after all the construction properties are
256  *  set. The first thing a @constructor implementation must do is chain up to the
257  *  @constructor of the parent class. Overriding @constructor should be rarely 
258  *  needed, e.g. to handle construct properties, or to implement singletons.
259  * @set_property: the generic setter for all properties of this type. Should be
260  *  overridden for every type with properties. Implementations of @set_property
261  *  don't need to emit property change notification explicitly, this is handled
262  *  by the type system.
263  * @get_property: the generic getter for all properties of this type. Should be
264  *  overridden for every type with properties.
265  * @dispose: the @dispose function is supposed to drop all references to other 
266  *  objects, but keep the instance otherwise intact, so that client method 
267  *  invocations still work. It may be run multiple times (due to reference 
268  *  loops). Before returning, @dispose should chain up to the @dispose method 
269  *  of the parent class.
270  * @finalize: instance finalization function, should finish the finalization of 
271  *  the instance begun in @dispose and chain up to the @finalize method of the 
272  *  parent class.
273  * @dispatch_properties_changed: emits property change notification for a bunch
274  *  of properties. Overriding @dispatch_properties_changed should be rarely 
275  *  needed.
276  * @notify: the class closure for the notify signal
277  * @constructed: the @constructed function is called by g_object_new() as the
278  *  final step of the object creation process.  At the point of the call, all
279  *  construction properties have been set on the object.  The purpose of this
280  *  call is to allow for object initialisation steps that can only be performed
281  *  after construction properties have been set.  @constructed implementors
282  *  should chain up to the @constructed call of their parent class to allow it
283  *  to complete its initialisation.
284  * 
285  * The class structure for the <structname>GObject</structname> type.
286  * 
287  * <example>
288  * <title>Implementing singletons using a constructor</title>
289  * <programlisting>
290  * static MySingleton *the_singleton = NULL;
291  * 
292  * static GObject*
293  * my_singleton_constructor (GType                  type,
294  *                           guint                  n_construct_params,
295  *                           GObjectConstructParam *construct_params)
296  * {
297  *   GObject *object;
298  *   
299  *   if (!the_singleton)
300  *     {
301  *       object = G_OBJECT_CLASS (parent_class)->constructor (type,
302  *                                                            n_construct_params,
303  *                                                            construct_params);
304  *       the_singleton = MY_SINGLETON (object);
305  *     }
306  *   else
307  *     object = g_object_ref (G_OBJECT (the_singleton));
308  * 
309  *   return object;
310  * }
311  * </programlisting></example>
312  */
313 struct  _GObjectClass
314 {
315   GTypeClass   g_type_class;
316
317   /*< private >*/
318   GSList      *construct_properties;
319
320   /*< public >*/
321   /* seldom overidden */
322   GObject*   (*constructor)     (GType                  type,
323                                  guint                  n_construct_properties,
324                                  GObjectConstructParam *construct_properties);
325   /* overridable methods */
326   void       (*set_property)            (GObject        *object,
327                                          guint           property_id,
328                                          const GValue   *value,
329                                          GParamSpec     *pspec);
330   void       (*get_property)            (GObject        *object,
331                                          guint           property_id,
332                                          GValue         *value,
333                                          GParamSpec     *pspec);
334   void       (*dispose)                 (GObject        *object);
335   void       (*finalize)                (GObject        *object);
336   /* seldom overidden */
337   void       (*dispatch_properties_changed) (GObject      *object,
338                                              guint         n_pspecs,
339                                              GParamSpec  **pspecs);
340   /* signals */
341   void       (*notify)                  (GObject        *object,
342                                          GParamSpec     *pspec);
343
344   /* called when done constructing */
345   void       (*constructed)             (GObject        *object);
346
347   /*< private >*/
348   gsize         flags;
349
350   /* padding */
351   gpointer      pdummy[6];
352 };
353 /**
354  * GObjectConstructParam:
355  * @pspec: the #GParamSpec of the construct parameter
356  * @value: the value to set the parameter to
357  * 
358  * The <structname>GObjectConstructParam</structname> struct is an auxiliary 
359  * structure used to hand #GParamSpec/#GValue pairs to the @constructor of
360  * a #GObjectClass.
361  */
362 struct _GObjectConstructParam
363 {
364   GParamSpec *pspec;
365   GValue     *value;
366 };
367
368 /**
369  * GInitiallyUnowned:
370  * 
371  * All the fields in the <structname>GInitiallyUnowned</structname> structure 
372  * are private to the #GInitiallyUnowned implementation and should never be 
373  * accessed directly.
374  */
375 /**
376  * GInitiallyUnownedClass:
377  * 
378  * The class structure for the <structname>GInitiallyUnowned</structname> type.
379  */
380
381
382 /* --- prototypes --- */
383 GLIB_AVAILABLE_IN_ALL
384 GType       g_initially_unowned_get_type      (void);
385 GLIB_AVAILABLE_IN_ALL
386 void        g_object_class_install_property   (GObjectClass   *oclass,
387                                                guint           property_id,
388                                                GParamSpec     *pspec);
389 GLIB_AVAILABLE_IN_ALL
390 GParamSpec* g_object_class_find_property      (GObjectClass   *oclass,
391                                                const gchar    *property_name);
392 GLIB_AVAILABLE_IN_ALL
393 GParamSpec**g_object_class_list_properties    (GObjectClass   *oclass,
394                                                guint          *n_properties);
395 GLIB_AVAILABLE_IN_ALL
396 void        g_object_class_override_property  (GObjectClass   *oclass,
397                                                guint           property_id,
398                                                const gchar    *name);
399 GLIB_AVAILABLE_IN_ALL
400 void        g_object_class_install_properties (GObjectClass   *oclass,
401                                                guint           n_pspecs,
402                                                GParamSpec    **pspecs);
403
404 GLIB_AVAILABLE_IN_ALL
405 void        g_object_interface_install_property (gpointer     g_iface,
406                                                  GParamSpec  *pspec);
407 GLIB_AVAILABLE_IN_ALL
408 GParamSpec* g_object_interface_find_property    (gpointer     g_iface,
409                                                  const gchar *property_name);
410 GLIB_AVAILABLE_IN_ALL
411 GParamSpec**g_object_interface_list_properties  (gpointer     g_iface,
412                                                  guint       *n_properties_p);
413
414 GLIB_AVAILABLE_IN_ALL
415 GType       g_object_get_type                 (void) G_GNUC_CONST;
416 GLIB_AVAILABLE_IN_ALL
417 gpointer    g_object_new                      (GType           object_type,
418                                                const gchar    *first_property_name,
419                                                ...);
420 GLIB_AVAILABLE_IN_ALL
421 gpointer    g_object_newv                     (GType           object_type,
422                                                guint           n_parameters,
423                                                GParameter     *parameters);
424 GLIB_AVAILABLE_IN_ALL
425 GObject*    g_object_new_valist               (GType           object_type,
426                                                const gchar    *first_property_name,
427                                                va_list         var_args);
428 GLIB_AVAILABLE_IN_ALL
429 void        g_object_set                      (gpointer        object,
430                                                const gchar    *first_property_name,
431                                                ...) G_GNUC_NULL_TERMINATED;
432 GLIB_AVAILABLE_IN_ALL
433 void        g_object_get                      (gpointer        object,
434                                                const gchar    *first_property_name,
435                                                ...) G_GNUC_NULL_TERMINATED;
436 GLIB_AVAILABLE_IN_ALL
437 gpointer    g_object_connect                  (gpointer        object,
438                                                const gchar    *signal_spec,
439                                                ...) G_GNUC_NULL_TERMINATED;
440 GLIB_AVAILABLE_IN_ALL
441 void        g_object_disconnect               (gpointer        object,
442                                                const gchar    *signal_spec,
443                                                ...) G_GNUC_NULL_TERMINATED;
444 GLIB_AVAILABLE_IN_ALL
445 void        g_object_set_valist               (GObject        *object,
446                                                const gchar    *first_property_name,
447                                                va_list         var_args);
448 GLIB_AVAILABLE_IN_ALL
449 void        g_object_get_valist               (GObject        *object,
450                                                const gchar    *first_property_name,
451                                                va_list         var_args);
452 GLIB_AVAILABLE_IN_ALL
453 void        g_object_set_property             (GObject        *object,
454                                                const gchar    *property_name,
455                                                const GValue   *value);
456 GLIB_AVAILABLE_IN_ALL
457 void        g_object_get_property             (GObject        *object,
458                                                const gchar    *property_name,
459                                                GValue         *value);
460 GLIB_AVAILABLE_IN_ALL
461 void        g_object_freeze_notify            (GObject        *object);
462 GLIB_AVAILABLE_IN_ALL
463 void        g_object_notify                   (GObject        *object,
464                                                const gchar    *property_name);
465 GLIB_AVAILABLE_IN_ALL
466 void        g_object_notify_by_pspec          (GObject        *object,
467                                                GParamSpec     *pspec);
468 GLIB_AVAILABLE_IN_ALL
469 void        g_object_thaw_notify              (GObject        *object);
470 GLIB_AVAILABLE_IN_ALL
471 gboolean    g_object_is_floating              (gpointer        object);
472 GLIB_AVAILABLE_IN_ALL
473 gpointer    g_object_ref_sink                 (gpointer        object);
474 GLIB_AVAILABLE_IN_ALL
475 gpointer    g_object_ref                      (gpointer        object);
476 GLIB_AVAILABLE_IN_ALL
477 void        g_object_unref                    (gpointer        object);
478 GLIB_AVAILABLE_IN_ALL
479 void        g_object_weak_ref                 (GObject        *object,
480                                                GWeakNotify     notify,
481                                                gpointer        data);
482 GLIB_AVAILABLE_IN_ALL
483 void        g_object_weak_unref               (GObject        *object,
484                                                GWeakNotify     notify,
485                                                gpointer        data);
486 GLIB_AVAILABLE_IN_ALL
487 void        g_object_add_weak_pointer         (GObject        *object, 
488                                                gpointer       *weak_pointer_location);
489 GLIB_AVAILABLE_IN_ALL
490 void        g_object_remove_weak_pointer      (GObject        *object, 
491                                                gpointer       *weak_pointer_location);
492
493 /**
494  * GToggleNotify:
495  * @data: Callback data passed to g_object_add_toggle_ref()
496  * @object: The object on which g_object_add_toggle_ref() was called.
497  * @is_last_ref: %TRUE if the toggle reference is now the
498  *  last reference to the object. %FALSE if the toggle
499  *  reference was the last reference and there are now other
500  *  references.
501  * 
502  * A callback function used for notification when the state
503  * of a toggle reference changes. See g_object_add_toggle_ref().
504  */
505 typedef void (*GToggleNotify) (gpointer      data,
506                                GObject      *object,
507                                gboolean      is_last_ref);
508
509 GLIB_AVAILABLE_IN_ALL
510 void g_object_add_toggle_ref    (GObject       *object,
511                                  GToggleNotify  notify,
512                                  gpointer       data);
513 GLIB_AVAILABLE_IN_ALL
514 void g_object_remove_toggle_ref (GObject       *object,
515                                  GToggleNotify  notify,
516                                  gpointer       data);
517
518 GLIB_AVAILABLE_IN_ALL
519 gpointer    g_object_get_qdata                (GObject        *object,
520                                                GQuark          quark);
521 GLIB_AVAILABLE_IN_ALL
522 void        g_object_set_qdata                (GObject        *object,
523                                                GQuark          quark,
524                                                gpointer        data);
525 GLIB_AVAILABLE_IN_ALL
526 void        g_object_set_qdata_full           (GObject        *object,
527                                                GQuark          quark,
528                                                gpointer        data,
529                                                GDestroyNotify  destroy);
530 GLIB_AVAILABLE_IN_ALL
531 gpointer    g_object_steal_qdata              (GObject        *object,
532                                                GQuark          quark);
533
534 GLIB_AVAILABLE_IN_2_34
535 gpointer    g_object_dup_qdata                (GObject        *object,
536                                                GQuark          quark,
537                                                GDuplicateFunc  dup_func,
538                                                gpointer         user_data);
539 GLIB_AVAILABLE_IN_2_34
540 gboolean    g_object_replace_qdata            (GObject        *object,
541                                                GQuark          quark,
542                                                gpointer        oldval,
543                                                gpointer        newval,
544                                                GDestroyNotify  destroy,
545                                                GDestroyNotify *old_destroy);
546
547 GLIB_AVAILABLE_IN_ALL
548 gpointer    g_object_get_data                 (GObject        *object,
549                                                const gchar    *key);
550 GLIB_AVAILABLE_IN_ALL
551 void        g_object_set_data                 (GObject        *object,
552                                                const gchar    *key,
553                                                gpointer        data);
554 GLIB_AVAILABLE_IN_ALL
555 void        g_object_set_data_full            (GObject        *object,
556                                                const gchar    *key,
557                                                gpointer        data,
558                                                GDestroyNotify  destroy);
559 GLIB_AVAILABLE_IN_ALL
560 gpointer    g_object_steal_data               (GObject        *object,
561                                                const gchar    *key);
562
563 GLIB_AVAILABLE_IN_2_34
564 gpointer    g_object_dup_data                 (GObject        *object,
565                                                const gchar    *key,
566                                                GDuplicateFunc  dup_func,
567                                                gpointer         user_data);
568 GLIB_AVAILABLE_IN_2_34
569 gboolean    g_object_replace_data             (GObject        *object,
570                                                const gchar    *key,
571                                                gpointer        oldval,
572                                                gpointer        newval,
573                                                GDestroyNotify  destroy,
574                                                GDestroyNotify *old_destroy);
575
576
577 GLIB_AVAILABLE_IN_ALL
578 void        g_object_watch_closure            (GObject        *object,
579                                                GClosure       *closure);
580 GLIB_AVAILABLE_IN_ALL
581 GClosure*   g_cclosure_new_object             (GCallback       callback_func,
582                                                GObject        *object);
583 GLIB_AVAILABLE_IN_ALL
584 GClosure*   g_cclosure_new_object_swap        (GCallback       callback_func,
585                                                GObject        *object);
586 GLIB_AVAILABLE_IN_ALL
587 GClosure*   g_closure_new_object              (guint           sizeof_closure,
588                                                GObject        *object);
589 GLIB_AVAILABLE_IN_ALL
590 void        g_value_set_object                (GValue         *value,
591                                                gpointer        v_object);
592 GLIB_AVAILABLE_IN_ALL
593 gpointer    g_value_get_object                (const GValue   *value);
594 GLIB_AVAILABLE_IN_ALL
595 gpointer    g_value_dup_object                (const GValue   *value);
596 GLIB_AVAILABLE_IN_ALL
597 gulong      g_signal_connect_object           (gpointer        instance,
598                                                const gchar    *detailed_signal,
599                                                GCallback       c_handler,
600                                                gpointer        gobject,
601                                                GConnectFlags   connect_flags);
602
603 /*< protected >*/
604 GLIB_AVAILABLE_IN_ALL
605 void        g_object_force_floating           (GObject        *object);
606 GLIB_AVAILABLE_IN_ALL
607 void        g_object_run_dispose              (GObject        *object);
608
609
610 GLIB_AVAILABLE_IN_ALL
611 void        g_value_take_object               (GValue         *value,
612                                                gpointer        v_object);
613 GLIB_DEPRECATED_FOR(g_value_take_object)
614 void        g_value_set_object_take_ownership (GValue         *value,
615                                                gpointer        v_object);
616
617 GLIB_DEPRECATED
618 gsize       g_object_compat_control           (gsize           what,
619                                                gpointer        data);
620
621 /* --- implementation macros --- */
622 #define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \
623 G_STMT_START { \
624   GObject *_glib__object = (GObject*) (object); \
625   GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \
626   guint _glib__property_id = (property_id); \
627   g_warning ("%s: invalid %s id %u for \"%s\" of type `%s' in `%s'", \
628              G_STRLOC, \
629              (pname), \
630              _glib__property_id, \
631              _glib__pspec->name, \
632              g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \
633              G_OBJECT_TYPE_NAME (_glib__object)); \
634 } G_STMT_END
635 /**
636  * G_OBJECT_WARN_INVALID_PROPERTY_ID:
637  * @object: the #GObject on which set_property() or get_property() was called
638  * @property_id: the numeric id of the property
639  * @pspec: the #GParamSpec of the property
640  * 
641  * This macro should be used to emit a standard warning about unexpected 
642  * properties in set_property() and get_property() implementations.
643  */
644 #define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
645     G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec))
646
647 GLIB_AVAILABLE_IN_ALL
648 void    g_clear_object (volatile GObject **object_ptr);
649 #define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref)
650
651 typedef struct {
652     /*<private>*/
653     union { gpointer p; } priv;
654 } GWeakRef;
655
656 GLIB_AVAILABLE_IN_ALL
657 void     g_weak_ref_init       (GWeakRef *weak_ref,
658                                 gpointer  object);
659 GLIB_AVAILABLE_IN_ALL
660 void     g_weak_ref_clear      (GWeakRef *weak_ref);
661 GLIB_AVAILABLE_IN_ALL
662 gpointer g_weak_ref_get        (GWeakRef *weak_ref);
663 GLIB_AVAILABLE_IN_ALL
664 void     g_weak_ref_set        (GWeakRef *weak_ref,
665                                 gpointer  object);
666
667 G_END_DECLS
668
669 #endif /* __G_OBJECT_H__ */