diff options
author | Chris Coulson <chrisccoulson@ubuntu.com> | 2011-02-28 22:47:04 +0000 |
---|---|---|
committer | Chris Coulson <chrisccoulson@ubuntu.com> | 2011-02-28 22:47:04 +0000 |
commit | 6fd3cb9d03b1418aaf550e4069f18e0dca8c7054 (patch) | |
tree | bd35ec613b65934c6deebf8199f966b2c748ba47 /libdbusmenu-glib/menuitem.c | |
parent | 218b2b32a73881b198f09f74725d395d2d27acdc (diff) | |
download | libdbusmenu-6fd3cb9d03b1418aaf550e4069f18e0dca8c7054.tar.gz libdbusmenu-6fd3cb9d03b1418aaf550e4069f18e0dca8c7054.tar.bz2 libdbusmenu-6fd3cb9d03b1418aaf550e4069f18e0dca8c7054.zip |
Fix LP: #723873 - when a menuitems property is restored to a default value, the new
state is not updated correctly on the listening client. Make dbusmenu_menuitem_property_remove call
dbusmenu_menuitem_property_set_variant with a NULL value rather than manipulating the properties
directly. When removing a property that has a default value now, it will signal PROPERTY_CHANGED
with the default value, which means that changing a property from non-default to default over the
wire (which really just deletes the property) now works correctly. This is also now more aligned with
how dbusmenu_menuitem_property_get* works, which will return the default value for a property
after removing the property from the menuitem
Diffstat (limited to 'libdbusmenu-glib/menuitem.c')
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 34147a3..61e59c3 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1150,9 +1150,9 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); GVariant * default_value = NULL; - if (value != NULL) { - const gchar * type = menuitem_get_type(mi); + const gchar * type = menuitem_get_type(mi); + if (value != NULL) { /* Check the expected type to see if we want to have a warning */ GVariantType * default_type = dbusmenu_defaults_default_get_type(priv->defaults, type, property); if (default_type != NULL) { @@ -1163,22 +1163,23 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro g_warning("Setting menuitem property '%s' with value of type '%s' when expecting '%s'", property, g_variant_get_type_string(value), g_variant_type_peek_string(default_type)); } } + } - /* Check the defaults database to see if we have a default - for this property. */ - default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); - if (default_value != NULL) { - /* Now see if we're setting this to the same value as the - default. If we are then we just want to swallow this variant - and make the function behave like we're clearing it. */ - if (g_variant_equal(default_value, value)) { - g_variant_ref_sink(value); - g_variant_unref(value); - value = NULL; - } + /* Check the defaults database to see if we have a default + for this property. */ + default_value = dbusmenu_defaults_default_get(priv->defaults, type, property); + if (default_value != NULL && value != NULL) { + /* Now see if we're setting this to the same value as the + default. If we are then we just want to swallow this variant + and make the function behave like we're clearing it. */ + if (g_variant_equal(default_value, value)) { + g_variant_ref_sink(value); + g_variant_unref(value); + value = NULL; } } + gboolean replaced = FALSE; gpointer currentval = g_hash_table_lookup(priv->properties, property); @@ -1371,9 +1372,7 @@ dbusmenu_menuitem_property_remove (DbusmenuMenuitem * mi, const gchar * property g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); g_return_if_fail(property != NULL); - DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - - g_hash_table_remove(priv->properties, property); + dbusmenu_menuitem_property_set_variant(mi, property, NULL); return; } |