williamr@2
|
1 |
/* GObject - GLib Type, Object, Parameter and Signal Library
|
williamr@2
|
2 |
* Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc.
|
williamr@2
|
3 |
* Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
|
williamr@2
|
4 |
*
|
williamr@2
|
5 |
* This library is free software; you can redistribute it and/or
|
williamr@2
|
6 |
* modify it under the terms of the GNU Lesser General Public
|
williamr@2
|
7 |
* License as published by the Free Software Foundation; either
|
williamr@2
|
8 |
* version 2 of the License, or (at your option) any later version.
|
williamr@2
|
9 |
*
|
williamr@2
|
10 |
* This library is distributed in the hope that it will be useful,
|
williamr@2
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
williamr@2
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
williamr@2
|
13 |
* Lesser General Public License for more details.
|
williamr@2
|
14 |
*
|
williamr@2
|
15 |
* You should have received a copy of the GNU Lesser General
|
williamr@2
|
16 |
* Public License along with this library; if not, write to the
|
williamr@2
|
17 |
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
williamr@2
|
18 |
* Boston, MA 02111-1307, USA.
|
williamr@2
|
19 |
*/
|
williamr@2
|
20 |
#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
|
williamr@2
|
21 |
#error "Only <glib-object.h> can be included directly."
|
williamr@2
|
22 |
#endif
|
williamr@2
|
23 |
|
williamr@2
|
24 |
#ifndef __G_OBJECT_H__
|
williamr@2
|
25 |
#define __G_OBJECT_H__
|
williamr@2
|
26 |
|
williamr@2
|
27 |
#include <_ansi.h>
|
williamr@2
|
28 |
#include <gobject/gtype.h>
|
williamr@2
|
29 |
#include <gobject/gvalue.h>
|
williamr@2
|
30 |
#include <gobject/gparam.h>
|
williamr@2
|
31 |
#include <gobject/gclosure.h>
|
williamr@2
|
32 |
#include <gobject/gsignal.h>
|
williamr@2
|
33 |
|
williamr@2
|
34 |
G_BEGIN_DECLS
|
williamr@2
|
35 |
|
williamr@2
|
36 |
/* --- type macros --- */
|
williamr@2
|
37 |
#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
|
williamr@2
|
38 |
#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
|
williamr@2
|
39 |
#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
|
williamr@2
|
40 |
#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
|
williamr@2
|
41 |
#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
|
williamr@2
|
42 |
#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
|
williamr@2
|
43 |
#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
|
williamr@2
|
44 |
#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
|
williamr@2
|
45 |
#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
|
williamr@2
|
46 |
#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
|
williamr@2
|
47 |
#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
|
williamr@2
|
48 |
|
williamr@2
|
49 |
/* --- type macros --- */
|
williamr@2
|
50 |
#define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type())
|
williamr@2
|
51 |
#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))
|
williamr@2
|
52 |
#define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
|
williamr@2
|
53 |
#define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))
|
williamr@2
|
54 |
#define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))
|
williamr@2
|
55 |
#define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
|
williamr@2
|
56 |
/* GInitiallyUnowned ia a GObject with initially floating reference count */
|
williamr@2
|
57 |
|
williamr@2
|
58 |
|
williamr@2
|
59 |
/* --- typedefs & structures --- */
|
williamr@2
|
60 |
typedef struct _GObject GObject;
|
williamr@2
|
61 |
typedef struct _GObjectClass GObjectClass;
|
williamr@2
|
62 |
typedef struct _GObject GInitiallyUnowned;
|
williamr@2
|
63 |
typedef struct _GObjectClass GInitiallyUnownedClass;
|
williamr@2
|
64 |
typedef struct _GObjectConstructParam GObjectConstructParam;
|
williamr@2
|
65 |
typedef void (*GObjectGetPropertyFunc) (GObject *object,
|
williamr@2
|
66 |
guint property_id,
|
williamr@2
|
67 |
GValue *value,
|
williamr@2
|
68 |
GParamSpec *pspec);
|
williamr@2
|
69 |
typedef void (*GObjectSetPropertyFunc) (GObject *object,
|
williamr@2
|
70 |
guint property_id,
|
williamr@2
|
71 |
const GValue *value,
|
williamr@2
|
72 |
GParamSpec *pspec);
|
williamr@2
|
73 |
typedef void (*GObjectFinalizeFunc) (GObject *object);
|
williamr@2
|
74 |
typedef void (*GWeakNotify) (gpointer data,
|
williamr@2
|
75 |
GObject *where_the_object_was);
|
williamr@2
|
76 |
struct _GObject
|
williamr@2
|
77 |
{
|
williamr@2
|
78 |
GTypeInstance g_type_instance;
|
williamr@2
|
79 |
|
williamr@2
|
80 |
/*< private >*/
|
williamr@2
|
81 |
volatile guint ref_count;
|
williamr@2
|
82 |
GData *qdata;
|
williamr@2
|
83 |
};
|
williamr@2
|
84 |
struct _GObjectClass
|
williamr@2
|
85 |
{
|
williamr@2
|
86 |
GTypeClass g_type_class;
|
williamr@2
|
87 |
|
williamr@2
|
88 |
/*< private >*/
|
williamr@2
|
89 |
GSList *construct_properties;
|
williamr@2
|
90 |
|
williamr@2
|
91 |
/*< public >*/
|
williamr@2
|
92 |
/* overridable methods */
|
williamr@2
|
93 |
GObject* (*constructor) (GType type,
|
williamr@2
|
94 |
guint n_construct_properties,
|
williamr@2
|
95 |
GObjectConstructParam *construct_properties);
|
williamr@2
|
96 |
void (*set_property) (GObject *object,
|
williamr@2
|
97 |
guint property_id,
|
williamr@2
|
98 |
const GValue *value,
|
williamr@2
|
99 |
GParamSpec *pspec);
|
williamr@2
|
100 |
void (*get_property) (GObject *object,
|
williamr@2
|
101 |
guint property_id,
|
williamr@2
|
102 |
GValue *value,
|
williamr@2
|
103 |
GParamSpec *pspec);
|
williamr@2
|
104 |
void (*dispose) (GObject *object);
|
williamr@2
|
105 |
void (*finalize) (GObject *object);
|
williamr@2
|
106 |
|
williamr@2
|
107 |
/* seldomly overidden */
|
williamr@2
|
108 |
void (*dispatch_properties_changed) (GObject *object,
|
williamr@2
|
109 |
guint n_pspecs,
|
williamr@2
|
110 |
GParamSpec **pspecs);
|
williamr@2
|
111 |
|
williamr@2
|
112 |
/* signals */
|
williamr@2
|
113 |
void (*notify) (GObject *object,
|
williamr@2
|
114 |
GParamSpec *pspec);
|
williamr@2
|
115 |
/*< private >*/
|
williamr@2
|
116 |
/* padding */
|
williamr@2
|
117 |
gpointer pdummy[8];
|
williamr@2
|
118 |
};
|
williamr@2
|
119 |
struct _GObjectConstructParam
|
williamr@2
|
120 |
{
|
williamr@2
|
121 |
GParamSpec *pspec;
|
williamr@2
|
122 |
GValue *value;
|
williamr@2
|
123 |
};
|
williamr@2
|
124 |
|
williamr@2
|
125 |
|
williamr@2
|
126 |
/* --- prototypes --- */
|
williamr@2
|
127 |
IMPORT_C GType g_initially_unowned_get_type (void);
|
williamr@2
|
128 |
IMPORT_C void g_object_class_install_property (GObjectClass *oclass,
|
williamr@2
|
129 |
guint property_id,
|
williamr@2
|
130 |
GParamSpec *pspec);
|
williamr@2
|
131 |
IMPORT_C GParamSpec* g_object_class_find_property (GObjectClass *oclass,
|
williamr@2
|
132 |
const gchar *property_name);
|
williamr@2
|
133 |
IMPORT_C GParamSpec**g_object_class_list_properties (GObjectClass *oclass,
|
williamr@2
|
134 |
guint *n_properties);
|
williamr@2
|
135 |
IMPORT_C void g_object_class_override_property (GObjectClass *oclass,
|
williamr@2
|
136 |
guint property_id,
|
williamr@2
|
137 |
const gchar *name);
|
williamr@2
|
138 |
|
williamr@2
|
139 |
IMPORT_C void g_object_interface_install_property (gpointer g_iface,
|
williamr@2
|
140 |
GParamSpec *pspec);
|
williamr@2
|
141 |
IMPORT_C GParamSpec* g_object_interface_find_property (gpointer g_iface,
|
williamr@2
|
142 |
const gchar *property_name);
|
williamr@2
|
143 |
IMPORT_C GParamSpec**g_object_interface_list_properties (gpointer g_iface,
|
williamr@2
|
144 |
guint *n_properties_p);
|
williamr@2
|
145 |
|
williamr@2
|
146 |
IMPORT_C gpointer g_object_new (GType object_type,
|
williamr@2
|
147 |
const gchar *first_property_name,
|
williamr@2
|
148 |
...);
|
williamr@2
|
149 |
IMPORT_C gpointer g_object_newv (GType object_type,
|
williamr@2
|
150 |
guint n_parameters,
|
williamr@2
|
151 |
GParameter *parameters);
|
williamr@2
|
152 |
IMPORT_C GObject* g_object_new_valist (GType object_type,
|
williamr@2
|
153 |
const gchar *first_property_name,
|
williamr@2
|
154 |
va_list var_args);
|
williamr@2
|
155 |
IMPORT_C void g_object_set (gpointer object,
|
williamr@2
|
156 |
const gchar *first_property_name,
|
williamr@2
|
157 |
...) G_GNUC_NULL_TERMINATED;
|
williamr@2
|
158 |
IMPORT_C void g_object_get (gpointer object,
|
williamr@2
|
159 |
const gchar *first_property_name,
|
williamr@2
|
160 |
...) G_GNUC_NULL_TERMINATED;
|
williamr@2
|
161 |
IMPORT_C gpointer g_object_connect (gpointer object,
|
williamr@2
|
162 |
const gchar *signal_spec,
|
williamr@2
|
163 |
...) G_GNUC_NULL_TERMINATED;
|
williamr@2
|
164 |
IMPORT_C void g_object_disconnect (gpointer object,
|
williamr@2
|
165 |
const gchar *signal_spec,
|
williamr@2
|
166 |
...) G_GNUC_NULL_TERMINATED;
|
williamr@2
|
167 |
IMPORT_C void g_object_set_valist (GObject *object,
|
williamr@2
|
168 |
const gchar *first_property_name,
|
williamr@2
|
169 |
va_list var_args);
|
williamr@2
|
170 |
IMPORT_C void g_object_get_valist (GObject *object,
|
williamr@2
|
171 |
const gchar *first_property_name,
|
williamr@2
|
172 |
va_list var_args);
|
williamr@2
|
173 |
IMPORT_C void g_object_set_property (GObject *object,
|
williamr@2
|
174 |
const gchar *property_name,
|
williamr@2
|
175 |
const GValue *value);
|
williamr@2
|
176 |
IMPORT_C void g_object_get_property (GObject *object,
|
williamr@2
|
177 |
const gchar *property_name,
|
williamr@2
|
178 |
GValue *value);
|
williamr@2
|
179 |
IMPORT_C void g_object_freeze_notify (GObject *object);
|
williamr@2
|
180 |
IMPORT_C void g_object_notify (GObject *object,
|
williamr@2
|
181 |
const gchar *property_name);
|
williamr@2
|
182 |
IMPORT_C void g_object_thaw_notify (GObject *object);
|
williamr@2
|
183 |
IMPORT_C gboolean g_object_is_floating (gpointer object);
|
williamr@2
|
184 |
IMPORT_C gpointer g_object_ref_sink (gpointer object);
|
williamr@2
|
185 |
IMPORT_C gpointer g_object_ref (gpointer object);
|
williamr@2
|
186 |
IMPORT_C void g_object_unref (gpointer object);
|
williamr@2
|
187 |
IMPORT_C void g_object_weak_ref (GObject *object,
|
williamr@2
|
188 |
GWeakNotify notify,
|
williamr@2
|
189 |
gpointer data);
|
williamr@2
|
190 |
IMPORT_C void g_object_weak_unref (GObject *object,
|
williamr@2
|
191 |
GWeakNotify notify,
|
williamr@2
|
192 |
gpointer data);
|
williamr@2
|
193 |
IMPORT_C void g_object_add_weak_pointer (GObject *object,
|
williamr@2
|
194 |
gpointer *weak_pointer_location);
|
williamr@2
|
195 |
IMPORT_C void g_object_remove_weak_pointer (GObject *object,
|
williamr@2
|
196 |
gpointer *weak_pointer_location);
|
williamr@2
|
197 |
|
williamr@2
|
198 |
typedef void (*GToggleNotify) (gpointer data,
|
williamr@2
|
199 |
GObject *object,
|
williamr@2
|
200 |
gboolean is_last_ref);
|
williamr@2
|
201 |
|
williamr@2
|
202 |
IMPORT_C void g_object_add_toggle_ref (GObject *object,
|
williamr@2
|
203 |
GToggleNotify notify,
|
williamr@2
|
204 |
gpointer data);
|
williamr@2
|
205 |
IMPORT_C void g_object_remove_toggle_ref (GObject *object,
|
williamr@2
|
206 |
GToggleNotify notify,
|
williamr@2
|
207 |
gpointer data);
|
williamr@2
|
208 |
|
williamr@2
|
209 |
IMPORT_C gpointer g_object_get_qdata (GObject *object,
|
williamr@2
|
210 |
GQuark quark);
|
williamr@2
|
211 |
IMPORT_C void g_object_set_qdata (GObject *object,
|
williamr@2
|
212 |
GQuark quark,
|
williamr@2
|
213 |
gpointer data);
|
williamr@2
|
214 |
IMPORT_C void g_object_set_qdata_full (GObject *object,
|
williamr@2
|
215 |
GQuark quark,
|
williamr@2
|
216 |
gpointer data,
|
williamr@2
|
217 |
GDestroyNotify destroy);
|
williamr@2
|
218 |
IMPORT_C gpointer g_object_steal_qdata (GObject *object,
|
williamr@2
|
219 |
GQuark quark);
|
williamr@2
|
220 |
IMPORT_C gpointer g_object_get_data (GObject *object,
|
williamr@2
|
221 |
const gchar *key);
|
williamr@2
|
222 |
IMPORT_C void g_object_set_data (GObject *object,
|
williamr@2
|
223 |
const gchar *key,
|
williamr@2
|
224 |
gpointer data);
|
williamr@2
|
225 |
IMPORT_C void g_object_set_data_full (GObject *object,
|
williamr@2
|
226 |
const gchar *key,
|
williamr@2
|
227 |
gpointer data,
|
williamr@2
|
228 |
GDestroyNotify destroy);
|
williamr@2
|
229 |
IMPORT_C gpointer g_object_steal_data (GObject *object,
|
williamr@2
|
230 |
const gchar *key);
|
williamr@2
|
231 |
IMPORT_C void g_object_watch_closure (GObject *object,
|
williamr@2
|
232 |
GClosure *closure);
|
williamr@2
|
233 |
IMPORT_C GClosure* g_cclosure_new_object (GCallback callback_func,
|
williamr@2
|
234 |
GObject *object);
|
williamr@2
|
235 |
IMPORT_C GClosure* g_cclosure_new_object_swap (GCallback callback_func,
|
williamr@2
|
236 |
GObject *object);
|
williamr@2
|
237 |
IMPORT_C GClosure* g_closure_new_object (guint sizeof_closure,
|
williamr@2
|
238 |
GObject *object);
|
williamr@2
|
239 |
IMPORT_C void g_value_set_object (GValue *value,
|
williamr@2
|
240 |
gpointer v_object);
|
williamr@2
|
241 |
IMPORT_C gpointer g_value_get_object (const GValue *value);
|
williamr@2
|
242 |
IMPORT_C GObject* g_value_dup_object (const GValue *value);
|
williamr@2
|
243 |
IMPORT_C gulong g_signal_connect_object (gpointer instance,
|
williamr@2
|
244 |
const gchar *detailed_signal,
|
williamr@2
|
245 |
GCallback c_handler,
|
williamr@2
|
246 |
gpointer gobject,
|
williamr@2
|
247 |
GConnectFlags connect_flags);
|
williamr@2
|
248 |
|
williamr@2
|
249 |
|
williamr@2
|
250 |
/*< protected >*/
|
williamr@2
|
251 |
IMPORT_C void g_object_force_floating (GObject *object);
|
williamr@2
|
252 |
IMPORT_C void g_object_run_dispose (GObject *object);
|
williamr@2
|
253 |
|
williamr@2
|
254 |
|
williamr@2
|
255 |
IMPORT_C void g_value_take_object (GValue *value,
|
williamr@2
|
256 |
gpointer v_object);
|
williamr@2
|
257 |
#ifndef G_DISABLE_DEPRECATED
|
williamr@2
|
258 |
IMPORT_C void g_value_set_object_take_ownership (GValue *value,
|
williamr@2
|
259 |
gpointer v_object);
|
williamr@2
|
260 |
#endif
|
williamr@2
|
261 |
|
williamr@2
|
262 |
#if !defined(G_DISABLE_DEPRECATED) || defined(GTK_COMPILATION)
|
williamr@2
|
263 |
gsize g_object_compat_control (gsize what,
|
williamr@2
|
264 |
gpointer data);
|
williamr@2
|
265 |
#endif
|
williamr@2
|
266 |
|
williamr@2
|
267 |
/* --- implementation macros --- */
|
williamr@2
|
268 |
#define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \
|
williamr@2
|
269 |
G_STMT_START { \
|
williamr@2
|
270 |
GObject *_object = (GObject*) (object); \
|
williamr@2
|
271 |
GParamSpec *_pspec = (GParamSpec*) (pspec); \
|
williamr@2
|
272 |
guint _property_id = (property_id); \
|
williamr@2
|
273 |
g_warning ("%s: invalid %s id %u for \"%s\" of type `%s' in `%s'", \
|
williamr@2
|
274 |
G_STRLOC, \
|
williamr@2
|
275 |
(pname), \
|
williamr@2
|
276 |
_property_id, \
|
williamr@2
|
277 |
_pspec->name, \
|
williamr@2
|
278 |
g_type_name (G_PARAM_SPEC_TYPE (_pspec)), \
|
williamr@2
|
279 |
G_OBJECT_TYPE_NAME (_object)); \
|
williamr@2
|
280 |
} G_STMT_END
|
williamr@2
|
281 |
#define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
|
williamr@2
|
282 |
G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec))
|
williamr@2
|
283 |
|
williamr@2
|
284 |
G_END_DECLS
|
williamr@2
|
285 |
|
williamr@2
|
286 |
#endif /* __G_OBJECT_H__ */
|