From: Havoc Pennington Date: Mon, 20 Nov 2000 22:24:12 +0000 (+0000) Subject: More convenient data-setting functions X-Git-Tag: GLIB_1_2_9PRE1~110 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40d62d0dd7ba5d5cc9dd00beb72599535f84ae8a;p=platform%2Fupstream%2Fglib.git More convenient data-setting functions 2000-11-20 Havoc Pennington * gobject.c (g_object_get_data) (g_object_set_data) (g_object_set_data_full) (g_object_steal_data): More convenient data-setting functions --- diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 0911c3a..829b661 100644 --- a/gobject/ChangeLog +++ b/gobject/ChangeLog @@ -1,3 +1,10 @@ +2000-11-20 Havoc Pennington + + * gobject.c (g_object_get_data) + (g_object_set_data) + (g_object_set_data_full) + (g_object_steal_data): More convenient data-setting functions + Wed Nov 15 20:58:05 2000 Owen Taylor * gtypemodule.c (g_type_module_use): If loading the diff --git a/gobject/gobject.c b/gobject/gobject.c index c4dd860..8f94c18 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -795,6 +795,56 @@ g_object_steal_qdata (GObject *object, return g_datalist_id_remove_no_notify (&object->qdata, quark); } +gpointer +g_object_get_data (GObject *object, + const gchar *key) +{ + g_return_val_if_fail (G_IS_OBJECT (object), NULL); + g_return_val_if_fail (key != NULL, NULL); + + return g_object_get_qdata (object, + g_quark_try_string (key)); +} + +void +g_object_set_data (GObject *object, + const gchar *key, + gpointer data) +{ + g_return_if_fail (G_IS_OBJECT (object)); + g_return_if_fail (key != NULL); + + g_object_set_qdata (object, + g_quark_from_string (key), + data); +} + +void +g_object_set_data_full (GObject *object, + const gchar *key, + gpointer data, + GDestroyNotify destroy) +{ + g_return_if_fail (G_IS_OBJECT (object)); + g_return_if_fail (key != NULL); + + g_object_set_qdata_full (object, + g_quark_from_string (key), + data, + destroy); +} + +gpointer +g_object_steal_data (GObject *object, + const gchar *key) +{ + g_return_val_if_fail (G_IS_OBJECT (object), NULL); + g_return_val_if_fail (key != NULL, NULL); + + return g_object_steal_qdata (object, + g_quark_try_string (key)); +} + static void g_value_object_init (GValue *value) { diff --git a/gobject/gobject.h b/gobject/gobject.h index 99529af..7c31d6a 100644 --- a/gobject/gobject.h +++ b/gobject/gobject.h @@ -149,6 +149,17 @@ void g_object_set_qdata_full (GObject *object, GDestroyNotify destroy); gpointer g_object_steal_qdata (GObject *object, GQuark quark); +gpointer g_object_get_data (GObject *object, + const gchar *key); +void g_object_set_data (GObject *object, + const gchar *key, + gpointer data); +void g_object_set_data_full (GObject *object, + const gchar *key, + gpointer data, + GDestroyNotify destroy); +gpointer g_object_steal_data (GObject *object, + const gchar *key); void g_object_watch_closure (GObject *object, GClosure *closure); GClosure* g_cclosure_new_object (GCallback callback_func,