aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-06 10:32:54 -0600
committerTed Gould <ted@gould.cx>2011-01-06 10:32:54 -0600
commitbb9a2fed367273c305dc899c94e3a626779e5fd7 (patch)
treeefe388b61911c25f6303f8e04eb0c5bfe1d07ca5 /libdbusmenu-glib
parent13f405d76a1549715e153d5634dd82eb7dee0a82 (diff)
parentaa5fbb4484bf070d6569d6dbf17a250848a4d4ac (diff)
downloadlibdbusmenu-bb9a2fed367273c305dc899c94e3a626779e5fd7.tar.gz
libdbusmenu-bb9a2fed367273c305dc899c94e3a626779e5fd7.tar.bz2
libdbusmenu-bb9a2fed367273c305dc899c94e3a626779e5fd7.zip
* Upstream Merge
* Supporting removing properties
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/menuitem.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index ad6472b..1e892c3 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -913,7 +913,10 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, gint id)
gboolean
dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value)
{
- GVariant * variant = g_variant_new("s", value);
+ GVariant * variant = NULL;
+ if (value != NULL) {
+ variant = g_variant_new_string(value);
+ }
return dbusmenu_menuitem_property_set_variant(mi, property, variant);
}
@@ -984,14 +987,22 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi);
- gchar * lprop = g_strdup(property);
- g_variant_ref(value);
-
gboolean replaced = FALSE;
- gpointer currentval = g_hash_table_lookup(priv->properties, lprop);
- if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) {
- g_hash_table_replace(priv->properties, lprop, value);
- replaced = TRUE;
+ gpointer currentval = g_hash_table_lookup(priv->properties, property);
+
+ if (value != NULL) {
+ gchar * lprop = g_strdup(property);
+ g_variant_ref(value);
+
+ if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) {
+ g_hash_table_replace(priv->properties, lprop, value);
+ replaced = TRUE;
+ }
+ } else {
+ if (currentval != NULL) {
+ g_hash_table_remove(priv->properties, property);
+ replaced = TRUE;
+ }
}
/* NOTE: The actual value is invalid at this point
@@ -999,7 +1010,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
table. But the fact that there was a value is
the imporant part. */
if (currentval == NULL || replaced) {
- g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, value, TRUE);
+ g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE);
}
return TRUE;