aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r--libdbusmenu-glib/client.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index b6e7204..4bb3217 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 == NULL && new_type == NULL) || (old_type != NULL && new_type != NULL && g_variant_compare(old_type, new_type) == 0)) {
+ // Only recycle the menu item if it's of the same type
+ oldchildren = g_list_remove(oldchildren, cs_mi);
+ childmi = cs_mi;
+ }
break;
}
}
@@ -2511,7 +2532,7 @@ type_handler_destroy (gpointer user_data)
* items when they come in.
*
* This function connects into the type handling of the #DbusmenuClient.
- * Every new menuitem that comes in immediately gets asked for it's
+ * Every new menuitem that comes in immediately gets asked for its
* properties. When we get those properties we check the 'type'
* property and look to see if it matches a handler that is known
* by the client. If so, the @newfunc function is executed on that
@@ -2542,7 +2563,7 @@ dbusmenu_client_add_type_handler (DbusmenuClient * client, const gchar * type, D
* the resources in @user_data.
*
* This function connects into the type handling of the #DbusmenuClient.
- * Every new menuitem that comes in immediately gets asked for it's
+ * Every new menuitem that comes in immediately gets asked for its
* properties. When we get those properties we check the 'type'
* property and look to see if it matches a handler that is known
* by the client. If so, the @newfunc function is executed on that