aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/menuitem.c29
-rw-r--r--libdbusmenu-glib/menuitem.h2
2 files changed, 22 insertions, 9 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index 747cc01..827d6c5 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -930,7 +930,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);
}
@@ -1001,14 +1004,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
@@ -1016,7 +1027,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;
diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h
index 0058ded..a4c7611 100644
--- a/libdbusmenu-glib/menuitem.h
+++ b/libdbusmenu-glib/menuitem.h
@@ -128,6 +128,7 @@ typedef void (*dbusmenu_menuitem_buildxml_slot_t) (DbusmenuMenuitem * mi, GPtrAr
* @child_removed: Slot for #DbusmenuMenuitem::child-removed.
* @child_moved: Slot for #DbusmenuMenuitem::child-moved.
* @realized: Slot for #DbusmenuMenuitem::realized.
+ * @about_to_show: Slot for #DbusmenuMenuitem::about-to-show.
* @buildxml: Virtual function that appends the strings required to represent this menu item in the menu XML file.
* @handle_event: This function is to override how events are handled by subclasses. Look at #dbusmenu_menuitem_handle_event for lots of good information.
* @send_about_to_show: Virtual function that notifies server that the client is about to show a menu.
@@ -167,6 +168,7 @@ struct _DbusmenuMenuitemClass
void (*reserved3) (void);
void (*reserved4) (void);
void (*reserved5) (void);
+ void (*reserved6) (void);
};
GType dbusmenu_menuitem_get_type (void);