aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Astals <albert.astals@canonical.com>2012-10-25 15:23:22 +0200
committerAlbert Astals <albert.astals@canonical.com>2012-10-25 15:23:22 +0200
commit64ed9ef0bf0799ea025f60c3ef1f0a9c2350cdbd (patch)
tree533aab8797d113b62f57ed4174807f6b978f1201
parentb914be2afa8fa8d12a83841991701298c558f142 (diff)
downloadlibdbusmenu-64ed9ef0bf0799ea025f60c3ef1f0a9c2350cdbd.tar.gz
libdbusmenu-64ed9ef0bf0799ea025f60c3ef1f0a9c2350cdbd.tar.bz2
libdbusmenu-64ed9ef0bf0799ea025f60c3ef1f0a9c2350cdbd.zip
Do not reuse menu items if their type is different
The gtk side does not know how to convert from a separator to a standard item, and even if it'd knew it does not make much sense to reuse them since if the types are different you can expect there's little to reuse
-rw-r--r--libdbusmenu-glib/client.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 237697c..4ec9d3b 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -2160,8 +2160,29 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem *
for (childsearch = oldchildren; childsearch != NULL; childsearch = g_list_next(childsearch)) {
DbusmenuMenuitem * cs_mi = DBUSMENU_MENUITEM(childsearch->data);
if (childid == dbusmenu_menuitem_get_id(cs_mi)) {
- oldchildren = g_list_remove(oldchildren, cs_mi);
- childmi = cs_mi;
+ GVariantIter iter;
+ gchar * prop;
+ GVariant * value;
+ GVariant * child_props;
+ GVariant * new_type = NULL;
+ GVariant * old_type = NULL;
+
+ child_props = g_variant_get_child_value(child, 1);
+ g_variant_iter_init(&iter, child_props);
+ while (g_variant_iter_loop(&iter, "{sv}", &prop, &value)) {
+ if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) {
+ new_type = value;
+ break;
+ }
+ }
+ g_variant_unref(child_props);
+
+ old_type = dbusmenu_menuitem_property_get_variant(cs_mi, DBUSMENU_MENUITEM_PROP_TYPE);
+ if ((old_type == new_type) || (old_type != NULL && new_type != NULL && g_strcmp0(g_variant_get_string (old_type, NULL), g_variant_get_string (new_type, NULL)) == 0)) {
+ // Only recycle the menu item if it's of the same type
+ oldchildren = g_list_remove(oldchildren, cs_mi);
+ childmi = cs_mi;
+ }
break;
}
}