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 | #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) |
---|
20 | #error "Only <glib-object.h> can be included directly." |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifndef __G_OBJECT_H__ |
---|
24 | #define __G_OBJECT_H__ |
---|
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 | |
---|
32 | G_BEGIN_DECLS |
---|
33 | |
---|
34 | /* --- type macros --- */ |
---|
35 | #define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT) |
---|
36 | #define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject)) |
---|
37 | #define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass)) |
---|
38 | #define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT)) |
---|
39 | #define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT)) |
---|
40 | #define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass)) |
---|
41 | #define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object)) |
---|
42 | #define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object))) |
---|
43 | #define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) |
---|
44 | #define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class))) |
---|
45 | #define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT)) |
---|
46 | |
---|
47 | |
---|
48 | /* --- typedefs & structures --- */ |
---|
49 | typedef struct _GObject GObject; |
---|
50 | typedef struct _GObjectClass GObjectClass; |
---|
51 | typedef struct _GObjectConstructParam GObjectConstructParam; |
---|
52 | typedef void (*GObjectGetPropertyFunc) (GObject *object, |
---|
53 | guint property_id, |
---|
54 | GValue *value, |
---|
55 | GParamSpec *pspec); |
---|
56 | typedef void (*GObjectSetPropertyFunc) (GObject *object, |
---|
57 | guint property_id, |
---|
58 | const GValue *value, |
---|
59 | GParamSpec *pspec); |
---|
60 | typedef void (*GObjectFinalizeFunc) (GObject *object); |
---|
61 | typedef void (*GWeakNotify) (gpointer data, |
---|
62 | GObject *where_the_object_was); |
---|
63 | struct _GObject |
---|
64 | { |
---|
65 | GTypeInstance g_type_instance; |
---|
66 | |
---|
67 | /*< private >*/ |
---|
68 | guint ref_count; |
---|
69 | GData *qdata; |
---|
70 | }; |
---|
71 | struct _GObjectClass |
---|
72 | { |
---|
73 | GTypeClass g_type_class; |
---|
74 | |
---|
75 | /*< private >*/ |
---|
76 | GSList *construct_properties; |
---|
77 | |
---|
78 | /*< public >*/ |
---|
79 | /* overridable methods */ |
---|
80 | GObject* (*constructor) (GType type, |
---|
81 | guint n_construct_properties, |
---|
82 | GObjectConstructParam *construct_properties); |
---|
83 | void (*set_property) (GObject *object, |
---|
84 | guint property_id, |
---|
85 | const GValue *value, |
---|
86 | GParamSpec *pspec); |
---|
87 | void (*get_property) (GObject *object, |
---|
88 | guint property_id, |
---|
89 | GValue *value, |
---|
90 | GParamSpec *pspec); |
---|
91 | void (*dispose) (GObject *object); |
---|
92 | void (*finalize) (GObject *object); |
---|
93 | |
---|
94 | /* seldomly overidden */ |
---|
95 | void (*dispatch_properties_changed) (GObject *object, |
---|
96 | guint n_pspecs, |
---|
97 | GParamSpec **pspecs); |
---|
98 | |
---|
99 | /* signals */ |
---|
100 | void (*notify) (GObject *object, |
---|
101 | GParamSpec *pspec); |
---|
102 | /*< private >*/ |
---|
103 | /* padding */ |
---|
104 | gpointer pdummy[8]; |
---|
105 | }; |
---|
106 | struct _GObjectConstructParam |
---|
107 | { |
---|
108 | GParamSpec *pspec; |
---|
109 | GValue *value; |
---|
110 | }; |
---|
111 | |
---|
112 | |
---|
113 | /* --- prototypes --- */ |
---|
114 | void g_object_class_install_property (GObjectClass *oclass, |
---|
115 | guint property_id, |
---|
116 | GParamSpec *pspec); |
---|
117 | GParamSpec* g_object_class_find_property (GObjectClass *oclass, |
---|
118 | const gchar *property_name); |
---|
119 | GParamSpec**g_object_class_list_properties (GObjectClass *oclass, |
---|
120 | guint *n_properties); |
---|
121 | void g_object_class_override_property (GObjectClass *oclass, |
---|
122 | guint property_id, |
---|
123 | const gchar *name); |
---|
124 | |
---|
125 | void g_object_interface_install_property (gpointer g_iface, |
---|
126 | GParamSpec *pspec); |
---|
127 | GParamSpec* g_object_interface_find_property (gpointer g_iface, |
---|
128 | const gchar *property_name); |
---|
129 | GParamSpec**g_object_interface_list_properties (gpointer g_iface, |
---|
130 | guint *n_properties_p); |
---|
131 | |
---|
132 | gpointer g_object_new (GType object_type, |
---|
133 | const gchar *first_property_name, |
---|
134 | ...); |
---|
135 | gpointer g_object_newv (GType object_type, |
---|
136 | guint n_parameters, |
---|
137 | GParameter *parameters); |
---|
138 | GObject* g_object_new_valist (GType object_type, |
---|
139 | const gchar *first_property_name, |
---|
140 | va_list var_args); |
---|
141 | void g_object_set (gpointer object, |
---|
142 | const gchar *first_property_name, |
---|
143 | ...); |
---|
144 | void g_object_get (gpointer object, |
---|
145 | const gchar *first_property_name, |
---|
146 | ...); |
---|
147 | gpointer g_object_connect (gpointer object, |
---|
148 | const gchar *signal_spec, |
---|
149 | ...); |
---|
150 | void g_object_disconnect (gpointer object, |
---|
151 | const gchar *signal_spec, |
---|
152 | ...); |
---|
153 | void g_object_set_valist (GObject *object, |
---|
154 | const gchar *first_property_name, |
---|
155 | va_list var_args); |
---|
156 | void g_object_get_valist (GObject *object, |
---|
157 | const gchar *first_property_name, |
---|
158 | va_list var_args); |
---|
159 | void g_object_set_property (GObject *object, |
---|
160 | const gchar *property_name, |
---|
161 | const GValue *value); |
---|
162 | void g_object_get_property (GObject *object, |
---|
163 | const gchar *property_name, |
---|
164 | GValue *value); |
---|
165 | void g_object_freeze_notify (GObject *object); |
---|
166 | void g_object_notify (GObject *object, |
---|
167 | const gchar *property_name); |
---|
168 | void g_object_thaw_notify (GObject *object); |
---|
169 | gpointer g_object_ref (gpointer object); |
---|
170 | void g_object_unref (gpointer object); |
---|
171 | void g_object_weak_ref (GObject *object, |
---|
172 | GWeakNotify notify, |
---|
173 | gpointer data); |
---|
174 | void g_object_weak_unref (GObject *object, |
---|
175 | GWeakNotify notify, |
---|
176 | gpointer data); |
---|
177 | void g_object_add_weak_pointer (GObject *object, |
---|
178 | gpointer *weak_pointer_location); |
---|
179 | void g_object_remove_weak_pointer (GObject *object, |
---|
180 | gpointer *weak_pointer_location); |
---|
181 | gpointer g_object_get_qdata (GObject *object, |
---|
182 | GQuark quark); |
---|
183 | void g_object_set_qdata (GObject *object, |
---|
184 | GQuark quark, |
---|
185 | gpointer data); |
---|
186 | void g_object_set_qdata_full (GObject *object, |
---|
187 | GQuark quark, |
---|
188 | gpointer data, |
---|
189 | GDestroyNotify destroy); |
---|
190 | gpointer g_object_steal_qdata (GObject *object, |
---|
191 | GQuark quark); |
---|
192 | gpointer g_object_get_data (GObject *object, |
---|
193 | const gchar *key); |
---|
194 | void g_object_set_data (GObject *object, |
---|
195 | const gchar *key, |
---|
196 | gpointer data); |
---|
197 | void g_object_set_data_full (GObject *object, |
---|
198 | const gchar *key, |
---|
199 | gpointer data, |
---|
200 | GDestroyNotify destroy); |
---|
201 | gpointer g_object_steal_data (GObject *object, |
---|
202 | const gchar *key); |
---|
203 | void g_object_watch_closure (GObject *object, |
---|
204 | GClosure *closure); |
---|
205 | GClosure* g_cclosure_new_object (GCallback callback_func, |
---|
206 | GObject *object); |
---|
207 | GClosure* g_cclosure_new_object_swap (GCallback callback_func, |
---|
208 | GObject *object); |
---|
209 | GClosure* g_closure_new_object (guint sizeof_closure, |
---|
210 | GObject *object); |
---|
211 | void g_value_set_object (GValue *value, |
---|
212 | gpointer v_object); |
---|
213 | gpointer g_value_get_object (const GValue *value); |
---|
214 | GObject* g_value_dup_object (const GValue *value); |
---|
215 | gulong g_signal_connect_object (gpointer instance, |
---|
216 | const gchar *detailed_signal, |
---|
217 | GCallback c_handler, |
---|
218 | gpointer gobject, |
---|
219 | GConnectFlags connect_flags); |
---|
220 | |
---|
221 | |
---|
222 | /*< protected >*/ |
---|
223 | void g_object_run_dispose (GObject *object); |
---|
224 | |
---|
225 | |
---|
226 | void g_value_take_object (GValue *value, |
---|
227 | gpointer v_object); |
---|
228 | #ifndef G_DISABLE_DEPRECATED |
---|
229 | void g_value_set_object_take_ownership (GValue *value, |
---|
230 | gpointer v_object); |
---|
231 | #endif |
---|
232 | |
---|
233 | /* --- implementation macros --- */ |
---|
234 | #define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \ |
---|
235 | G_STMT_START { \ |
---|
236 | GObject *_object = (GObject*) (object); \ |
---|
237 | GParamSpec *_pspec = (GParamSpec*) (pspec); \ |
---|
238 | guint _property_id = (property_id); \ |
---|
239 | g_warning ("%s: invalid %s id %u for \"%s\" of type `%s' in `%s'", \ |
---|
240 | G_STRLOC, \ |
---|
241 | (pname), \ |
---|
242 | _property_id, \ |
---|
243 | _pspec->name, \ |
---|
244 | g_type_name (G_PARAM_SPEC_TYPE (_pspec)), \ |
---|
245 | G_OBJECT_TYPE_NAME (_object)); \ |
---|
246 | } G_STMT_END |
---|
247 | #define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \ |
---|
248 | G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec)) |
---|
249 | |
---|
250 | G_END_DECLS |
---|
251 | |
---|
252 | #endif /* __G_OBJECT_H__ */ |
---|