Remove GtkObject floating, weak, arg and user data handling

This commit is contained in:
Christian Dywan 2009-12-10 11:38:27 +01:00 committed by Javier Jardón
parent 729d4c3624
commit e0969a1327
4 changed files with 1 additions and 744 deletions

View File

@ -294,7 +294,6 @@ gtk_spin_button_update_policy_get_type G_GNUC_CONST
gtk_notebook_tab_get_type G_GNUC_CONST
gtk_number_up_layout_get_type G_GNUC_CONST
gtk_anchor_type_get_type G_GNUC_CONST
gtk_arg_flags_get_type G_GNUC_CONST
gtk_arrow_type_get_type G_GNUC_CONST
gtk_arrow_placement_get_type G_GNUC_CONST
gtk_assistant_page_type_get_type G_GNUC_CONST
@ -2218,29 +2217,6 @@ gtk_notebook_set_action_widget
#if IN_HEADER(__GTK_OBJECT_H__)
#if IN_FILE(__GTK_OBJECT_C__)
#ifndef GTK_DISABLE_DEPRECATED
gtk_object_add_arg_type
gtk_object_get G_GNUC_NULL_TERMINATED
gtk_object_set G_GNUC_NULL_TERMINATED
gtk_object_get_data
gtk_object_get_data_by_id
gtk_object_get_user_data
gtk_object_new
gtk_object_remove_data
gtk_object_remove_data_by_id
gtk_object_remove_no_notify
gtk_object_remove_no_notify_by_id
gtk_object_ref
gtk_object_unref
gtk_object_weakref
gtk_object_weakunref
gtk_object_set_data
gtk_object_set_data_by_id
gtk_object_set_data_by_id_full
gtk_object_set_data_full
gtk_object_set_user_data
gtk_object_sink
#endif
gtk_object_destroy
gtk_object_get_type G_GNUC_CONST
#endif

View File

