Commit 294cfcdb authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

make use of *_by_id() functions for handler key.

Sat Mar 14 02:03:13 1998  Tim Janik  <timj@gimp.org>

        * gtk/gtksignal.c: make use of *_by_id() functions for handler key.

        * gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
        (gtk_widget_shutdown): new function to perform pre-destruction shutdown
        of the widget.
        (gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)

        * gtk/gtkobject.h:
        * gtk/gtkobject.c: GtkObject destruction is now split into an internally
        used shutdown class method and the usual GtkObject::destroy signal
        emission. this allowes for class based shutdown functionality prior
        to actuall object destruction.
        added *_by_id() counterparts for gtk_object_data_* functions, meant for
        internal use only.

        * gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
        a GtkObject once gtk_main() of a certain level finishes. it is save to
        destroy the object prior to that, gtk_quit_add_destroy will only destroy
        objects that are still existing.
parent 3ef2c37a
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
Sat Mar 14 02:03:13 1998 Tim Janik <timj@gimp.org>
* gtk/gtksignal.c: make use of *_by_id() functions for handler key.
* gtk/gtkwidget.c: make use of *_by_id() functions for a bunch of keys.
(gtk_widget_shutdown): new function to perform pre-destruction shutdown
of the widget.
(gtk_widget_unparent): call gtk_widget_set_parent_window(widget,NULL)
* gtk/gtkobject.h:
* gtk/gtkobject.c: GtkObject destruction is now split into an internally
used shutdown class method and the usual GtkObject::destroy signal
emission. this allowes for class based shutdown functionality prior
to actuall object destruction.
added *_by_id() counterparts for gtk_object_data_* functions, meant for
internal use only.
* gtk/gtkmain.c (gtk_quit_add_destroy): new function which will destroy
a GtkObject once gtk_main() of a certain level finishes. it is save to
destroy the object prior to that, gtk_quit_add_destroy will only destroy
objects that are still existing.
1998-03-13 Federico Mena Quintero <federico@nuclecu.unam.mx>
* gtk/gtkclist.c (gtk_clist_row_is_visible): Now we return a
......
......@@ -68,11 +68,10 @@ static void gtk_object_set_arg (GtkObject *object,
static void gtk_object_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_object_shutdown (GtkObject *object);
static void gtk_object_real_destroy (GtkObject *object);
static void gtk_object_finalize (GtkObject *object);
static void gtk_object_notify_weaks (gpointer data);
static void gtk_object_data_init (void);
static GtkObjectData* gtk_object_data_new (void);
static void gtk_object_data_destroy (GtkObjectData *odata);
static guint* gtk_object_data_id_alloc (void);
......@@ -82,7 +81,6 @@ GtkArg* gtk_object_collect_args (guint *nargs,
static guint object_signals[LAST_SIGNAL] = { 0 };
static gint object_data_init = TRUE;
static GHashTable *object_data_ht = NULL;
static GMemChunk *object_data_mem_chunk = NULL;
static GSList *object_data_id_list = NULL;
......@@ -91,6 +89,7 @@ static guint object_data_id_index = 0;
static GHashTable *arg_info_ht = NULL;
static const gchar *user_data_key = "user_data";
static guint user_data_key_id = 0;
#ifdef G_ENABLE_DEBUG
......@@ -127,13 +126,10 @@ gtk_object_pointer_hash (const gpointer v)
}
#endif /* G_ENABLE_DEBUG */
/*****************************************
* gtk_object_init_type:
*
* arguments:
/****************************************************
* GtkObject type, class and instance initialization
*
* results:
*****************************************/
****************************************************/
void
gtk_object_init_type ()
......@@ -165,14 +161,6 @@ gtk_object_get_type ()
return GTK_TYPE_OBJECT;
}
/*****************************************
* gtk_object_class_init:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_class_init (GtkObjectClass *class)
{
......@@ -203,35 +191,11 @@ gtk_object_class_init (GtkObjectClass *class)
gtk_object_class_add_signals (class, object_signals, LAST_SIGNAL);
class->shutdown = gtk_object_shutdown;
class->destroy = gtk_object_real_destroy;
class->finalize = gtk_object_finalize;
}
/*****************************************
* gtk_object_real_destroy:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_real_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
gtk_signal_handlers_destroy (object);
}
/*****************************************
* gtk_object_init:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_init (GtkObject *object)
{
......@@ -253,12 +217,61 @@ gtk_object_init (GtkObject *object)
#endif /* G_ENABLE_DEBUG */
}
/*****************************************
* gtk_object_set_arg:
/********************************************
* Functions to end a GtkObject's life time
*
* arguments:
********************************************/
void
gtk_object_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
if (!GTK_OBJECT_DESTROYED (object))
{
/* we will hold a reference on the object in this place, so
* to ease all classes shutdown and destroy implementations.
* i.e. they don't have to bother about referencing at all.
*/
gtk_object_ref (object);
object->klass->shutdown (object);
gtk_object_unref (object);
}
}
static void
gtk_object_shutdown (GtkObject *object)
{
GTK_OBJECT_SET_FLAGS (object, GTK_DESTROYED);
gtk_signal_emit (object, object_signals[DESTROY]);
}
static void
gtk_object_real_destroy (GtkObject *object)
{
gtk_signal_handlers_destroy (object);
}
static void
gtk_object_finalize (GtkObject *object)
{
GtkObjectData *odata, *next;
odata = object->object_data;
while (odata)
{
next = odata->next;
gtk_object_data_destroy (odata);
odata = next;
}
g_free (object);
}
/*****************************************
* GtkObject argument handlers
*
* results:
*****************************************/
static void
......@@ -299,14 +312,6 @@ gtk_object_set_arg (GtkObject *object,
}
}
/*****************************************
* gtk_object_get_arg:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_get_arg (GtkObject *object,
GtkArg *arg,
......@@ -408,30 +413,6 @@ gtk_object_class_add_user_signal (GtkObjectClass *class,
return signal_id;
}
/*****************************************
* gtk_object_finalize:
*
* arguments:
*
* results:
*****************************************/
static void
gtk_object_finalize (GtkObject *object)
{
GtkObjectData *odata, *next;
odata = object->object_data;
while (odata)
{
next = odata->next;
gtk_object_data_destroy (odata);
odata = next;
}
g_free (object);
}
/*****************************************
* gtk_object_sink:
*
......@@ -453,27 +434,6 @@ gtk_object_sink (GtkObject *object)
}
}
/*****************************************
* gtk_object_destroy:
*
* arguments:
*
* results:
*****************************************/
void
gtk_object_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
if (!GTK_OBJECT_DESTROYED (object))
{
GTK_OBJECT_SET_FLAGS (object, GTK_DESTROYED);
gtk_signal_emit (object, object_signals[DESTROY]);
}
}
/*****************************************
* Weak references.
*
......@@ -988,158 +948,236 @@ gtk_object_get_arg_type (const gchar *arg_name)
}
/*****************************************
* gtk_object_set_data:
* GtkObject object_data mechanism
*
* arguments:
*
* results:
*****************************************/
void
gtk_object_set_data_by_id (GtkObject *object,
guint data_id,
gpointer data)
{
g_return_if_fail (data_id > 0);
gtk_object_set_data_by_id_full (object, data_id, data, NULL);
}
void
gtk_object_set_data (GtkObject *object,
const gchar *key,
gpointer data)
{
gtk_object_set_data_full (object, key, data, NULL);
g_return_if_fail (key != NULL);
gtk_object_set_data_by_id_full (object, gtk_object_data_force_id (key), data, NULL);
}
/*****************************************
* gtk_object_set_data_full:
*
* arguments:
*
* results:
*****************************************/
void
gtk_object_set_data_full (GtkObject *object,
const gchar *key,
gpointer data,
GtkDestroyNotify destroy)
gtk_object_set_data_by_id_full (GtkObject *object,
guint data_id,
gpointer data,
GtkDestroyNotify destroy)
{
GtkObjectData *odata;
GtkObjectData *prev;
guint *id;
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
g_return_if_fail (key != NULL);
if (object_data_init)
gtk_object_data_init ();
id = g_hash_table_lookup (object_data_ht, (gpointer) key);
g_return_if_fail (data_id > 0);
if (!data)
{
if (id)
prev = NULL;
odata = object->object_data;
while (odata)
{
prev = NULL;
odata = object->object_data;
while (odata)
if (odata->id == data_id)
{
if (odata->id == *id)
{
if (prev)
prev->next = odata->next;
if (odata == object->object_data)
object->object_data = odata->next;
gtk_object_data_destroy (odata);
break;
}
prev = odata;
odata = odata->next;
if (prev)
prev->next = odata->next;
if (odata == object->object_data)
object->object_data = odata->next;
gtk_object_data_destroy (odata);
break;
}
prev = odata;
odata = odata->next;
}
}
else
{
if (!id)
{
id = gtk_object_data_id_alloc ();
g_hash_table_insert (object_data_ht, (gpointer) g_strdup (key), id);
}
odata = object->object_data;
while (odata)
{
if (odata->id == *id)
if (odata->id == data_id)
{
if (odata->destroy)
odata->destroy (odata->data);
odata->data = data;
odata->destroy = destroy;
return;
}
odata = odata->next;
}
odata = gtk_object_data_new ();
odata->id = *id;
if (!object_data_mem_chunk)
object_data_mem_chunk = g_mem_chunk_new ("object data mem chunk",
sizeof (GtkObjectData),
1024, G_ALLOC_AND_FREE);
odata = g_chunk_new (GtkObjectData, object_data_mem_chunk);
odata->id = data_id;
odata->data = data;
odata->destroy = destroy;
odata->next = object->object_data;
object->object_data = odata;
}
}
/*****************************************
* gtk_object_get_data:
*
* arguments:
*
* results:
*****************************************/
void
gtk_object_set_data_full (GtkObject *object,
const gchar *key,
gpointer data,
GtkDestroyNotify destroy)
{
g_return_if_fail (key != NULL);
gtk_object_set_data_by_id_full (object, gtk_object_data_force_id (key), data, destroy);
}
guint
gtk_object_data_force_id (const gchar *key)
{
guint *id;
g_return_val_if_fail (key != NULL, 0);
if (!object_data_ht)
object_data_ht = g_hash_table_new (g_str_hash, g_str_equal);
id = g_hash_table_lookup (object_data_ht, (gpointer) key);
if (!id)
{
id = gtk_object_data_id_alloc ();
g_hash_table_insert (object_data_ht, g_strdup (key), id);
}
return *id;
}
gpointer
gtk_object_get_data (GtkObject *object,
const gchar *key)
gtk_object_get_data_by_id (GtkObject *object,
guint data_id)
{
GtkObjectData *odata;
guint *id;
g_return_val_if_fail (object != NULL, NULL);
g_return_val_if_fail (GTK_IS_OBJECT (object), NULL);
g_return_val_if_fail (key != NULL, NULL);
if (object_data_init)
gtk_object_data_init ();
id = g_hash_table_lookup (object_data_ht, (gpointer) key);
if (id)
if (data_id)
{
odata = object->object_data;
while (odata)
{
if (odata->id == *id)
if (odata->id == data_id)
return odata->data;
odata = odata->next;
}
}
return NULL;
}
gpointer
gtk_object_get_data (GtkObject *object,
const gchar *key)
{
guint id;
g_return_val_if_fail (key != NULL, NULL);
id = gtk_object_data_try_key (key);
if (id)
return gtk_object_get_data_by_id (object, id);
return NULL;
}
/*****************************************
* gtk_object_remove_data:
*
* arguments:
*
* results:
*****************************************/
guint
gtk_object_data_try_key (const gchar *key)
{
g_return_val_if_fail (key != NULL, 0);
if (object_data_ht)
{
guint *id;
id = g_hash_table_lookup (object_data_ht, (gpointer) key);
if (id)
return *id;
}
return 0;
}
void
gtk_object_remove_data_by_id (GtkObject *object,
guint data_id)
{
if (data_id)
gtk_object_set_data_by_id_full (object, data_id, NULL, NULL);
}
void
gtk_object_remove_data (GtkObject *object,
const gchar *key)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GTK_IS_OBJECT (object));
gint id;
g_return_if_fail (key != NULL);
gtk_object_set_data_full (object, key, NULL, NULL);
id = gtk_object_data_try_key (key);
if (id)
gtk_object_set_data_by_id_full (object, id, NULL, NULL);
}
static void
gtk_object_data_destroy (GtkObjectData *odata)
{
g_return_if_fail (odata != NULL);
if (odata->destroy)
odata->destroy (odata->data);
g_mem_chunk_free (object_data_mem_chunk, odata);
}
static guint*
gtk_object_data_id_alloc ()