00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
00021 #error "Only <glib-object.h> can be included directly."
00022 #endif
00023
00024 #ifndef __G_OBJECT_H__
00025 #define __G_OBJECT_H__
00026
00027 #include <_ansi.h>
00028 #include <gobject/gtype.h>
00029 #include <gobject/gvalue.h>
00030 #include <gobject/gparam.h>
00031 #include <gobject/gclosure.h>
00032 #include <gobject/gsignal.h>
00033
00034 G_BEGIN_DECLS
00035
00036
00037 #define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)
00038 #define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))
00039 #define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))
00040 #define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))
00041 #define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))
00042 #define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))
00043 #define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))
00044 #define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))
00045 #define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))
00046 #define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))
00047 #define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))
00048
00049
00050 #define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type())
00051 #define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))
00052 #define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
00053 #define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))
00054 #define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))
00055 #define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))
00056
00057
00058
00059
00060 typedef struct _GObject GObject;
00061 typedef struct _GObjectClass GObjectClass;
00062 typedef struct _GObject GInitiallyUnowned;
00063 typedef struct _GObjectClass GInitiallyUnownedClass;
00064 typedef struct _GObjectConstructParam GObjectConstructParam;
00065 typedef void (*GObjectGetPropertyFunc) (GObject *object,
00066 guint property_id,
00067 GValue *value,
00068 GParamSpec *pspec);
00069 typedef void (*GObjectSetPropertyFunc) (GObject *object,
00070 guint property_id,
00071 const GValue *value,
00072 GParamSpec *pspec);
00073 typedef void (*GObjectFinalizeFunc) (GObject *object);
00074 typedef void (*GWeakNotify) (gpointer data,
00075 GObject *where_the_object_was);
00076 struct _GObject
00077 {
00078 GTypeInstance g_type_instance;
00079
00080
00081 volatile guint ref_count;
00082 GData *qdata;
00083 };
00084 struct _GObjectClass
00085 {
00086 GTypeClass g_type_class;
00087
00088
00089 GSList *construct_properties;
00090
00091
00092
00093 GObject* (*constructor) (GType type,
00094 guint n_construct_properties,
00095 GObjectConstructParam *construct_properties);
00096 void (*set_property) (GObject *object,
00097 guint property_id,
00098 const GValue *value,
00099 GParamSpec *pspec);
00100 void (*get_property) (GObject *object,
00101 guint property_id,
00102 GValue *value,
00103 GParamSpec *pspec);
00104 void (*dispose) (GObject *object);
00105 void (*finalize) (GObject *object);
00106
00107
00108 void (*dispatch_properties_changed) (GObject *object,
00109 guint n_pspecs,
00110 GParamSpec **pspecs);
00111
00112
00113 void (*notify) (GObject *object,
00114 GParamSpec *pspec);
00115
00116
00117 gpointer pdummy[8];
00118 };
00119 struct _GObjectConstructParam
00120 {
00121 GParamSpec *pspec;
00122 GValue *value;
00123 };
00124
00125
00126
00127 IMPORT_C GType g_initially_unowned_get_type (void);
00128 IMPORT_C void g_object_class_install_property (GObjectClass *oclass,
00129 guint property_id,
00130 GParamSpec *pspec);
00131 IMPORT_C GParamSpec* g_object_class_find_property (GObjectClass *oclass,
00132 const gchar *property_name);
00133 IMPORT_C GParamSpec**g_object_class_list_properties (GObjectClass *oclass,
00134 guint *n_properties);
00135 IMPORT_C void g_object_class_override_property (GObjectClass *oclass,
00136 guint property_id,
00137 const gchar *name);
00138
00139 IMPORT_C void g_object_interface_install_property (gpointer g_iface,
00140 GParamSpec *pspec);
00141 IMPORT_C GParamSpec* g_object_interface_find_property (gpointer g_iface,
00142 const gchar *property_name);
00143 IMPORT_C GParamSpec**g_object_interface_list_properties (gpointer g_iface,
00144 guint *n_properties_p);
00145
00146 IMPORT_C gpointer g_object_new (GType object_type,
00147 const gchar *first_property_name,
00148 ...);
00149 IMPORT_C gpointer g_object_newv (GType object_type,
00150 guint n_parameters,
00151 GParameter *parameters);
00152 IMPORT_C GObject* g_object_new_valist (GType object_type,
00153 const gchar *first_property_name,
00154 va_list var_args);
00155 IMPORT_C void g_object_set (gpointer object,
00156 const gchar *first_property_name,
00157 ...) G_GNUC_NULL_TERMINATED;
00158 IMPORT_C void g_object_get (gpointer object,
00159 const gchar *first_property_name,
00160 ...) G_GNUC_NULL_TERMINATED;
00161 IMPORT_C gpointer g_object_connect (gpointer object,
00162 const gchar *signal_spec,
00163 ...) G_GNUC_NULL_TERMINATED;
00164 IMPORT_C void g_object_disconnect (gpointer object,
00165 const gchar *signal_spec,
00166 ...) G_GNUC_NULL_TERMINATED;
00167 IMPORT_C void g_object_set_valist (GObject *object,
00168 const gchar *first_property_name,
00169 va_list var_args);
00170 IMPORT_C void g_object_get_valist (GObject *object,
00171 const gchar *first_property_name,
00172 va_list var_args);
00173 IMPORT_C void g_object_set_property (GObject *object,
00174 const gchar *property_name,
00175 const GValue *value);
00176 IMPORT_C void g_object_get_property (GObject *object,
00177 const gchar *property_name,
00178 GValue *value);
00179 IMPORT_C void g_object_freeze_notify (GObject *object);
00180 IMPORT_C void g_object_notify (GObject *object,
00181 const gchar *property_name);
00182 IMPORT_C void g_object_thaw_notify (GObject *object);
00183 IMPORT_C gboolean g_object_is_floating (gpointer object);
00184 IMPORT_C gpointer g_object_ref_sink (gpointer object);
00185 IMPORT_C gpointer g_object_ref (gpointer object);
00186 IMPORT_C void g_object_unref (gpointer object);
00187 IMPORT_C void g_object_weak_ref (GObject *object,
00188 GWeakNotify notify,
00189 gpointer data);
00190 IMPORT_C void g_object_weak_unref (GObject *object,
00191 GWeakNotify notify,
00192 gpointer data);
00193 IMPORT_C void g_object_add_weak_pointer (GObject *object,
00194 gpointer *weak_pointer_location);
00195 IMPORT_C void g_object_remove_weak_pointer (GObject *object,
00196 gpointer *weak_pointer_location);
00197
00198 typedef void (*GToggleNotify) (gpointer data,
00199 GObject *object,
00200 gboolean is_last_ref);
00201
00202 IMPORT_C void g_object_add_toggle_ref (GObject *object,
00203 GToggleNotify notify,
00204 gpointer data);
00205 IMPORT_C void g_object_remove_toggle_ref (GObject *object,
00206 GToggleNotify notify,
00207 gpointer data);
00208
00209 IMPORT_C gpointer g_object_get_qdata (GObject *object,
00210 GQuark quark);
00211 IMPORT_C void g_object_set_qdata (GObject *object,
00212 GQuark quark,
00213 gpointer data);
00214 IMPORT_C void g_object_set_qdata_full (GObject *object,
00215 GQuark quark,
00216 gpointer data,
00217 GDestroyNotify destroy);
00218 IMPORT_C gpointer g_object_steal_qdata (GObject *object,
00219 GQuark quark);
00220 IMPORT_C gpointer g_object_get_data (GObject *object,
00221 const gchar *key);
00222 IMPORT_C void g_object_set_data (GObject *object,
00223 const gchar *key,
00224 gpointer data);
00225 IMPORT_C void g_object_set_data_full (GObject *object,
00226 const gchar *key,
00227 gpointer data,
00228 GDestroyNotify destroy);
00229 IMPORT_C gpointer g_object_steal_data (GObject *object,
00230 const gchar *key);
00231 IMPORT_C void g_object_watch_closure (GObject *object,
00232 GClosure *closure);
00233 IMPORT_C GClosure* g_cclosure_new_object (GCallback callback_func,
00234 GObject *object);
00235 IMPORT_C GClosure* g_cclosure_new_object_swap (GCallback callback_func,
00236 GObject *object);
00237 IMPORT_C GClosure* g_closure_new_object (guint sizeof_closure,
00238 GObject *object);
00239 IMPORT_C void g_value_set_object (GValue *value,
00240 gpointer v_object);
00241 IMPORT_C gpointer g_value_get_object (const GValue *value);
00242 IMPORT_C GObject* g_value_dup_object (const GValue *value);
00243 IMPORT_C gulong g_signal_connect_object (gpointer instance,
00244 const gchar *detailed_signal,
00245 GCallback c_handler,
00246 gpointer gobject,
00247 GConnectFlags connect_flags);
00248
00249
00250
00251 IMPORT_C void g_object_force_floating (GObject *object);
00252 IMPORT_C void g_object_run_dispose (GObject *object);
00253
00254
00255 IMPORT_C void g_value_take_object (GValue *value,
00256 gpointer v_object);
00257 #ifndef G_DISABLE_DEPRECATED
00258 IMPORT_C void g_value_set_object_take_ownership (GValue *value,
00259 gpointer v_object);
00260 #endif
00261
00262 #if !defined(G_DISABLE_DEPRECATED) || defined(GTK_COMPILATION)
00263 gsize g_object_compat_control (gsize what,
00264 gpointer data);
00265 #endif
00266
00267
00268 #define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \
00269 G_STMT_START { \
00270 GObject *_object = (GObject*) (object); \
00271 GParamSpec *_pspec = (GParamSpec*) (pspec); \
00272 guint _property_id = (property_id); \
00273 g_warning ("%s: invalid %s id %u for \"%s\" of type `%s' in `%s'", \
00274 G_STRLOC, \
00275 (pname), \
00276 _property_id, \
00277 _pspec->name, \
00278 g_type_name (G_PARAM_SPEC_TYPE (_pspec)), \
00279 G_OBJECT_TYPE_NAME (_object)); \
00280 } G_STMT_END
00281 #define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \
00282 G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec))
00283
00284 G_END_DECLS
00285
00286 #endif