@ -30,8 +30,6 @@
#include <string.h>
#include <stdio.h>
#undef GTK_DISABLE_DEPRECATED
#include "gtkobject.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
@ -44,10 +42,6 @@ enum {
DESTROY,
LAST_SIGNAL
};
enum {
PROP_0,
PROP_USER_DATA
};
static void gtk_object_base_class_init (GtkObjectClass *class);
@ -55,22 +49,12 @@ static void gtk_object_base_class_finalize (GtkObjectClass *class);
static void gtk_object_class_init (GtkObjectClass *klass);
static void gtk_object_init (GtkObject *object,
GtkObjectClass *klass);
static void gtk_object_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gtk_object_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gtk_object_dispose (GObject *object);
static void gtk_object_real_destroy (GtkObject *object);
static void gtk_object_finalize (GObject *object);
static void gtk_object_notify_weaks (GtkObject *object);
static gpointer parent_class = NULL;
static guint object_signals[LAST_SIGNAL] = { 0 };
static GQuark quark_weakrefs = 0;
/****************************************************
@ -109,9 +93,6 @@ gtk_object_get_type (void)
static void
gtk_object_base_class_init (GtkObjectClass *class)
{
/* reset instance specifc methods that don't get inherited */
class->get_arg = NULL;
class->set_arg = NULL;
}
static void
@ -119,257 +100,18 @@ gtk_object_base_class_finalize (GtkObjectClass *class)
{
}
static inline gboolean
gtk_arg_set_from_value (GtkArg *arg,
const GValue *value,
gboolean copy_string)
{
switch (G_TYPE_FUNDAMENTAL (arg->type))
{
case G_TYPE_CHAR: GTK_VALUE_CHAR (*arg) = g_value_get_char (value); break;
case G_TYPE_UCHAR: GTK_VALUE_UCHAR (*arg) = g_value_get_uchar (value); break;
case G_TYPE_BOOLEAN: GTK_VALUE_BOOL (*arg) = g_value_get_boolean (value); break;
case G_TYPE_INT: GTK_VALUE_INT (*arg) = g_value_get_int (value); break;
case G_TYPE_UINT: GTK_VALUE_UINT (*arg) = g_value_get_uint (value); break;
case G_TYPE_LONG: GTK_VALUE_LONG (*arg) = g_value_get_long (value); break;
case G_TYPE_ULONG: GTK_VALUE_ULONG (*arg) = g_value_get_ulong (value); break;
case G_TYPE_ENUM: GTK_VALUE_ENUM (*arg) = g_value_get_enum (value); break;
case G_TYPE_FLAGS: GTK_VALUE_FLAGS (*arg) = g_value_get_flags (value); break;
case G_TYPE_FLOAT: GTK_VALUE_FLOAT (*arg) = g_value_get_float (value); break;
case G_TYPE_DOUBLE: GTK_VALUE_DOUBLE (*arg) = g_value_get_double (value); break;
case G_TYPE_BOXED: GTK_VALUE_BOXED (*arg) = g_value_get_boxed (value); break;
case G_TYPE_POINTER: GTK_VALUE_POINTER (*arg) = g_value_get_pointer (value); break;
case G_TYPE_OBJECT: GTK_VALUE_POINTER (*arg) = g_value_get_object (value); break;
case G_TYPE_STRING: if (copy_string)
GTK_VALUE_STRING (*arg) = g_value_dup_string (value);
else
GTK_VALUE_STRING (*arg) = (char *) g_value_get_string (value);
break;
default:
return FALSE;
}
return TRUE;
}
static inline gboolean
gtk_arg_to_value (GtkArg *arg,
GValue *value)
{
switch (G_TYPE_FUNDAMENTAL (arg->type))
{
case G_TYPE_CHAR: g_value_set_char (value, GTK_VALUE_CHAR (*arg)); break;
case G_TYPE_UCHAR: g_value_set_uchar (value, GTK_VALUE_UCHAR (*arg)); break;
case G_TYPE_BOOLEAN: g_value_set_boolean (value, GTK_VALUE_BOOL (*arg)); break;
case G_TYPE_INT: g_value_set_int (value, GTK_VALUE_INT (*arg)); break;
case G_TYPE_UINT: g_value_set_uint (value, GTK_VALUE_UINT (*arg)); break;
case G_TYPE_LONG: g_value_set_long (value, GTK_VALUE_LONG (*arg)); break;
case G_TYPE_ULONG: g_value_set_ulong (value, GTK_VALUE_ULONG (*arg)); break;
case G_TYPE_ENUM: g_value_set_enum (value, GTK_VALUE_ENUM (*arg)); break;
case G_TYPE_FLAGS: g_value_set_flags (value, GTK_VALUE_FLAGS (*arg)); break;
case G_TYPE_FLOAT: g_value_set_float (value, GTK_VALUE_FLOAT (*arg)); break;
case G_TYPE_DOUBLE: g_value_set_double (value, GTK_VALUE_DOUBLE (*arg)); break;
case G_TYPE_STRING: g_value_set_string (value, GTK_VALUE_STRING (*arg)); break;
case G_TYPE_BOXED: g_value_set_boxed (value, GTK_VALUE_BOXED (*arg)); break;
case G_TYPE_POINTER: g_value_set_pointer (value, GTK_VALUE_POINTER (*arg)); break;
case G_TYPE_OBJECT: g_value_set_object (value, GTK_VALUE_POINTER (*arg)); break;
default:
return FALSE;
}
return TRUE;
}
static void
gtk_arg_proxy_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GtkObjectClass *class = g_type_class_peek (pspec->owner_type);
GtkArg arg;
g_return_if_fail (class->set_arg != NULL);
memset (&arg, 0, sizeof (arg));
arg.type = G_VALUE_TYPE (value);
gtk_arg_set_from_value (&arg, value, FALSE);
arg.name = pspec->name;
class->set_arg (GTK_OBJECT (object), &arg, property_id);
}
static void
gtk_arg_proxy_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GtkObjectClass *class = g_type_class_peek (pspec->owner_type);
GtkArg arg;
g_return_if_fail (class->get_arg != NULL);
memset (&arg, 0, sizeof (arg));
arg.type = G_VALUE_TYPE (value);
arg.name = pspec->name;
class->get_arg (GTK_OBJECT (object), &arg, property_id);
gtk_arg_to_value (&arg, value);
}
void
gtk_object_add_arg_type (const gchar *arg_name,
GType arg_type,
guint arg_flags,
guint arg_id)
{
GObjectClass *oclass;
GParamSpec *pspec;
gchar *type_name, *pname;
GType type;
g_return_if_fail (arg_name != NULL);
g_return_if_fail (arg_type > G_TYPE_NONE);
g_return_if_fail (arg_id > 0);
g_return_if_fail (arg_flags & G_PARAM_READWRITE);
if (arg_flags & G_PARAM_CONSTRUCT)
g_return_if_fail ((arg_flags & G_PARAM_CONSTRUCT_ONLY) == 0);
if (arg_flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))
g_return_if_fail (arg_flags & G_PARAM_WRITABLE);
g_return_if_fail ((arg_flags & ~(G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME)) == 0);
pname = strchr (arg_name, ':');
g_return_if_fail (pname && pname[1] == ':');
type_name = g_strndup (arg_name, pname - arg_name);
pname += 2;
type = g_type_from_name (type_name);
g_free (type_name);
g_return_if_fail (G_TYPE_IS_OBJECT (type));
oclass = gtk_type_class (type);
if (arg_flags & G_PARAM_READABLE)
{
if (oclass->get_property && oclass->get_property != gtk_arg_proxy_get_property)
{
g_warning (G_STRLOC ": GtkArg compatibility code can't be mixed with customized %s.get_property() implementation",
g_type_name (type));
return;
}
oclass->get_property = gtk_arg_proxy_get_property;
}
if (arg_flags & G_PARAM_WRITABLE)
{
if (oclass->set_property && oclass->set_property != gtk_arg_proxy_set_property)
{
g_warning (G_STRLOC ": GtkArg compatibility code can't be mixed with customized %s.set_property() implementation",
g_type_name (type));
return;
}
oclass->set_property = gtk_arg_proxy_set_property;
}
switch (G_TYPE_FUNDAMENTAL (arg_type))
{
case G_TYPE_ENUM:
pspec = g_param_spec_enum (pname, NULL, NULL, arg_type, 0, arg_flags);
break;
case G_TYPE_FLAGS:
pspec = g_param_spec_flags (pname, NULL, NULL, arg_type, 0, arg_flags);
break;
case G_TYPE_CHAR:
pspec = g_param_spec_char (pname, NULL, NULL, -128, 127, 0, arg_flags);
break;
case G_TYPE_UCHAR:
pspec = g_param_spec_uchar (pname, NULL, NULL, 0, 255, 0, arg_flags);
break;
case G_TYPE_BOOLEAN:
pspec = g_param_spec_boolean (pname, NULL, NULL, FALSE, arg_flags);
break;
case G_TYPE_INT:
pspec = g_param_spec_int (pname, NULL, NULL, G_MININT, G_MAXINT, 0, arg_flags);
break;
case G_TYPE_UINT:
pspec = g_param_spec_uint (pname, NULL, NULL, 0, G_MAXUINT, 0, arg_flags);
break;
case G_TYPE_FLOAT:
pspec = g_param_spec_float (pname, NULL, NULL, -G_MAXFLOAT, G_MAXFLOAT, 0, arg_flags);
break;
case G_TYPE_DOUBLE:
pspec = g_param_spec_double (pname, NULL, NULL, -G_MAXDOUBLE, G_MAXDOUBLE, 0, arg_flags);
break;
case G_TYPE_STRING:
pspec = g_param_spec_string (pname, NULL, NULL, NULL, arg_flags);
break;
case G_TYPE_POINTER:
pspec = g_param_spec_pointer (pname, NULL, NULL, arg_flags);
break;
case G_TYPE_OBJECT:
pspec = g_param_spec_object (pname, NULL, NULL, arg_type, arg_flags);
break;
case G_TYPE_BOXED:
if (!G_TYPE_IS_FUNDAMENTAL (arg_type))
{
pspec = g_param_spec_boxed (pname, NULL, NULL, arg_type, arg_flags);
break;
}
default:
g_warning (G_STRLOC ": Property type `%s' is not supported by the GtkArg compatibility code",
g_type_name (arg_type));
return;
}
g_object_class_install_property (oclass, arg_id, pspec);
}
static guint (*gobject_floating_flag_handler) (GtkObject*,gint) = NULL;
static guint
gtk_object_floating_flag_handler (GtkObject *object,
gint job)
{
/* FIXME: remove this whole thing once GTK+ breaks ABI */
if (!GTK_IS_OBJECT (object))
return gobject_floating_flag_handler (object, job);
switch (job)
{
guint32 oldvalue;
case +1: /* force floating if possible */
do
oldvalue = g_atomic_int_get (&object->flags);
while (!g_atomic_int_compare_and_exchange ((gint *)&object->flags, oldvalue, oldvalue | GTK_FLOATING));
return oldvalue & GTK_FLOATING;
case -1: /* sink if possible */
do
oldvalue = g_atomic_int_get (&object->flags);
while (!g_atomic_int_compare_and_exchange ((gint *)&object->flags, oldvalue, oldvalue & ~(guint32) GTK_FLOATING));
return oldvalue & GTK_FLOATING;
default: /* check floating */
return 0 != (g_atomic_int_get (&object->flags) & GTK_FLOATING);
}
}
static void
gtk_object_class_init (GtkObjectClass *class)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (class);
gboolean is_glib_2_10_1;
parent_class = g_type_class_ref (G_TYPE_OBJECT);
is_glib_2_10_1 = g_object_compat_control (3, &gobject_floating_flag_handler);
if (!is_glib_2_10_1)
g_error ("this version of Gtk+ requires GLib-2.10.1");
g_object_compat_control (2, gtk_object_floating_flag_handler);
gobject_class->set_property = gtk_object_set_property;
gobject_class->get_property = gtk_object_get_property;
gobject_class->dispose = gtk_object_dispose;
gobject_class->finalize = gtk_object_finalize;
class->destroy = gtk_object_real_destroy;
g_object_class_install_property (gobject_class,
PROP_USER_DATA,
g_param_spec_pointer ("user-data",
P_("User Data"),
P_("Anonymous User Data Pointer"),
GTK_PARAM_READWRITE));
object_signals[DESTROY] =
g_signal_new (I_("destroy"),
G_TYPE_FROM_CLASS (gobject_class),
@ -384,12 +126,6 @@ static void
gtk_object_init (GtkObject *object,
GtkObjectClass *klass)
{
gboolean was_floating;
/* sink the GInitiallyUnowned floating flag */
was_floating = gobject_floating_flag_handler (object, -1);
/* set GTK_FLOATING via gtk_object_floating_flag_handler */
if (was_floating)
g_object_force_floating (G_OBJECT (object));
}
/********************************************
@ -399,7 +135,6 @@ gtk_object_init (GtkObject *object,
void
gtk_object_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
if (!(GTK_OBJECT_FLAGS (object) & GTK_IN_DESTRUCTION))
@ -445,336 +180,8 @@ gtk_object_finalize (GObject *gobject)
"and must be removed with g_object_ref_sink().");
}
gtk_object_notify_weaks (object);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
/*****************************************
* GtkObject argument handlers
*
*****************************************/
static void
gtk_object_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
case PROP_USER_DATA:
g_object_set_data (G_OBJECT (object), I_("user_data"), g_value_get_pointer (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gtk_object_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
switch (property_id)
{
case PROP_USER_DATA:
g_value_set_pointer (value, g_object_get_data (G_OBJECT (object), "user_data"));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
void
gtk_object_sink (GtkObject *object)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_object_ref_sink (object);
g_object_unref (object);
}
/*****************************************
* Weak references.
*
* Weak refs are very similar to the old "destroy" signal. They allow
* one to register a callback that is called when the weakly
* referenced object is finalized.
*
* They are not implemented as a signal because they really are
* special and need to be used with great care. Unlike signals, which
* should be able to execute any code whatsoever.
*
* A weakref callback is not allowed to retain a reference to the
* object. Object data keys may be retrieved in a weak reference
* callback.
*
* A weakref callback is called at most once.
*
*****************************************/
typedef struct _GtkWeakRef GtkWeakRef;
struct _GtkWeakRef
{
GtkWeakRef *next;
GDestroyNotify notify;
gpointer data;
};
void
gtk_object_weakref (GtkObject *object,
GDestroyNotify notify,
gpointer data)
{
GtkWeakRef *weak;
g_return_if_fail (notify != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
if (!quark_weakrefs)
quark_weakrefs = g_quark_from_static_string ("gtk-weakrefs");
weak = g_new (GtkWeakRef, 1);
weak->next = g_object_get_qdata (G_OBJECT (object), quark_weakrefs);
weak->notify = notify;
weak->data = data;
g_object_set_qdata (G_OBJECT (object), quark_weakrefs, weak);
}
void
gtk_object_weakunref (GtkObject *object,
GDestroyNotify notify,
gpointer data)
{
GtkWeakRef *weaks, *w, **wp;
g_return_if_fail (GTK_IS_OBJECT (object));
if (!quark_weakrefs)
return;
weaks = g_object_get_qdata (G_OBJECT (object), quark_weakrefs);
for (wp = &weaks; *wp; wp = &(*wp)->next)
{
w = *wp;
if (w->notify == notify && w->data == data)
{
if (w == weaks)
g_object_set_qdata (G_OBJECT (object), quark_weakrefs, w->next);
else
*wp = w->next;
g_free (w);
return;
}
}
}
static void
gtk_object_notify_weaks (GtkObject *object)
{
if (quark_weakrefs)
{
GtkWeakRef *w1, *w2;
w1 = g_object_get_qdata (G_OBJECT (object), quark_weakrefs);
while (w1)
{
w1->notify (w1->data);
w2 = w1->next;
g_free (w1);
w1 = w2;
}
}
}
GtkObject*
gtk_object_new (GType object_type,
const gchar *first_property_name,
...)
{
GtkObject *object;
va_list var_args;
g_return_val_if_fail (G_TYPE_IS_OBJECT (object_type), NULL);
va_start (var_args, first_property_name);
object = (GtkObject *)g_object_new_valist (object_type, first_property_name, var_args);
va_end (var_args);
return object;
}
void
gtk_object_get (GtkObject *object,
const gchar *first_property_name,
...)
{
va_list var_args;
g_return_if_fail (GTK_IS_OBJECT (object));
va_start (var_args, first_property_name);
g_object_get_valist (G_OBJECT (object), first_property_name, var_args);
va_end (var_args);
}
void
gtk_object_set (GtkObject *object,
const gchar *first_property_name,
...)
{
va_list var_args;
g_return_if_fail (GTK_IS_OBJECT (object));
va_start (var_args, first_property_name);
g_object_set_valist (G_OBJECT (object), first_property_name, var_args);
va_end (var_args);
}
/*****************************************
* GtkObject object_data mechanism
*
*****************************************/
void
gtk_object_set_data_by_id (GtkObject *object,
GQuark data_id,
gpointer data)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_datalist_id_set_data (&G_OBJECT (object)->qdata, data_id, data);
}
void
gtk_object_set_data (GtkObject *object,
const gchar *key,
gpointer data)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
g_datalist_set_data (&G_OBJECT (object)->qdata, key, data);
}
void
gtk_object_set_data_by_id_full (GtkObject *object,
GQuark data_id,
gpointer data,
GDestroyNotify destroy)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_datalist_id_set_data_full (&G_OBJECT (object)->qdata, data_id, data, destroy);
}
void
gtk_object_set_data_full (GtkObject *object,
const gchar *key,
gpointer data,
GDestroyNotify destroy)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
g_datalist_set_data_full (&G_OBJECT (object)->qdata, key, data, destroy);
}
gpointer
gtk_object_get_data_by_id (GtkObject *object,
GQuark data_id)
{
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
return g_datalist_id_get_data (&G_OBJECT (object)->qdata, data_id);
}
gpointer
gtk_object_get_data (GtkObject *object,
const gchar *key)
{
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
g_return_val_if_fail (key != NULL, NULL);
return g_datalist_get_data (&G_OBJECT (object)->qdata, key);
}
void
gtk_object_remove_data_by_id (GtkObject *object,
GQuark data_id)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_datalist_id_remove_data (&G_OBJECT (object)->qdata, data_id);
}
void
gtk_object_remove_data (GtkObject *object,
const gchar *key)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
g_datalist_remove_data (&G_OBJECT (object)->qdata, key);
}
void
gtk_object_remove_no_notify_by_id (GtkObject *object,
GQuark key_id)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_datalist_id_remove_no_notify (&G_OBJECT (object)->qdata, key_id);
}
void
gtk_object_remove_no_notify (GtkObject *object,
const gchar *key)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
g_datalist_remove_no_notify (&G_OBJECT (object)->qdata, key);
}
void
gtk_object_set_user_data (GtkObject *object,
gpointer data)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_object_set_data (G_OBJECT (object), "user_data", data);
}
gpointer
gtk_object_get_user_data (GtkObject *object)
{
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
return g_object_get_data (G_OBJECT (object), "user_data");
}
GtkObject*
gtk_object_ref (GtkObject *object)
{
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
return (GtkObject*) g_object_ref ((GObject*) object);
}
void
gtk_object_unref (GtkObject *object)
{
g_return_if_fail (GTK_IS_OBJECT (object));
g_object_unref ((GObject*) object);
}
#define __GTK_OBJECT_C__
#include "gtkaliasdef.c"

