From 40d62d0dd7ba5d5cc9dd00beb72599535f84ae8a Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Mon, 20 Nov 2000 22:24:12 +0000 Subject: [PATCH] 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 --- gobject/ChangeLog | 7 +++++++ gobject/gobject.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++ gobject/gobject.h | 11 +++++++++++ 3 files changed, 68 insertions(+) diff --git a/gobject/ChangeLog b/gobject/ChangeLog index 0911c3aed..829b66185 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 c4dd8601c..8f94c18c8 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 99529af39..7c31d6af4 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,