/src/glib/gobject/gobject.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /* GObject - GLib Type, Object, Parameter and Signal Library  | 
2  |  |  * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.  | 
3  |  |  *  | 
4  |  |  * SPDX-License-Identifier: LGPL-2.1-or-later  | 
5  |  |  *  | 
6  |  |  * This library is free software; you can redistribute it and/or  | 
7  |  |  * modify it under the terms of the GNU Lesser General Public  | 
8  |  |  * License as published by the Free Software Foundation; either  | 
9  |  |  * version 2.1 of the License, or (at your option) any later version.  | 
10  |  |  *  | 
11  |  |  * This library is distributed in the hope that it will be useful,  | 
12  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of  | 
13  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  | 
14  |  |  * Lesser General Public License for more details.  | 
15  |  |  *  | 
16  |  |  * You should have received a copy of the GNU Lesser General  | 
17  |  |  * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.  | 
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  |  |  *  | 
51  |  |  * Depending on the current debugging level, this function may invoke  | 
52  |  |  * certain runtime checks to identify invalid casts.  | 
53  |  |  */  | 
54  |  | #define G_OBJECT(object)            (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))  | 
55  |  | /**  | 
56  |  |  * G_OBJECT_CLASS:  | 
57  |  |  * @class: a valid #GObjectClass  | 
58  |  |  *   | 
59  |  |  * Casts a derived #GObjectClass structure into a #GObjectClass structure.  | 
60  |  |  */  | 
61  |  | #define G_OBJECT_CLASS(class)       (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))  | 
62  |  | /**  | 
63  |  |  * G_IS_OBJECT:  | 
64  |  |  * @object: Instance to check for being a %G_TYPE_OBJECT.  | 
65  |  |  *   | 
66  |  |  * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT.  | 
67  |  |  */  | 
68  |  | #if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_42  | 
69  |  | #define G_IS_OBJECT(object)         (G_TYPE_CHECK_INSTANCE_FUNDAMENTAL_TYPE ((object), G_TYPE_OBJECT))  | 
70  |  | #else  | 
71  |  | #define G_IS_OBJECT(object)         (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))  | 
72  |  | #endif  | 
73  |  | /**  | 
74  |  |  * G_IS_OBJECT_CLASS:  | 
75  |  |  * @class: a #GObjectClass  | 
76  |  |  *   | 
77  |  |  * Checks whether @class "is a" valid #GObjectClass structure of type  | 
78  |  |  * %G_TYPE_OBJECT or derived.  | 
79  |  |  */  | 
80  |  | #define G_IS_OBJECT_CLASS(class)    (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))  | 
81  |  | /**  | 
82  |  |  * G_OBJECT_GET_CLASS:  | 
83  |  |  * @object: a #GObject instance.  | 
84  |  |  *   | 
85  |  |  * Get the class structure associated to a #GObject instance.  | 
86  |  |  *  | 
87  |  |  * Returns: pointer to object class structure.  | 
88  |  |  */  | 
89  |  | #define G_OBJECT_GET_CLASS(object)  (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))  | 
90  |  | /**  | 
91  |  |  * G_OBJECT_TYPE:  | 
92  |  |  * @object: Object to return the type id for.  | 
93  |  |  *   | 
94  |  |  * Get the type id of an object.  | 
95  |  |  *   | 
96  |  |  * Returns: Type id of @object.  | 
97  |  |  */  | 
98  |  | #define G_OBJECT_TYPE(object)       (G_TYPE_FROM_INSTANCE (object))  | 
99  |  | /**  | 
100  |  |  * G_OBJECT_TYPE_NAME:  | 
101  |  |  * @object: Object to return the type name for.  | 
102  |  |  *   | 
103  |  |  * Get the name of an object's type.  | 
104  |  |  *   | 
105  |  |  * Returns: Type name of @object. The string is owned by the type system and   | 
106  |  |  *  should not be freed.  | 
107  |  |  */  | 
108  |  | #define G_OBJECT_TYPE_NAME(object)  (g_type_name (G_OBJECT_TYPE (object)))  | 
109  |  | /**  | 
110  |  |  * G_OBJECT_CLASS_TYPE:  | 
111  |  |  * @class: a valid #GObjectClass  | 
112  |  |  *   | 
113  |  |  * Get the type id of a class structure.  | 
114  |  |  *   | 
115  |  |  * Returns: Type id of @class.  | 
116  |  |  */  | 
117  |  | #define G_OBJECT_CLASS_TYPE(class)  (G_TYPE_FROM_CLASS (class))  | 
118  |  | /**  | 
119  |  |  * G_OBJECT_CLASS_NAME:  | 
120  |  |  * @class: a valid #GObjectClass  | 
121  |  |  *   | 
122  |  |  * Return the name of a class structure's type.  | 
123  |  |  *   | 
124  |  |  * Returns: Type name of @class. The string is owned by the type system and   | 
125  |  |  *  should not be freed.  | 
126  |  |  */  | 
127  |  | #define G_OBJECT_CLASS_NAME(class)  (g_type_name (G_OBJECT_CLASS_TYPE (class)))  | 
128  |  | /**  | 
129  |  |  * G_VALUE_HOLDS_OBJECT:  | 
130  |  |  * @value: a valid #GValue structure  | 
131  |  |  *   | 
132  |  |  * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT.  | 
133  |  |  *   | 
134  |  |  * Returns: %TRUE on success.  | 
135  |  |  */  | 
136  |  | #define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))  | 
137  |  |  | 
138  |  | /* --- type macros --- */  | 
139  |  | /**  | 
140  |  |  * G_TYPE_INITIALLY_UNOWNED:  | 
141  |  |  *   | 
142  |  |  * The type for #GInitiallyUnowned.  | 
143  |  |  */  | 
144  |  | #define G_TYPE_INITIALLY_UNOWNED        (g_initially_unowned_get_type())  | 
145  |  | /**  | 
146  |  |  * G_INITIALLY_UNOWNED:  | 
147  |  |  * @object: Object which is subject to casting.  | 
148  |  |  *   | 
149  |  |  * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*)   | 
150  |  |  * pointer.  | 
151  |  |  *  | 
152  |  |  * Depending on the current debugging level, this function may invoke  | 
153  |  |  * certain runtime checks to identify invalid casts.  | 
154  |  |  */  | 
155  |  | #define G_INITIALLY_UNOWNED(object)           (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))  | 
156  |  | /**  | 
157  |  |  * G_INITIALLY_UNOWNED_CLASS:  | 
158  |  |  * @class: a valid #GInitiallyUnownedClass  | 
159  |  |  *   | 
160  |  |  * Casts a derived #GInitiallyUnownedClass structure into a  | 
161  |  |  * #GInitiallyUnownedClass structure.  | 
162  |  |  */  | 
163  |  | #define G_INITIALLY_UNOWNED_CLASS(class)      (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))  | 
164  |  | /**  | 
165  |  |  * G_IS_INITIALLY_UNOWNED:  | 
166  |  |  * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED.  | 
167  |  |  *   | 
168  |  |  * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED.  | 
169  |  |  */  | 
170  |  | #define G_IS_INITIALLY_UNOWNED(object)        (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))  | 
171  |  | /**  | 
172  |  |  * G_IS_INITIALLY_UNOWNED_CLASS:  | 
173  |  |  * @class: a #GInitiallyUnownedClass  | 
174  |  |  *   | 
175  |  |  * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type  | 
176  |  |  * %G_TYPE_INITIALLY_UNOWNED or derived.  | 
177  |  |  */  | 
178  |  | #define G_IS_INITIALLY_UNOWNED_CLASS(class)   (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))  | 
179  |  | /**  | 
180  |  |  * G_INITIALLY_UNOWNED_GET_CLASS:  | 
181  |  |  * @object: a #GInitiallyUnowned instance.  | 
182  |  |  *   | 
183  |  |  * Get the class structure associated to a #GInitiallyUnowned instance.  | 
184  |  |  *  | 
185  |  |  * Returns: pointer to object class structure.  | 
186  |  |  */  | 
187  |  | #define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))  | 
188  |  | /* GInitiallyUnowned ia a GObject with initially floating reference count */  | 
189  |  |  | 
190  |  |  | 
191  |  | /* --- typedefs & structures --- */  | 
192  |  | typedef struct _GObject                  GObject;  | 
193  |  | typedef struct _GObjectClass             GObjectClass;  | 
194  |  | typedef struct _GObject                  GInitiallyUnowned;  | 
195  |  | typedef struct _GObjectClass             GInitiallyUnownedClass;  | 
196  |  | typedef struct _GObjectConstructParam    GObjectConstructParam;  | 
197  |  | /**  | 
198  |  |  * GObjectGetPropertyFunc:  | 
199  |  |  * @object: a #GObject  | 
200  |  |  * @property_id: the numeric id under which the property was registered with  | 
201  |  |  *  g_object_class_install_property().  | 
202  |  |  * @value: a #GValue to return the property value in  | 
203  |  |  * @pspec: the #GParamSpec describing the property  | 
204  |  |  *   | 
205  |  |  * The type of the @get_property function of #GObjectClass.   | 
206  |  |  */  | 
207  |  | typedef void (*GObjectGetPropertyFunc)  (GObject      *object,  | 
208  |  |                                          guint         property_id,  | 
209  |  |                                          GValue       *value,  | 
210  |  |                                          GParamSpec   *pspec);  | 
211  |  | /**  | 
212  |  |  * GObjectSetPropertyFunc:  | 
213  |  |  * @object: a #GObject  | 
214  |  |  * @property_id: the numeric id under which the property was registered with  | 
215  |  |  *  g_object_class_install_property().  | 
216  |  |  * @value: the new value for the property  | 
217  |  |  * @pspec: the #GParamSpec describing the property  | 
218  |  |  *   | 
219  |  |  * The type of the @set_property function of #GObjectClass.   | 
220  |  |  */  | 
221  |  | typedef void (*GObjectSetPropertyFunc)  (GObject      *object,  | 
222  |  |                                          guint         property_id,  | 
223  |  |                                          const GValue *value,  | 
224  |  |                                          GParamSpec   *pspec);  | 
225  |  | /**  | 
226  |  |  * GObjectFinalizeFunc:  | 
227  |  |  * @object: the #GObject being finalized  | 
228  |  |  *   | 
229  |  |  * The type of the @finalize function of #GObjectClass.  | 
230  |  |  */  | 
231  |  | typedef void (*GObjectFinalizeFunc)     (GObject      *object);  | 
232  |  | /**  | 
233  |  |  * GWeakNotify:  | 
234  |  |  * @data: data that was provided when the weak reference was established  | 
235  |  |  * @where_the_object_was: the object being disposed  | 
236  |  |  *   | 
237  |  |  * A #GWeakNotify function can be added to an object as a callback that gets  | 
238  |  |  * triggered when the object is finalized.  | 
239  |  |  *  | 
240  |  |  * Since the object is already being disposed when the #GWeakNotify is called,  | 
241  |  |  * there's not much you could do with the object, apart from e.g. using its  | 
242  |  |  * address as hash-index or the like.  | 
243  |  |  *  | 
244  |  |  * In particular, this means it’s invalid to call g_object_ref(),  | 
245  |  |  * g_weak_ref_init(), g_weak_ref_set(), g_object_add_toggle_ref(),  | 
246  |  |  * g_object_weak_ref(), g_object_add_weak_pointer() or any function which calls  | 
247  |  |  * them on the object from this callback.  | 
248  |  |  */  | 
249  |  | typedef void (*GWeakNotify)   (gpointer      data,  | 
250  |  |            GObject      *where_the_object_was);  | 
251  |  |  | 
252  |  | struct  _GObject  | 
253  |  | { | 
254  |  |   GTypeInstance  g_type_instance;  | 
255  |  |     | 
256  |  |   /*< private >*/  | 
257  |  |   guint          ref_count;  /* (atomic) */  | 
258  |  |   GData         *qdata;  | 
259  |  | };  | 
260  |  | /**  | 
261  |  |  * GObjectClass:  | 
262  |  |  * @g_type_class: the parent class  | 
263  |  |  * @constructor: the @constructor function is called by g_object_new () to   | 
264  |  |  *  complete the object initialization after all the construction properties are  | 
265  |  |  *  set. The first thing a @constructor implementation must do is chain up to the  | 
266  |  |  *  @constructor of the parent class. Overriding @constructor should be rarely   | 
267  |  |  *  needed, e.g. to handle construct properties, or to implement singletons.  | 
268  |  |  * @set_property: the generic setter for all properties of this type. Should be  | 
269  |  |  *  overridden for every type with properties. If implementations of  | 
270  |  |  *  @set_property don't emit property change notification explicitly, this will  | 
271  |  |  *  be done implicitly by the type system. However, if the notify signal is  | 
272  |  |  *  emitted explicitly, the type system will not emit it a second time.  | 
273  |  |  * @get_property: the generic getter for all properties of this type. Should be  | 
274  |  |  *  overridden for every type with properties.  | 
275  |  |  * @dispose: the @dispose function is supposed to drop all references to other   | 
276  |  |  *  objects, but keep the instance otherwise intact, so that client method   | 
277  |  |  *  invocations still work. It may be run multiple times (due to reference   | 
278  |  |  *  loops). Before returning, @dispose should chain up to the @dispose method   | 
279  |  |  *  of the parent class.  | 
280  |  |  * @finalize: instance finalization function, should finish the finalization of   | 
281  |  |  *  the instance begun in @dispose and chain up to the @finalize method of the   | 
282  |  |  *  parent class.  | 
283  |  |  * @dispatch_properties_changed: emits property change notification for a bunch  | 
284  |  |  *  of properties. Overriding @dispatch_properties_changed should be rarely   | 
285  |  |  *  needed.  | 
286  |  |  * @notify: the class closure for the notify signal  | 
287  |  |  * @constructed: the @constructed function is called by g_object_new() as the  | 
288  |  |  *  final step of the object creation process.  At the point of the call, all  | 
289  |  |  *  construction properties have been set on the object.  The purpose of this  | 
290  |  |  *  call is to allow for object initialisation steps that can only be performed  | 
291  |  |  *  after construction properties have been set.  @constructed implementors  | 
292  |  |  *  should chain up to the @constructed call of their parent class to allow it  | 
293  |  |  *  to complete its initialisation.  | 
294  |  |  *   | 
295  |  |  * The class structure for the GObject type.  | 
296  |  |  *   | 
297  |  |  * |[<!-- language="C" -->  | 
298  |  |  * // Example of implementing a singleton using a constructor.  | 
299  |  |  * static MySingleton *the_singleton = NULL;  | 
300  |  |  *   | 
301  |  |  * static GObject*  | 
302  |  |  * my_singleton_constructor (GType                  type,  | 
303  |  |  *                           guint                  n_construct_params,  | 
304  |  |  *                           GObjectConstructParam *construct_params)  | 
305  |  |  * { | 
306  |  |  *   GObject *object;  | 
307  |  |  *     | 
308  |  |  *   if (!the_singleton)  | 
309  |  |  *     { | 
310  |  |  *       object = G_OBJECT_CLASS (parent_class)->constructor (type,  | 
311  |  |  *                                                            n_construct_params,  | 
312  |  |  *                                                            construct_params);  | 
313  |  |  *       the_singleton = MY_SINGLETON (object);  | 
314  |  |  *     }  | 
315  |  |  *   else  | 
316  |  |  *     object = g_object_ref (G_OBJECT (the_singleton));  | 
317  |  |  *   | 
318  |  |  *   return object;  | 
319  |  |  * }  | 
320  |  |  * ]|  | 
321  |  |  */  | 
322  |  | struct  _GObjectClass  | 
323  |  | { | 
324  |  |   GTypeClass   g_type_class;  | 
325  |  |  | 
326  |  |   /*< private >*/  | 
327  |  |   GSList      *construct_properties;  | 
328  |  |  | 
329  |  |   /*< public >*/  | 
330  |  |   /* seldom overridden */  | 
331  |  |   GObject*   (*constructor)     (GType                  type,  | 
332  |  |                                  guint                  n_construct_properties,  | 
333  |  |                                  GObjectConstructParam *construct_properties);  | 
334  |  |   /* overridable methods */  | 
335  |  |   void       (*set_property)    (GObject        *object,  | 
336  |  |                                          guint           property_id,  | 
337  |  |                                          const GValue   *value,  | 
338  |  |                                          GParamSpec     *pspec);  | 
339  |  |   void       (*get_property)    (GObject        *object,  | 
340  |  |                                          guint           property_id,  | 
341  |  |                                          GValue         *value,  | 
342  |  |                                          GParamSpec     *pspec);  | 
343  |  |   void       (*dispose)     (GObject        *object);  | 
344  |  |   void       (*finalize)    (GObject        *object);  | 
345  |  |   /* seldom overridden */  | 
346  |  |   void       (*dispatch_properties_changed) (GObject      *object,  | 
347  |  |                guint     n_pspecs,  | 
348  |  |                GParamSpec  **pspecs);  | 
349  |  |   /* signals */  | 
350  |  |   void       (*notify)      (GObject  *object,  | 
351  |  |            GParamSpec *pspec);  | 
352  |  |  | 
353  |  |   /* called when done constructing */  | 
354  |  |   void       (*constructed)   (GObject  *object);  | 
355  |  |  | 
356  |  |   /*< private >*/  | 
357  |  |   gsize   flags;  | 
358  |  |  | 
359  |  |   gsize         n_construct_properties;  | 
360  |  |  | 
361  |  |   gpointer pspecs;  | 
362  |  |   gsize n_pspecs;  | 
363  |  |  | 
364  |  |   /* padding */  | 
365  |  |   gpointer  pdummy[3];  | 
366  |  | };  | 
367  |  |  | 
368  |  | /**  | 
369  |  |  * GObjectConstructParam:  | 
370  |  |  * @pspec: the #GParamSpec of the construct parameter  | 
371  |  |  * @value: the value to set the parameter to  | 
372  |  |  *   | 
373  |  |  * The GObjectConstructParam struct is an auxiliary structure used to hand  | 
374  |  |  * #GParamSpec/#GValue pairs to the @constructor of a #GObjectClass.  | 
375  |  |  */  | 
376  |  | struct _GObjectConstructParam  | 
377  |  | { | 
378  |  |   GParamSpec *pspec;  | 
379  |  |   GValue     *value;  | 
380  |  | };  | 
381  |  |  | 
382  |  | /**  | 
383  |  |  * GInitiallyUnowned:  | 
384  |  |  *  | 
385  |  |  * A type for objects that have an initially floating reference.  | 
386  |  |  *   | 
387  |  |  * All the fields in the `GInitiallyUnowned` structure are private to the  | 
388  |  |  * implementation and should never be accessed directly.  | 
389  |  |  */  | 
390  |  | /**  | 
391  |  |  * GInitiallyUnownedClass:  | 
392  |  |  *   | 
393  |  |  * The class structure for the GInitiallyUnowned type.  | 
394  |  |  */  | 
395  |  |  | 
396  |  |  | 
397  |  | /* --- prototypes --- */  | 
398  |  | GOBJECT_AVAILABLE_IN_ALL  | 
399  |  | GType       g_initially_unowned_get_type      (void);  | 
400  |  | GOBJECT_AVAILABLE_IN_ALL  | 
401  |  | void        g_object_class_install_property   (GObjectClass   *oclass,  | 
402  |  |                  guint           property_id,  | 
403  |  |                  GParamSpec     *pspec);  | 
404  |  | GOBJECT_AVAILABLE_IN_ALL  | 
405  |  | GParamSpec* g_object_class_find_property      (GObjectClass   *oclass,  | 
406  |  |                  const gchar    *property_name);  | 
407  |  | GOBJECT_AVAILABLE_IN_ALL  | 
408  |  | GParamSpec**g_object_class_list_properties    (GObjectClass   *oclass,  | 
409  |  |                  guint        *n_properties);  | 
410  |  | GOBJECT_AVAILABLE_IN_ALL  | 
411  |  | void        g_object_class_override_property  (GObjectClass   *oclass,  | 
412  |  |                  guint           property_id,  | 
413  |  |                  const gchar    *name);  | 
414  |  | GOBJECT_AVAILABLE_IN_ALL  | 
415  |  | void        g_object_class_install_properties (GObjectClass   *oclass,  | 
416  |  |                                                guint           n_pspecs,  | 
417  |  |                                                GParamSpec    **pspecs);  | 
418  |  |  | 
419  |  | GOBJECT_AVAILABLE_IN_ALL  | 
420  |  | void        g_object_interface_install_property (gpointer     g_iface,  | 
421  |  |              GParamSpec  *pspec);  | 
422  |  | GOBJECT_AVAILABLE_IN_ALL  | 
423  |  | GParamSpec* g_object_interface_find_property    (gpointer     g_iface,  | 
424  |  |              const gchar *property_name);  | 
425  |  | GOBJECT_AVAILABLE_IN_ALL  | 
426  |  | GParamSpec**g_object_interface_list_properties  (gpointer     g_iface,  | 
427  |  |              guint       *n_properties_p);  | 
428  |  |  | 
429  |  | GOBJECT_AVAILABLE_IN_ALL  | 
430  |  | GType       g_object_get_type                 (void) G_GNUC_CONST;  | 
431  |  | GOBJECT_AVAILABLE_IN_ALL  | 
432  |  | gpointer    g_object_new                      (GType           object_type,  | 
433  |  |                  const gchar    *first_property_name,  | 
434  |  |                  ...);  | 
435  |  | GOBJECT_AVAILABLE_IN_2_54  | 
436  |  | GObject*    g_object_new_with_properties      (GType           object_type,  | 
437  |  |                                                guint           n_properties,  | 
438  |  |                                                const char     *names[],  | 
439  |  |                                                const GValue    values[]);  | 
440  |  |  | 
441  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
442  |  |  | 
443  |  | GOBJECT_DEPRECATED_IN_2_54_FOR(g_object_new_with_properties)  | 
444  |  | gpointer    g_object_newv         (GType           object_type,  | 
445  |  |                  guint         n_parameters,  | 
446  |  |                  GParameter     *parameters);  | 
447  |  |  | 
448  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
449  |  |  | 
450  |  | GOBJECT_AVAILABLE_IN_ALL  | 
451  |  | GObject*    g_object_new_valist               (GType           object_type,  | 
452  |  |                  const gchar    *first_property_name,  | 
453  |  |                  va_list         var_args);  | 
454  |  | GOBJECT_AVAILABLE_IN_ALL  | 
455  |  | void      g_object_set                      (gpointer        object,  | 
456  |  |                  const gchar    *first_property_name,  | 
457  |  |                  ...) G_GNUC_NULL_TERMINATED;  | 
458  |  | GOBJECT_AVAILABLE_IN_ALL  | 
459  |  | void        g_object_get                      (gpointer        object,  | 
460  |  |                  const gchar    *first_property_name,  | 
461  |  |                  ...) G_GNUC_NULL_TERMINATED;  | 
462  |  | GOBJECT_AVAILABLE_IN_ALL  | 
463  |  | gpointer    g_object_connect                  (gpointer        object,  | 
464  |  |                  const gchar    *signal_spec,  | 
465  |  |                  ...) G_GNUC_NULL_TERMINATED;  | 
466  |  | GOBJECT_AVAILABLE_IN_ALL  | 
467  |  | void      g_object_disconnect               (gpointer        object,  | 
468  |  |                  const gchar    *signal_spec,  | 
469  |  |                  ...) G_GNUC_NULL_TERMINATED;  | 
470  |  | GOBJECT_AVAILABLE_IN_2_54  | 
471  |  | void        g_object_setv                     (GObject        *object,  | 
472  |  |                                                guint           n_properties,  | 
473  |  |                                                const gchar    *names[],  | 
474  |  |                                                const GValue    values[]);  | 
475  |  | GOBJECT_AVAILABLE_IN_ALL  | 
476  |  | void        g_object_set_valist               (GObject        *object,  | 
477  |  |                  const gchar    *first_property_name,  | 
478  |  |                  va_list         var_args);  | 
479  |  | GOBJECT_AVAILABLE_IN_2_54  | 
480  |  | void        g_object_getv                     (GObject        *object,  | 
481  |  |                                                guint           n_properties,  | 
482  |  |                                                const gchar    *names[],  | 
483  |  |                                                GValue          values[]);  | 
484  |  | GOBJECT_AVAILABLE_IN_ALL  | 
485  |  | void        g_object_get_valist               (GObject        *object,  | 
486  |  |                  const gchar    *first_property_name,  | 
487  |  |                  va_list         var_args);  | 
488  |  | GOBJECT_AVAILABLE_IN_ALL  | 
489  |  | void        g_object_set_property             (GObject        *object,  | 
490  |  |                  const gchar    *property_name,  | 
491  |  |                  const GValue   *value);  | 
492  |  | GOBJECT_AVAILABLE_IN_ALL  | 
493  |  | void        g_object_get_property             (GObject        *object,  | 
494  |  |                  const gchar    *property_name,  | 
495  |  |                  GValue         *value);  | 
496  |  | GOBJECT_AVAILABLE_IN_ALL  | 
497  |  | void        g_object_freeze_notify            (GObject        *object);  | 
498  |  | GOBJECT_AVAILABLE_IN_ALL  | 
499  |  | void        g_object_notify                   (GObject        *object,  | 
500  |  |                  const gchar    *property_name);  | 
501  |  | GOBJECT_AVAILABLE_IN_ALL  | 
502  |  | void        g_object_notify_by_pspec          (GObject        *object,  | 
503  |  |                  GParamSpec     *pspec);  | 
504  |  | GOBJECT_AVAILABLE_IN_ALL  | 
505  |  | void        g_object_thaw_notify              (GObject        *object);  | 
506  |  | GOBJECT_AVAILABLE_IN_ALL  | 
507  |  | gboolean    g_object_is_floating            (gpointer        object);  | 
508  |  | GOBJECT_AVAILABLE_IN_ALL  | 
509  |  | gpointer    g_object_ref_sink               (gpointer        object);  | 
510  |  | GOBJECT_AVAILABLE_IN_2_70  | 
511  |  | gpointer    g_object_take_ref                 (gpointer        object);  | 
512  |  | GOBJECT_AVAILABLE_IN_ALL  | 
513  |  | gpointer    g_object_ref                      (gpointer        object);  | 
514  |  | GOBJECT_AVAILABLE_IN_ALL  | 
515  |  | void        g_object_unref                    (gpointer        object);  | 
516  |  | GOBJECT_AVAILABLE_IN_ALL  | 
517  |  | void      g_object_weak_ref         (GObject        *object,  | 
518  |  |                  GWeakNotify     notify,  | 
519  |  |                  gpointer        data);  | 
520  |  | GOBJECT_AVAILABLE_IN_ALL  | 
521  |  | void      g_object_weak_unref         (GObject        *object,  | 
522  |  |                  GWeakNotify     notify,  | 
523  |  |                  gpointer        data);  | 
524  |  | GOBJECT_AVAILABLE_IN_ALL  | 
525  |  | void        g_object_add_weak_pointer         (GObject        *object,   | 
526  |  |                                                gpointer       *weak_pointer_location);  | 
527  |  | GOBJECT_AVAILABLE_IN_ALL  | 
528  |  | void        g_object_remove_weak_pointer      (GObject        *object,   | 
529  |  |                                                gpointer       *weak_pointer_location);  | 
530  |  |  | 
531  |  | #if defined(glib_typeof) && GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_56  | 
532  |  | /* Make reference APIs type safe with macros */  | 
533  |  | #define g_object_ref(Obj) ((glib_typeof (Obj)) (g_object_ref) (Obj))  | 
534  |  | #define g_object_ref_sink(Obj) ((glib_typeof (Obj)) (g_object_ref_sink) (Obj))  | 
535  |  | #endif  | 
536  |  |  | 
537  |  | /**  | 
538  |  |  * GToggleNotify:  | 
539  |  |  * @data: Callback data passed to g_object_add_toggle_ref()  | 
540  |  |  * @object: The object on which g_object_add_toggle_ref() was called.  | 
541  |  |  * @is_last_ref: %TRUE if the toggle reference is now the  | 
542  |  |  *  last reference to the object. %FALSE if the toggle  | 
543  |  |  *  reference was the last reference and there are now other  | 
544  |  |  *  references.  | 
545  |  |  *   | 
546  |  |  * A callback function used for notification when the state  | 
547  |  |  * of a toggle reference changes.  | 
548  |  |  *  | 
549  |  |  * See also: g_object_add_toggle_ref()  | 
550  |  |  */  | 
551  |  | typedef void (*GToggleNotify) (gpointer      data,  | 
552  |  |              GObject      *object,  | 
553  |  |              gboolean      is_last_ref);  | 
554  |  |  | 
555  |  | GOBJECT_AVAILABLE_IN_ALL  | 
556  |  | void g_object_add_toggle_ref    (GObject       *object,  | 
557  |  |          GToggleNotify  notify,  | 
558  |  |          gpointer       data);  | 
559  |  | GOBJECT_AVAILABLE_IN_ALL  | 
560  |  | void g_object_remove_toggle_ref (GObject       *object,  | 
561  |  |          GToggleNotify  notify,  | 
562  |  |          gpointer       data);  | 
563  |  |  | 
564  |  | GOBJECT_AVAILABLE_IN_ALL  | 
565  |  | gpointer    g_object_get_qdata                (GObject        *object,  | 
566  |  |                  GQuark          quark);  | 
567  |  | GOBJECT_AVAILABLE_IN_ALL  | 
568  |  | void        g_object_set_qdata                (GObject        *object,  | 
569  |  |                  GQuark          quark,  | 
570  |  |                  gpointer        data);  | 
571  |  | GOBJECT_AVAILABLE_IN_ALL  | 
572  |  | void        g_object_set_qdata_full           (GObject        *object,  | 
573  |  |                  GQuark          quark,  | 
574  |  |                  gpointer        data,  | 
575  |  |                  GDestroyNotify  destroy);  | 
576  |  | GOBJECT_AVAILABLE_IN_ALL  | 
577  |  | gpointer    g_object_steal_qdata              (GObject        *object,  | 
578  |  |                  GQuark          quark);  | 
579  |  |  | 
580  |  | GOBJECT_AVAILABLE_IN_2_34  | 
581  |  | gpointer    g_object_dup_qdata                (GObject        *object,  | 
582  |  |                                                GQuark          quark,  | 
583  |  |                                                GDuplicateFunc  dup_func,  | 
584  |  |                  gpointer         user_data);  | 
585  |  | GOBJECT_AVAILABLE_IN_2_34  | 
586  |  | gboolean    g_object_replace_qdata            (GObject        *object,  | 
587  |  |                                                GQuark          quark,  | 
588  |  |                                                gpointer        oldval,  | 
589  |  |                                                gpointer        newval,  | 
590  |  |                                                GDestroyNotify  destroy,  | 
591  |  |                  GDestroyNotify *old_destroy);  | 
592  |  |  | 
593  |  | GOBJECT_AVAILABLE_IN_ALL  | 
594  |  | gpointer    g_object_get_data                 (GObject        *object,  | 
595  |  |                  const gchar    *key);  | 
596  |  | GOBJECT_AVAILABLE_IN_ALL  | 
597  |  | void        g_object_set_data                 (GObject        *object,  | 
598  |  |                  const gchar    *key,  | 
599  |  |                  gpointer        data);  | 
600  |  | GOBJECT_AVAILABLE_IN_ALL  | 
601  |  | void        g_object_set_data_full            (GObject        *object,  | 
602  |  |                  const gchar    *key,  | 
603  |  |                  gpointer        data,  | 
604  |  |                  GDestroyNotify  destroy);  | 
605  |  | GOBJECT_AVAILABLE_IN_ALL  | 
606  |  | gpointer    g_object_steal_data               (GObject        *object,  | 
607  |  |                  const gchar    *key);  | 
608  |  |  | 
609  |  | GOBJECT_AVAILABLE_IN_2_34  | 
610  |  | gpointer    g_object_dup_data                 (GObject        *object,  | 
611  |  |                                                const gchar    *key,  | 
612  |  |                                                GDuplicateFunc  dup_func,  | 
613  |  |                  gpointer         user_data);  | 
614  |  | GOBJECT_AVAILABLE_IN_2_34  | 
615  |  | gboolean    g_object_replace_data             (GObject        *object,  | 
616  |  |                                                const gchar    *key,  | 
617  |  |                                                gpointer        oldval,  | 
618  |  |                                                gpointer        newval,  | 
619  |  |                                                GDestroyNotify  destroy,  | 
620  |  |                  GDestroyNotify *old_destroy);  | 
621  |  |  | 
622  |  |  | 
623  |  | GOBJECT_AVAILABLE_IN_ALL  | 
624  |  | void        g_object_watch_closure            (GObject        *object,  | 
625  |  |                  GClosure       *closure);  | 
626  |  | GOBJECT_AVAILABLE_IN_ALL  | 
627  |  | GClosure*   g_cclosure_new_object             (GCallback       callback_func,  | 
628  |  |                  GObject        *object);  | 
629  |  | GOBJECT_AVAILABLE_IN_ALL  | 
630  |  | GClosure*   g_cclosure_new_object_swap        (GCallback       callback_func,  | 
631  |  |                  GObject        *object);  | 
632  |  | GOBJECT_AVAILABLE_IN_ALL  | 
633  |  | GClosure*   g_closure_new_object              (guint           sizeof_closure,  | 
634  |  |                  GObject        *object);  | 
635  |  | GOBJECT_AVAILABLE_IN_ALL  | 
636  |  | void        g_value_set_object                (GValue         *value,  | 
637  |  |                  gpointer        v_object);  | 
638  |  | GOBJECT_AVAILABLE_IN_ALL  | 
639  |  | gpointer    g_value_get_object                (const GValue   *value);  | 
640  |  | GOBJECT_AVAILABLE_IN_ALL  | 
641  |  | gpointer    g_value_dup_object                (const GValue   *value);  | 
642  |  | GOBJECT_AVAILABLE_IN_ALL  | 
643  |  | gulong      g_signal_connect_object           (gpointer        instance,  | 
644  |  |                  const gchar    *detailed_signal,  | 
645  |  |                  GCallback       c_handler,  | 
646  |  |                  gpointer        gobject,  | 
647  |  |                  GConnectFlags   connect_flags);  | 
648  |  |  | 
649  |  | /*< protected >*/  | 
650  |  | GOBJECT_AVAILABLE_IN_ALL  | 
651  |  | void        g_object_force_floating           (GObject        *object);  | 
652  |  | GOBJECT_AVAILABLE_IN_ALL  | 
653  |  | void        g_object_run_dispose        (GObject        *object);  | 
654  |  |  | 
655  |  |  | 
656  |  | GOBJECT_AVAILABLE_IN_ALL  | 
657  |  | void        g_value_take_object               (GValue         *value,  | 
658  |  |                  gpointer        v_object);  | 
659  |  | GOBJECT_DEPRECATED_FOR(g_value_take_object)  | 
660  |  | void        g_value_set_object_take_ownership (GValue         *value,  | 
661  |  |                                                gpointer        v_object);  | 
662  |  |  | 
663  |  | GOBJECT_DEPRECATED  | 
664  |  | gsize     g_object_compat_control       (gsize         what,  | 
665  |  |                  gpointer        data);  | 
666  |  |  | 
667  |  | /* --- implementation macros --- */  | 
668  |  | #define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \  | 
669  |  | G_STMT_START { \ | 
670  |  |   GObject *_glib__object = (GObject*) (object); \  | 
671  |  |   GParamSpec *_glib__pspec = (GParamSpec*) (pspec); \  | 
672  |  |   guint _glib__property_id = (property_id); \  | 
673  |  |   g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'", \ | 
674  |  |              __FILE__, __LINE__, \  | 
675  |  |              (pname), \  | 
676  |  |              _glib__property_id, \  | 
677  |  |              _glib__pspec->name, \  | 
678  |  |              g_type_name (G_PARAM_SPEC_TYPE (_glib__pspec)), \  | 
679  |  |              G_OBJECT_TYPE_NAME (_glib__object)); \  | 
680  |  | } G_STMT_END  | 
681  |  | /**  | 
682  |  |  * G_OBJECT_WARN_INVALID_PROPERTY_ID:  | 
683  |  |  * @object: the #GObject on which set_property() or get_property() was called  | 
684  |  |  * @property_id: the numeric id of the property  | 
685  |  |  * @pspec: the #GParamSpec of the property  | 
686  |  |  *   | 
687  |  |  * This macro should be used to emit a standard warning about unexpected   | 
688  |  |  * properties in set_property() and get_property() implementations.  | 
689  |  |  */  | 
690  |  | #define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \  | 
691  |  |     G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec))  | 
692  |  |  | 
693  |  | GOBJECT_AVAILABLE_IN_ALL  | 
694  |  | void    g_clear_object (GObject **object_ptr);  | 
695  |  | #define g_clear_object(object_ptr) g_clear_pointer ((object_ptr), g_object_unref)  | 
696  |  |  | 
697  |  | /**  | 
698  |  |  * g_set_object: (skip)  | 
699  |  |  * @object_ptr: (inout) (not optional) (nullable): a pointer to a #GObject reference  | 
700  |  |  * @new_object: (nullable) (transfer none): a pointer to the new #GObject to  | 
701  |  |  *   assign to @object_ptr, or %NULL to clear the pointer  | 
702  |  |  *  | 
703  |  |  * Updates a #GObject pointer to refer to @new_object.  | 
704  |  |  *  | 
705  |  |  * It increments the reference count of @new_object (if non-%NULL), decrements  | 
706  |  |  * the reference count of the current value of @object_ptr (if non-%NULL), and  | 
707  |  |  * assigns @new_object to @object_ptr. The assignment is not atomic.  | 
708  |  |  *  | 
709  |  |  * @object_ptr must not be %NULL, but can point to a %NULL value.  | 
710  |  |  *  | 
711  |  |  * A macro is also included that allows this function to be used without  | 
712  |  |  * pointer casts. The function itself is static inline, so its address may vary  | 
713  |  |  * between compilation units.  | 
714  |  |  *  | 
715  |  |  * One convenient usage of this function is in implementing property setters:  | 
716  |  |  * |[  | 
717  |  |  *   void  | 
718  |  |  *   foo_set_bar (Foo *foo,  | 
719  |  |  *                Bar *new_bar)  | 
720  |  |  *   { | 
721  |  |  *     g_return_if_fail (IS_FOO (foo));  | 
722  |  |  *     g_return_if_fail (new_bar == NULL || IS_BAR (new_bar));  | 
723  |  |  *  | 
724  |  |  *     if (g_set_object (&foo->bar, new_bar))  | 
725  |  |  *       g_object_notify (foo, "bar");  | 
726  |  |  *   }  | 
727  |  |  * ]|  | 
728  |  |  *  | 
729  |  |  * Returns: %TRUE if the value of @object_ptr changed, %FALSE otherwise  | 
730  |  |  *  | 
731  |  |  * Since: 2.44  | 
732  |  |  */  | 
733  |  | static inline gboolean  | 
734  |  | (g_set_object) (GObject **object_ptr,  | 
735  |  |                 GObject  *new_object)  | 
736  | 0  | { | 
737  | 0  |   GObject *old_object = *object_ptr;  | 
738  | 0  | 
  | 
739  | 0  |   /* rely on g_object_[un]ref() to check the pointers are actually GObjects;  | 
740  | 0  |    * elide a (object_ptr != NULL) check because most of the time we will be  | 
741  | 0  |    * operating on struct members with a constant offset, so a NULL check would  | 
742  | 0  |    * not catch bugs  | 
743  | 0  |    */  | 
744  | 0  | 
  | 
745  | 0  |   if (old_object == new_object)  | 
746  | 0  |     return FALSE;  | 
747  | 0  | 
  | 
748  | 0  |   if (new_object != NULL)  | 
749  | 0  |     g_object_ref (new_object);  | 
750  | 0  | 
  | 
751  | 0  |   *object_ptr = new_object;  | 
752  | 0  | 
  | 
753  | 0  |   if (old_object != NULL)  | 
754  | 0  |     g_object_unref (old_object);  | 
755  | 0  | 
  | 
756  | 0  |   return TRUE;  | 
757  | 0  | }  | 
758  |  |  | 
759  |  | /* We need GCC for __extension__, which we need to sort out strict aliasing of @object_ptr */  | 
760  |  | #if defined(__GNUC__)  | 
761  |  |  | 
762  |  | #define g_set_object(object_ptr, new_object) \  | 
763  |  |   (G_GNUC_EXTENSION ({ \ | 
764  |  |     G_STATIC_ASSERT (sizeof *(object_ptr) == sizeof (new_object)); \  | 
765  |  |     /* Only one access, please; work around type aliasing */ \  | 
766  |  |     union { char *in; GObject **out; } _object_ptr; \ | 
767  |  |     _object_ptr.in = (char *) (object_ptr); \  | 
768  |  |     /* Check types match */ \  | 
769  |  |     (void) (0 ? *(object_ptr) = (new_object), FALSE : FALSE); \  | 
770  |  |     (g_set_object) (_object_ptr.out, (GObject *) new_object); \  | 
771  |  |   })) \  | 
772  |  |   GOBJECT_AVAILABLE_MACRO_IN_2_44  | 
773  |  |  | 
774  |  | #else  /* if !defined(__GNUC__) */  | 
775  |  |  | 
776  |  | #define g_set_object(object_ptr, new_object) \  | 
777  |  |  (/* Check types match. */ \  | 
778  |  |   0 ? *(object_ptr) = (new_object), FALSE : \  | 
779  |  |   (g_set_object) ((GObject **) (object_ptr), (GObject *) (new_object)) \  | 
780  |  |  )  | 
781  |  |  | 
782  |  | #endif  /* !defined(__GNUC__) */  | 
783  |  |  | 
784  |  | /**  | 
785  |  |  * g_assert_finalize_object: (skip)  | 
786  |  |  * @object: (transfer full) (type GObject.Object): an object  | 
787  |  |  *  | 
788  |  |  * Assert that @object is non-%NULL, then release one reference to it with  | 
789  |  |  * g_object_unref() and assert that it has been finalized (i.e. that there  | 
790  |  |  * are no more references).  | 
791  |  |  *  | 
792  |  |  * If assertions are disabled via `G_DISABLE_ASSERT`,  | 
793  |  |  * this macro just calls g_object_unref() without any further checks.  | 
794  |  |  *  | 
795  |  |  * This macro should only be used in regression tests.  | 
796  |  |  *  | 
797  |  |  * Since: 2.62  | 
798  |  |  */  | 
799  |  | static inline void  | 
800  |  | (g_assert_finalize_object) (GObject *object)  | 
801  | 0  | { | 
802  | 0  |   gpointer weak_pointer = object;  | 
803  | 0  | 
  | 
804  | 0  |   g_assert_true (G_IS_OBJECT (weak_pointer));  | 
805  | 0  |   g_object_add_weak_pointer (object, &weak_pointer);  | 
806  | 0  |   g_object_unref (weak_pointer);  | 
807  | 0  |   g_assert_null (weak_pointer);  | 
808  | 0  | }  | 
809  |  |  | 
810  |  | #ifdef G_DISABLE_ASSERT  | 
811  |  | #define g_assert_finalize_object(object) g_object_unref (object)  | 
812  |  | #else  | 
813  |  | #define g_assert_finalize_object(object) (g_assert_finalize_object ((GObject *) object))  | 
814  |  | #endif  | 
815  |  |  | 
816  |  | /**  | 
817  |  |  * g_clear_weak_pointer: (skip)  | 
818  |  |  * @weak_pointer_location: The memory address of a pointer  | 
819  |  |  *  | 
820  |  |  * Clears a weak reference to a #GObject.  | 
821  |  |  *  | 
822  |  |  * @weak_pointer_location must not be %NULL.  | 
823  |  |  *  | 
824  |  |  * If the weak reference is %NULL then this function does nothing.  | 
825  |  |  * Otherwise, the weak reference to the object is removed for that location  | 
826  |  |  * and the pointer is set to %NULL.  | 
827  |  |  *  | 
828  |  |  * A macro is also included that allows this function to be used without  | 
829  |  |  * pointer casts. The function itself is static inline, so its address may vary  | 
830  |  |  * between compilation units.  | 
831  |  |  *  | 
832  |  |  * Since: 2.56  | 
833  |  |  */  | 
834  |  | static inline void  | 
835  |  | (g_clear_weak_pointer) (gpointer *weak_pointer_location)  | 
836  | 0  | { | 
837  | 0  |   GObject *object = (GObject *) *weak_pointer_location;  | 
838  | 0  | 
  | 
839  | 0  |   if (object != NULL)  | 
840  | 0  |     { | 
841  | 0  |       g_object_remove_weak_pointer (object, weak_pointer_location);  | 
842  | 0  |       *weak_pointer_location = NULL;  | 
843  | 0  |     }  | 
844  | 0  | }  | 
845  |  |  | 
846  |  | #define g_clear_weak_pointer(weak_pointer_location) \  | 
847  |  |  (/* Check types match. */ \  | 
848  |  |   (g_clear_weak_pointer) ((gpointer *) (weak_pointer_location)) \  | 
849  |  |  )  | 
850  |  |  | 
851  |  | /**  | 
852  |  |  * g_set_weak_pointer: (skip)  | 
853  |  |  * @weak_pointer_location: the memory address of a pointer  | 
854  |  |  * @new_object: (nullable) (transfer none): a pointer to the new #GObject to  | 
855  |  |  *   assign to it, or %NULL to clear the pointer  | 
856  |  |  *  | 
857  |  |  * Updates a pointer to weakly refer to @new_object.  | 
858  |  |  *  | 
859  |  |  * It assigns @new_object to @weak_pointer_location and ensures  | 
860  |  |  * that @weak_pointer_location will automatically be set to %NULL  | 
861  |  |  * if @new_object gets destroyed. The assignment is not atomic.  | 
862  |  |  * The weak reference is not thread-safe, see g_object_add_weak_pointer()  | 
863  |  |  * for details.  | 
864  |  |  *  | 
865  |  |  * The @weak_pointer_location argument must not be %NULL.  | 
866  |  |  *  | 
867  |  |  * A macro is also included that allows this function to be used without  | 
868  |  |  * pointer casts. The function itself is static inline, so its address may vary  | 
869  |  |  * between compilation units.  | 
870  |  |  *  | 
871  |  |  * One convenient usage of this function is in implementing property setters:  | 
872  |  |  * |[  | 
873  |  |  *   void  | 
874  |  |  *   foo_set_bar (Foo *foo,  | 
875  |  |  *                Bar *new_bar)  | 
876  |  |  *   { | 
877  |  |  *     g_return_if_fail (IS_FOO (foo));  | 
878  |  |  *     g_return_if_fail (new_bar == NULL || IS_BAR (new_bar));  | 
879  |  |  *  | 
880  |  |  *     if (g_set_weak_pointer (&foo->bar, new_bar))  | 
881  |  |  *       g_object_notify (foo, "bar");  | 
882  |  |  *   }  | 
883  |  |  * ]|  | 
884  |  |  *  | 
885  |  |  * Returns: %TRUE if the value of @weak_pointer_location changed, %FALSE otherwise  | 
886  |  |  *  | 
887  |  |  * Since: 2.56  | 
888  |  |  */  | 
889  |  | static inline gboolean  | 
890  |  | (g_set_weak_pointer) (gpointer *weak_pointer_location,  | 
891  |  |                       GObject  *new_object)  | 
892  | 0  | { | 
893  | 0  |   GObject *old_object = (GObject *) *weak_pointer_location;  | 
894  | 0  | 
  | 
895  | 0  |   /* elide a (weak_pointer_location != NULL) check because most of the time we  | 
896  | 0  |    * will be operating on struct members with a constant offset, so a NULL  | 
897  | 0  |    * check would not catch bugs  | 
898  | 0  |    */  | 
899  | 0  | 
  | 
900  | 0  |   if (old_object == new_object)  | 
901  | 0  |     return FALSE;  | 
902  | 0  | 
  | 
903  | 0  |   if (old_object != NULL)  | 
904  | 0  |     g_object_remove_weak_pointer (old_object, weak_pointer_location);  | 
905  | 0  | 
  | 
906  | 0  |   *weak_pointer_location = new_object;  | 
907  | 0  | 
  | 
908  | 0  |   if (new_object != NULL)  | 
909  | 0  |     g_object_add_weak_pointer (new_object, weak_pointer_location);  | 
910  | 0  | 
  | 
911  | 0  |   return TRUE;  | 
912  | 0  | }  | 
913  |  |  | 
914  |  | #define g_set_weak_pointer(weak_pointer_location, new_object) \  | 
915  |  |  (/* Check types match. */ \  | 
916  |  |   0 ? *(weak_pointer_location) = (new_object), FALSE : \  | 
917  |  |   (g_set_weak_pointer) ((gpointer *) (weak_pointer_location), (GObject *) (new_object)) \  | 
918  |  |  )  | 
919  |  |  | 
920  |  | typedef struct { | 
921  |  |     /*<private>*/  | 
922  |  |     union { gpointer p; } priv; | 
923  |  | } GWeakRef;  | 
924  |  |  | 
925  |  | GOBJECT_AVAILABLE_IN_ALL  | 
926  |  | void     g_weak_ref_init       (GWeakRef *weak_ref,  | 
927  |  |                                 gpointer  object);  | 
928  |  | GOBJECT_AVAILABLE_IN_ALL  | 
929  |  | void     g_weak_ref_clear      (GWeakRef *weak_ref);  | 
930  |  | GOBJECT_AVAILABLE_IN_ALL  | 
931  |  | gpointer g_weak_ref_get        (GWeakRef *weak_ref);  | 
932  |  | GOBJECT_AVAILABLE_IN_ALL  | 
933  |  | void     g_weak_ref_set        (GWeakRef *weak_ref,  | 
934  |  |                                 gpointer  object);  | 
935  |  |  | 
936  |  | G_END_DECLS  | 
937  |  |  | 
938  |  | #endif /* __G_OBJECT_H__ */  |