From 088c421863751188f5702cd0703b343cb07a2dea Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 13 Nov 2009 12:02:08 -0600 Subject: Moving 'buildxml' into the private header file. --- libdbusmenu-glib/menuitem.c | 1 + 1 file changed, 1 insertion(+) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index fdf5608..d486b53 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -31,6 +31,7 @@ License version 3 and version 2.1 along with this program. If not, see #endif #include "menuitem.h" #include "menuitem-marshal.h" +#include "menuitem-private.h" #ifdef MASSIVEDEBUGGING #define LABEL(x) dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(x), DBUSMENU_MENUITEM_PROP_LABEL) -- cgit v1.2.3 From 2997a508fd49ebbbfa53d1c5fc5d0d56250de760 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 21:50:25 -0600 Subject: Switching the menuitem internal storage to be a hashtable of values. --- libdbusmenu-glib/menuitem.c | 78 +++++++++++++++++++++++++++++++++++++++++---- libdbusmenu-glib/menuitem.h | 4 ++- libdbusmenu-glib/server.c | 16 ---------- 3 files changed, 75 insertions(+), 23 deletions(-) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d486b53..77f8e90 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -213,6 +213,20 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) static guint menuitem_next_id = 1; +/* A small little function to both clear the insides of a + value as well as the memory it itself uses. */ +static void +g_value_free (gpointer data) +{ + if (data == NULL) return; + GValue * value = (GValue*)data; + g_value_unset(value); + g_free(data); + return; +} + +/* Initialize the values of the in the object, and build the + properties hash table. */ static void dbusmenu_menuitem_init (DbusmenuMenuitem *self) { @@ -221,7 +235,7 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->id = 0; priv->children = NULL; - priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_value_free); priv->root = FALSE; @@ -673,28 +687,59 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id) */ gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_STRING); + g_value_set_static_string(&val, value); + return dbusmenu_menuitem_property_set_value(mi, property, &val); +} + +/** + dbusmenu_menuitem_property_set: + @mi: The #DbusmenuMenuitem to set the property on. + @property: Name of the property to set. + @value: The value of the property. + + Takes the pair of @property and @value and places them as a + property on @mi. If a property already exists by that name, + then the value is set to the new value. If not, the property + is added. If the value is changed or the property was previously + unset then the signal #DbusmenuMenuitem::prop-changed will be + emitted by this function. + + Return value: A boolean representing if the property value was set. +*/ +gboolean +dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); g_return_val_if_fail(property != NULL, FALSE); + g_return_val_if_fail(G_IS_VALUE(value), FALSE); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); /* g_debug("Setting a property. ID: %d Prop: %s Value: %s", priv->id, property, value); */ + #if 0 gpointer lookup = g_hash_table_lookup(priv->properties, property); if (g_strcmp0((gchar *)lookup, value) == 0) { /* The value is the same as the value currently in the table so we don't really care. Just say everything's okay */ return TRUE; } + #endif gchar * lprop = g_strdup(property); - gchar * lval = g_strdup(value); + GValue * lval = g_new0(GValue, 1); + g_value_init(lval, G_VALUE_TYPE(value)); + g_value_copy(value, lval); g_hash_table_insert(priv->properties, lprop, lval); #ifdef MASSIVEDEBUGGING - g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(value, 50) < 25 ? value : ""); + gchar * valstr = g_strdup_value_contents(lval); + g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(valstr, 50) < 25 ? valstr : ""); + g_free(valstr); #endif - g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE); + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, lval, TRUE); return TRUE; } @@ -710,19 +755,40 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c Return value: A string with the value of the property that shouldn't be free'd. Or #NULL if the property - is not set. + is not set or is not a string. */ const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) +{ + const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); + if (value == NULL) return NULL; + if (G_VALUE_TYPE(value) != G_TYPE_STRING) return NULL; + return g_value_get_string(value); +} + +/** + dbusmenu_menuitem_property_get_value: + @mi: The #DbusmenuMenuitem to look for the property on. + @property: The property to grab. + + Look up a property on @mi and return the value of it if + it exits. #NULL will be returned if the property doesn't + exist. + + Return value: A GValue for the property. +*/ +const GValue * +dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); g_return_val_if_fail(property != NULL, NULL); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - return (const gchar *)g_hash_table_lookup(priv->properties, property); + return (const GValue *)g_hash_table_lookup(priv->properties, property); } + /** dbusmenu_menuitem_property_exit: @mi: The #DbusmenuMenuitem to look for the property on. diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 27a86a2..f0615d7 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -94,7 +94,7 @@ struct _DbusmenuMenuitemClass GObjectClass parent_class; /* Signals */ - void (*property_changed) (gchar * property, gchar * value); + void (*property_changed) (gchar * property, GValue * value); void (*item_activated) (void); void (*child_added) (DbusmenuMenuitem * child, guint position); void (*child_removed) (DbusmenuMenuitem * child); @@ -129,7 +129,9 @@ DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); +gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); +const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 73c21e2..f61b0fb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -442,16 +442,6 @@ _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * proper return TRUE; } -static void -value_table (gpointer pkey, gpointer pvalue, gpointer phash) -{ - GValue * value = g_new0(GValue, 1); - g_value_init(value, G_TYPE_STRING); - g_value_set_string(value, (gchar *)pvalue); - g_hash_table_insert((GHashTable *)phash, g_strdup((gchar *)pkey), value); - return; -} - static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error) { @@ -471,12 +461,6 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * *dict = dbusmenu_menuitem_properties_copy(mi); - GHashTable * newtable = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_foreach(*dict, value_table, newtable); - g_hash_table_destroy(*dict); - - *dict = newtable; - return TRUE; } -- cgit v1.2.3 From 030d27a1ca21c10ddad7f04848f60b0b2adc4c40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 11:50:59 -0600 Subject: Basic implementation of some helper getter/setters for GValues with int and bools --- libdbusmenu-glib/menuitem.c | 36 ++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/menuitem.h | 4 ++++ 2 files changed, 40 insertions(+) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 77f8e90..76ce79c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -694,6 +694,24 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c return dbusmenu_menuitem_property_set_value(mi, property, &val); } +gboolean +dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_BOOLEAN); + g_value_set_boolean(&val, value); + return dbusmenu_menuitem_property_set_value(mi, property, &val); +} + +gboolean +dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_INT); + g_value_set_int(&val, value); + return dbusmenu_menuitem_property_set_value(mi, property, &val); +} + /** dbusmenu_menuitem_property_set: @mi: The #DbusmenuMenuitem to set the property on. @@ -788,6 +806,24 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, property); } +gboolean +dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) +{ + const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); + if (value == NULL) return FALSE; + if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) return FALSE; + return g_value_get_boolean(value); +} + +gint +dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) +{ + const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); + if (value == NULL) return 0; + if (G_VALUE_TYPE(value) != G_TYPE_INT) return 0; + return g_value_get_int(value); +} + /** dbusmenu_menuitem_property_exit: diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index be56fc8..fc9e410 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -135,8 +135,12 @@ DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); +gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); +gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); +gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); +gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); -- cgit v1.2.3 From 655498939579199807de427c65597e503c84f3da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 13:17:20 -0600 Subject: Docs for the new functions. --- libdbusmenu-glib/menuitem.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 76ce79c..cec9486 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -694,6 +694,21 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c return dbusmenu_menuitem_property_set_value(mi, property, &val); } +/** + dbusmenu_menuitem_property_set_bool: + @mi: The #DbusmenuMenuitem to set the property on. + @property: Name of the property to set. + @value: The value of the property. + + Takes a boolean @value and sets it on @property as a + property on @mi. If a property already exists by that name, + then the value is set to the new value. If not, the property + is added. If the value is changed or the property was previously + unset then the signal #DbusmenuMenuitem::prop-changed will be + emitted by this function. + + Return value: A boolean representing if the property value was set. +*/ gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value) { @@ -703,6 +718,21 @@ dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * proper return dbusmenu_menuitem_property_set_value(mi, property, &val); } +/** + dbusmenu_menuitem_property_set_int: + @mi: The #DbusmenuMenuitem to set the property on. + @property: Name of the property to set. + @value: The value of the property. + + Takes a boolean @value and sets it on @property as a + property on @mi. If a property already exists by that name, + then the value is set to the new value. If not, the property + is added. If the value is changed or the property was previously + unset then the signal #DbusmenuMenuitem::prop-changed will be + emitted by this function. + + Return value: A boolean representing if the property value was set. +*/ gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value) { @@ -806,6 +836,16 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, property); } +/** + dbusmenu_menuitem_property_get_bool: + @mi: The #DbusmenuMenuitem to look for the property on. + @property: The property to grab. + + Look up a property on @mi and return the value of it if + it exits. Returns #FALSE if the property doesn't exist. + + Return value: The value of the property or #FALSE. +*/ gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) { @@ -815,6 +855,16 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper return g_value_get_boolean(value); } +/** + dbusmenu_menuitem_property_get_int: + @mi: The #DbusmenuMenuitem to look for the property on. + @property: The property to grab. + + Look up a property on @mi and return the value of it if + it exits. Returns zero if the property doesn't exist. + + Return value: The value of the property or zero. +*/ gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) { -- cgit v1.2.3 From 167d610ec25a9074c09dfc44e82995582b24b90a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 13:56:14 -0600 Subject: Adding in a couple of transfer functions so that we can be backwards compatible with our string way of doing things. --- libdbusmenu-glib/menuitem.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index cec9486..d8da357 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -26,6 +26,7 @@ License version 3 and version 2.1 along with this program. If not, see */ +#include #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -89,6 +90,8 @@ static void dbusmenu_menuitem_dispose (GObject *object); static void dbusmenu_menuitem_finalize (GObject *object); static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out); +static void g_value_transform_STRING_INT (const GValue * in, GValue * out); /* GObject stuff */ G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT); @@ -208,6 +211,37 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) 0, 30000, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + /* Check transfer functions for GValue */ + if (!g_value_type_transformable(G_TYPE_STRING, G_TYPE_BOOLEAN)) { + g_value_register_transform_func(G_TYPE_STRING, G_TYPE_BOOLEAN, g_value_transform_STRING_BOOLEAN); + } + if (!g_value_type_transformable(G_TYPE_STRING, G_TYPE_INT)) { + g_value_register_transform_func(G_TYPE_STRING, G_TYPE_INT, g_value_transform_STRING_INT); + } + + return; +} + +/* A little helper function to translate a string into + a boolean value */ +static void +g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out) +{ + const gchar * string = g_value_get_string(in); + if (!g_strcmp0(string, "TRUE") || !g_strcmp0(string, "true") || !g_strcmp0(string, "True")) { + g_value_set_boolean(out, TRUE); + } else { + g_value_set_boolean(out, FALSE); + } + return; +} + +/* A little helper function to translate a string into + a integer value */ +static void +g_value_transform_STRING_INT (const GValue * in, GValue * out) +{ + g_value_set_int(out, atoi(g_value_get_string(in))); return; } -- cgit v1.2.3 From 3bee257cedf6af6f94b2e77ee77f6eb76e784a90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 14:03:08 -0600 Subject: Adding in transforms for our getters. --- libdbusmenu-glib/menuitem.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d8da357..dc01157 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -885,7 +885,16 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper { const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return FALSE; - if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) return FALSE; + if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) { + if (g_value_type_transformable(G_VALUE_TYPE(value), G_TYPE_BOOLEAN)) { + GValue boolval = {0}; + g_value_init(&boolval, G_TYPE_BOOLEAN); + g_value_transform(value, &boolval); + return g_value_get_boolean(&boolval); + } else { + return FALSE; + } + } return g_value_get_boolean(value); } @@ -904,7 +913,16 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert { const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return 0; - if (G_VALUE_TYPE(value) != G_TYPE_INT) return 0; + if (G_VALUE_TYPE(value) != G_TYPE_INT) { + if (g_value_type_transformable(G_VALUE_TYPE(value), G_TYPE_INT)) { + GValue intval = {0}; + g_value_init(&intval, G_TYPE_INT); + g_value_transform(value, &intval); + return g_value_get_int(&intval); + } else { + return 0; + } + } return g_value_get_int(value); } -- cgit v1.2.3 From ad4bfb14e3449857f52f50bca76ce52ee72be5f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 21:58:26 -0600 Subject: Changing the prototype on the signal so that it isn't a string, but a value. --- libdbusmenu-glib/menuitem-marshal.list | 2 +- libdbusmenu-glib/menuitem.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem-marshal.list b/libdbusmenu-glib/menuitem-marshal.list index a32e7e3..dc4ba53 100644 --- a/libdbusmenu-glib/menuitem-marshal.list +++ b/libdbusmenu-glib/menuitem-marshal.list @@ -1,4 +1,4 @@ -VOID: STRING, STRING +VOID: STRING, POINTER VOID: OBJECT, UINT, UINT VOID: OBJECT, UINT VOID: OBJECT diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index dc01157..5d45e98 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -122,8 +122,8 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuMenuitemClass, property_changed), NULL, NULL, - _dbusmenu_menuitem_marshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + _dbusmenu_menuitem_marshal_VOID__STRING_POINTER, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); /** DbusmenuMenuitem::item-activated: @arg0: The #DbusmenuMenuitem object. -- cgit v1.2.3 From 8f3554c1f22f58ab8e601a4efc5eabfbf04c2349 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:09:02 -0600 Subject: Switching to just being a string and a pointer. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 5d45e98..ec37da5 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -123,7 +123,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_STRUCT_OFFSET(DbusmenuMenuitemClass, property_changed), NULL, NULL, _dbusmenu_menuitem_marshal_VOID__STRING_POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER); /** DbusmenuMenuitem::item-activated: @arg0: The #DbusmenuMenuitem object. -- cgit v1.2.3 From 9276f061d4565b57a160ece79ec547550195188b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:24:25 -0600 Subject: Making sure we get our function. --- libdbusmenu-glib/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ec37da5..2cefce4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -250,7 +250,7 @@ static guint menuitem_next_id = 1; /* A small little function to both clear the insides of a value as well as the memory it itself uses. */ static void -g_value_free (gpointer data) +_g_value_free (gpointer data) { if (data == NULL) return; GValue * value = (GValue*)data; @@ -269,7 +269,7 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->id = 0; priv->children = NULL; - priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_value_free); + priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free); priv->root = FALSE; -- cgit v1.2.3 From 7d0dbc3dd6be6ffaeca675b460767e20e505841e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 16:15:45 -0600 Subject: Switching to a replace so that new values are added. --- libdbusmenu-glib/menuitem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-glib/menuitem.c') diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 2cefce4..a03117c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -815,12 +815,13 @@ dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * prope g_value_init(lval, G_VALUE_TYPE(value)); g_value_copy(value, lval); - g_hash_table_insert(priv->properties, lprop, lval); + g_hash_table_replace(priv->properties, lprop, lval); #ifdef MASSIVEDEBUGGING gchar * valstr = g_strdup_value_contents(lval); g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(valstr, 50) < 25 ? valstr : ""); g_free(valstr); #endif + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, lval, TRUE); return TRUE; -- cgit v1.2.3