View File

@ -82,9 +82,6 @@ G_BEGIN_DECLS
typedef enum
{
GTK_IN_DESTRUCTION = 1 << 0, /* Used internally during dispose */
#if !defined (GTK_DISABLE_DEPRECATED) || defined (GTK_COMPILATION)
GTK_FLOATING = 1 << 1,
#endif
GTK_RESERVED_1 = 1 << 2,
GTK_RESERVED_2 = 1 << 3
} GtkObjectFlags;
@ -92,9 +89,6 @@ typedef enum
/* Macros for extracting the object_flags from GtkObject.
*/
#define GTK_OBJECT_FLAGS(obj) (GTK_OBJECT (obj)->flags)
#ifndef GTK_DISABLE_DEPRECATED
#define GTK_OBJECT_FLOATING(obj) (g_object_is_floating (obj))
#endif
/* Macros for setting and clearing bits in the object_flags field of GtkObject.
*/
@ -120,14 +114,6 @@ struct _GtkObjectClass
{
GInitiallyUnownedClass parent_class;
/* Non overridable class methods to set and get per class arguments */
void (*set_arg) (GtkObject *object,
GtkArg *arg,
guint arg_id);
void (*get_arg) (GtkObject *object,
GtkArg *arg,
guint arg_id);
/* Default signal handler for the ::destroy signal, which is
* invoked to request that references to the widget be dropped.
* If an object class overrides destroy() in order to perform class
@ -139,112 +125,12 @@ struct _GtkObjectClass
void (*destroy) (GtkObject *object);
};
/* Application-level methods */
GType gtk_object_get_type (void) G_GNUC_CONST;
#ifndef GTK_DISABLE_DEPRECATED
void gtk_object_sink (GtkObject *object);
#endif
void gtk_object_destroy (GtkObject *object);
/****************************************************************/
#ifndef GTK_DISABLE_DEPRECATED
GtkObject* gtk_object_new (GType type,
const gchar *first_property_name,
...);
GtkObject* gtk_object_ref (GtkObject *object);
void gtk_object_unref (GtkObject *object);
void gtk_object_weakref (GtkObject *object,
GDestroyNotify notify,
gpointer data);
void gtk_object_weakunref (GtkObject *object,
GDestroyNotify notify,
gpointer data);
/* Set 'data' to the "object_data" field of the object. The
* data is indexed by the "key". If there is already data
* associated with "key" then the new data will replace it.
* If 'data' is NULL then this call is equivalent to
* 'gtk_object_remove_data'.
* The gtk_object_set_data_full variant acts just the same,
* but takes an additional argument which is a function to
* be called when the data is removed.
* `gtk_object_remove_data' is equivalent to the above,
* where 'data' is NULL
* `gtk_object_get_data' gets the data associated with "key".
*/
void gtk_object_set_data (GtkObject *object,
const gchar *key,
gpointer data);
void gtk_object_set_data_full (GtkObject *object,
const gchar *key,
gpointer data,
GDestroyNotify destroy);
void gtk_object_remove_data (GtkObject *object,
const gchar *key);
gpointer gtk_object_get_data (GtkObject *object,
const gchar *key);
void gtk_object_remove_no_notify (GtkObject *object,
const gchar *key);
/* Set/get the "user_data" object data field of "object". It should
* be noted that these functions are no different than calling
* `gtk_object_set_data'/`gtk_object_get_data' with a key of "user_data".
* They are merely provided as a convenience.
*/
void gtk_object_set_user_data (GtkObject *object,
gpointer data);
gpointer gtk_object_get_user_data (GtkObject *object);
/* Object-level methods */
/* Object data method variants that operate on key ids. */
void gtk_object_set_data_by_id (GtkObject *object,
GQuark data_id,
gpointer data);
void gtk_object_set_data_by_id_full (GtkObject *object,
GQuark data_id,
gpointer data,
GDestroyNotify destroy);
gpointer gtk_object_get_data_by_id (GtkObject *object,
GQuark data_id);
void gtk_object_remove_data_by_id (GtkObject *object,
GQuark data_id);
void gtk_object_remove_no_notify_by_id (GtkObject *object,
GQuark key_id);
#define gtk_object_data_try_key g_quark_try_string
#define gtk_object_data_force_id g_quark_from_string
/* GtkArg flag bits for gtk_object_add_arg_type
*/
typedef enum
{
GTK_ARG_READABLE = G_PARAM_READABLE,
GTK_ARG_WRITABLE = G_PARAM_WRITABLE,
GTK_ARG_CONSTRUCT = G_PARAM_CONSTRUCT,
GTK_ARG_CONSTRUCT_ONLY = G_PARAM_CONSTRUCT_ONLY,
GTK_ARG_CHILD_ARG = 1 << 4
} GtkArgFlags;
#define GTK_ARG_READWRITE (GTK_ARG_READABLE | GTK_ARG_WRITABLE)
void gtk_object_get (GtkObject *object,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
void gtk_object_set (GtkObject *object,
const gchar *first_property_name,
...) G_GNUC_NULL_TERMINATED;
void gtk_object_add_arg_type (const gchar *arg_name,
GType arg_type,
guint arg_flags,
guint arg_id);
#endif /* GTK_DISABLE_DEPRECATED */
G_END_DECLS
#endif /* __GTK_OBJECT_H__ */

View File

@ -32,28 +32,16 @@ floating_tests (void)
GtkWidget *widget = g_object_new (GTK_TYPE_LABEL, NULL);
g_object_connect (widget, "signal::destroy", destroy, NULL, NULL);
g_assert (GTK_OBJECT_FLOATING (widget));
g_assert (g_object_is_floating (widget));
GTK_OBJECT_UNSET_FLAGS (widget, GTK_FLOATING);
g_assert (!GTK_OBJECT_FLOATING (widget));
g_assert (!g_object_is_floating (widget));
GTK_OBJECT_SET_FLAGS (widget, GTK_FLOATING);
g_assert (GTK_OBJECT_FLOATING (widget));
g_assert (g_object_is_floating (widget));
g_object_ref_sink (widget);
g_assert (!GTK_OBJECT_FLOATING (widget));
g_assert (!g_object_is_floating (widget));
g_object_force_floating (G_OBJECT (widget));
g_assert (GTK_OBJECT_FLOATING (widget));
g_assert (g_object_is_floating (widget));
g_object_ref (widget);
gtk_object_sink (GTK_OBJECT (widget));
g_assert (!GTK_OBJECT_FLOATING (widget));
g_object_ref_sink (widget);
g_assert (!g_object_is_floating (widget));
g_assert (!destroyed);