williamr@2: /* GObject - GLib Type, Object, Parameter and Signal Library williamr@2: * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. williamr@2: * Portions copyright (c) 2006 Nokia Corporation. All rights reserved. williamr@2: * williamr@2: * This library is free software; you can redistribute it and/or williamr@2: * modify it under the terms of the GNU Lesser General Public williamr@2: * License as published by the Free Software Foundation; either williamr@2: * version 2 of the License, or (at your option) any later version. williamr@2: * williamr@2: * This library is distributed in the hope that it will be useful, williamr@2: * but WITHOUT ANY WARRANTY; without even the implied warranty of williamr@2: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU williamr@2: * Lesser General Public License for more details. williamr@2: * williamr@2: * You should have received a copy of the GNU Lesser General williamr@2: * Public License along with this library; if not, write to the williamr@2: * Free Software Foundation, Inc., 59 Temple Place, Suite 330, williamr@2: * Boston, MA 02111-1307, USA. williamr@2: */ williamr@2: #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION) williamr@2: #error "Only can be included directly." williamr@2: #endif williamr@2: williamr@2: #ifndef __G_OBJECT_H__ williamr@2: #define __G_OBJECT_H__ williamr@2: williamr@2: #include <_ansi.h> williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: G_BEGIN_DECLS williamr@2: williamr@2: /* --- type macros --- */ williamr@2: #define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT) williamr@2: #define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject)) williamr@2: #define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass)) williamr@2: #define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT)) williamr@2: #define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT)) williamr@2: #define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass)) williamr@2: #define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object)) williamr@2: #define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object))) williamr@2: #define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class)) williamr@2: #define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class))) williamr@2: #define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT)) williamr@2: williamr@2: /* --- type macros --- */ williamr@2: #define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type()) williamr@2: #define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned)) williamr@2: #define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) williamr@2: #define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED)) williamr@2: #define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED)) williamr@2: #define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass)) williamr@2: /* GInitiallyUnowned ia a GObject with initially floating reference count */ williamr@2: williamr@2: williamr@2: /* --- typedefs & structures --- */ williamr@2: typedef struct _GObject GObject; williamr@2: typedef struct _GObjectClass GObjectClass; williamr@2: typedef struct _GObject GInitiallyUnowned; williamr@2: typedef struct _GObjectClass GInitiallyUnownedClass; williamr@2: typedef struct _GObjectConstructParam GObjectConstructParam; williamr@2: typedef void (*GObjectGetPropertyFunc) (GObject *object, williamr@2: guint property_id, williamr@2: GValue *value, williamr@2: GParamSpec *pspec); williamr@2: typedef void (*GObjectSetPropertyFunc) (GObject *object, williamr@2: guint property_id, williamr@2: const GValue *value, williamr@2: GParamSpec *pspec); williamr@2: typedef void (*GObjectFinalizeFunc) (GObject *object); williamr@2: typedef void (*GWeakNotify) (gpointer data, williamr@2: GObject *where_the_object_was); williamr@2: struct _GObject williamr@2: { williamr@2: GTypeInstance g_type_instance; williamr@2: williamr@2: /*< private >*/ williamr@2: volatile guint ref_count; williamr@2: GData *qdata; williamr@2: }; williamr@2: struct _GObjectClass williamr@2: { williamr@2: GTypeClass g_type_class; williamr@2: williamr@2: /*< private >*/ williamr@2: GSList *construct_properties; williamr@2: williamr@2: /*< public >*/ williamr@2: /* overridable methods */ williamr@2: GObject* (*constructor) (GType type, williamr@2: guint n_construct_properties, williamr@2: GObjectConstructParam *construct_properties); williamr@2: void (*set_property) (GObject *object, williamr@2: guint property_id, williamr@2: const GValue *value, williamr@2: GParamSpec *pspec); williamr@2: void (*get_property) (GObject *object, williamr@2: guint property_id, williamr@2: GValue *value, williamr@2: GParamSpec *pspec); williamr@2: void (*dispose) (GObject *object); williamr@2: void (*finalize) (GObject *object); williamr@2: williamr@2: /* seldomly overidden */ williamr@2: void (*dispatch_properties_changed) (GObject *object, williamr@2: guint n_pspecs, williamr@2: GParamSpec **pspecs); williamr@2: williamr@2: /* signals */ williamr@2: void (*notify) (GObject *object, williamr@2: GParamSpec *pspec); williamr@2: /*< private >*/ williamr@2: /* padding */ williamr@2: gpointer pdummy[8]; williamr@2: }; williamr@2: struct _GObjectConstructParam williamr@2: { williamr@2: GParamSpec *pspec; williamr@2: GValue *value; williamr@2: }; williamr@2: williamr@2: williamr@2: /* --- prototypes --- */ williamr@2: IMPORT_C GType g_initially_unowned_get_type (void); williamr@2: IMPORT_C void g_object_class_install_property (GObjectClass *oclass, williamr@2: guint property_id, williamr@2: GParamSpec *pspec); williamr@2: IMPORT_C GParamSpec* g_object_class_find_property (GObjectClass *oclass, williamr@2: const gchar *property_name); williamr@2: IMPORT_C GParamSpec**g_object_class_list_properties (GObjectClass *oclass, williamr@2: guint *n_properties); williamr@2: IMPORT_C void g_object_class_override_property (GObjectClass *oclass, williamr@2: guint property_id, williamr@2: const gchar *name); williamr@2: williamr@2: IMPORT_C void g_object_interface_install_property (gpointer g_iface, williamr@2: GParamSpec *pspec); williamr@2: IMPORT_C GParamSpec* g_object_interface_find_property (gpointer g_iface, williamr@2: const gchar *property_name); williamr@2: IMPORT_C GParamSpec**g_object_interface_list_properties (gpointer g_iface, williamr@2: guint *n_properties_p); williamr@2: williamr@2: IMPORT_C gpointer g_object_new (GType object_type, williamr@2: const gchar *first_property_name, williamr@2: ...); williamr@2: IMPORT_C gpointer g_object_newv (GType object_type, williamr@2: guint n_parameters, williamr@2: GParameter *parameters); williamr@2: IMPORT_C GObject* g_object_new_valist (GType object_type, williamr@2: const gchar *first_property_name, williamr@2: va_list var_args); williamr@2: IMPORT_C void g_object_set (gpointer object, williamr@2: const gchar *first_property_name, williamr@2: ...) G_GNUC_NULL_TERMINATED; williamr@2: IMPORT_C void g_object_get (gpointer object, williamr@2: const gchar *first_property_name, williamr@2: ...) G_GNUC_NULL_TERMINATED; williamr@2: IMPORT_C gpointer g_object_connect (gpointer object, williamr@2: const gchar *signal_spec, williamr@2: ...) G_GNUC_NULL_TERMINATED; williamr@2: IMPORT_C void g_object_disconnect (gpointer object, williamr@2: const gchar *signal_spec, williamr@2: ...) G_GNUC_NULL_TERMINATED; williamr@2: IMPORT_C void g_object_set_valist (GObject *object, williamr@2: const gchar *first_property_name, williamr@2: va_list var_args); williamr@2: IMPORT_C void g_object_get_valist (GObject *object, williamr@2: const gchar *first_property_name, williamr@2: va_list var_args); williamr@2: IMPORT_C void g_object_set_property (GObject *object, williamr@2: const gchar *property_name, williamr@2: const GValue *value); williamr@2: IMPORT_C void g_object_get_property (GObject *object, williamr@2: const gchar *property_name, williamr@2: GValue *value); williamr@2: IMPORT_C void g_object_freeze_notify (GObject *object); williamr@2: IMPORT_C void g_object_notify (GObject *object, williamr@2: const gchar *property_name); williamr@2: IMPORT_C void g_object_thaw_notify (GObject *object); williamr@2: IMPORT_C gboolean g_object_is_floating (gpointer object); williamr@2: IMPORT_C gpointer g_object_ref_sink (gpointer object); williamr@2: IMPORT_C gpointer g_object_ref (gpointer object); williamr@2: IMPORT_C void g_object_unref (gpointer object); williamr@2: IMPORT_C void g_object_weak_ref (GObject *object, williamr@2: GWeakNotify notify, williamr@2: gpointer data); williamr@2: IMPORT_C void g_object_weak_unref (GObject *object, williamr@2: GWeakNotify notify, williamr@2: gpointer data); williamr@2: IMPORT_C void g_object_add_weak_pointer (GObject *object, williamr@2: gpointer *weak_pointer_location); williamr@2: IMPORT_C void g_object_remove_weak_pointer (GObject *object, williamr@2: gpointer *weak_pointer_location); williamr@2: williamr@2: typedef void (*GToggleNotify) (gpointer data, williamr@2: GObject *object, williamr@2: gboolean is_last_ref); williamr@2: williamr@2: IMPORT_C void g_object_add_toggle_ref (GObject *object, williamr@2: GToggleNotify notify, williamr@2: gpointer data); williamr@2: IMPORT_C void g_object_remove_toggle_ref (GObject *object, williamr@2: GToggleNotify notify, williamr@2: gpointer data); williamr@2: williamr@2: IMPORT_C gpointer g_object_get_qdata (GObject *object, williamr@2: GQuark quark); williamr@2: IMPORT_C void g_object_set_qdata (GObject *object, williamr@2: GQuark quark, williamr@2: gpointer data); williamr@2: IMPORT_C void g_object_set_qdata_full (GObject *object, williamr@2: GQuark quark, williamr@2: gpointer data, williamr@2: GDestroyNotify destroy); williamr@2: IMPORT_C gpointer g_object_steal_qdata (GObject *object, williamr@2: GQuark quark); williamr@2: IMPORT_C gpointer g_object_get_data (GObject *object, williamr@2: const gchar *key); williamr@2: IMPORT_C void g_object_set_data (GObject *object, williamr@2: const gchar *key, williamr@2: gpointer data); williamr@2: IMPORT_C void g_object_set_data_full (GObject *object, williamr@2: const gchar *key, williamr@2: gpointer data, williamr@2: GDestroyNotify destroy); williamr@2: IMPORT_C gpointer g_object_steal_data (GObject *object, williamr@2: const gchar *key); williamr@2: IMPORT_C void g_object_watch_closure (GObject *object, williamr@2: GClosure *closure); williamr@2: IMPORT_C GClosure* g_cclosure_new_object (GCallback callback_func, williamr@2: GObject *object); williamr@2: IMPORT_C GClosure* g_cclosure_new_object_swap (GCallback callback_func, williamr@2: GObject *object); williamr@2: IMPORT_C GClosure* g_closure_new_object (guint sizeof_closure, williamr@2: GObject *object); williamr@2: IMPORT_C void g_value_set_object (GValue *value, williamr@2: gpointer v_object); williamr@2: IMPORT_C gpointer g_value_get_object (const GValue *value); williamr@2: IMPORT_C GObject* g_value_dup_object (const GValue *value); williamr@2: IMPORT_C gulong g_signal_connect_object (gpointer instance, williamr@2: const gchar *detailed_signal, williamr@2: GCallback c_handler, williamr@2: gpointer gobject, williamr@2: GConnectFlags connect_flags); williamr@2: williamr@2: williamr@2: /*< protected >*/ williamr@2: IMPORT_C void g_object_force_floating (GObject *object); williamr@2: IMPORT_C void g_object_run_dispose (GObject *object); williamr@2: williamr@2: williamr@2: IMPORT_C void g_value_take_object (GValue *value, williamr@2: gpointer v_object); williamr@2: #ifndef G_DISABLE_DEPRECATED williamr@2: IMPORT_C void g_value_set_object_take_ownership (GValue *value, williamr@2: gpointer v_object); williamr@2: #endif williamr@2: williamr@2: #if !defined(G_DISABLE_DEPRECATED) || defined(GTK_COMPILATION) williamr@2: gsize g_object_compat_control (gsize what, williamr@2: gpointer data); williamr@2: #endif williamr@2: williamr@2: /* --- implementation macros --- */ williamr@2: #define G_OBJECT_WARN_INVALID_PSPEC(object, pname, property_id, pspec) \ williamr@2: G_STMT_START { \ williamr@2: GObject *_object = (GObject*) (object); \ williamr@2: GParamSpec *_pspec = (GParamSpec*) (pspec); \ williamr@2: guint _property_id = (property_id); \ williamr@2: g_warning ("%s: invalid %s id %u for \"%s\" of type `%s' in `%s'", \ williamr@2: G_STRLOC, \ williamr@2: (pname), \ williamr@2: _property_id, \ williamr@2: _pspec->name, \ williamr@2: g_type_name (G_PARAM_SPEC_TYPE (_pspec)), \ williamr@2: G_OBJECT_TYPE_NAME (_object)); \ williamr@2: } G_STMT_END williamr@2: #define G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec) \ williamr@2: G_OBJECT_WARN_INVALID_PSPEC ((object), "property", (property_id), (pspec)) williamr@2: williamr@2: G_END_DECLS williamr@2: williamr@2: #endif /* __G_OBJECT_H__ */