diff options
author | Ted Gould <ted@gould.cx> | 2010-03-31 17:13:25 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-03-31 17:13:25 -0500 |
commit | cbcbaf8ee1fa6fd498f691acbd39032994ed113d (patch) | |
tree | be87ef480271ebbeb87e6074170f5756263579a8 | |
parent | 1f308a47c578baec7ba7bfebb880e0ecf0a17688 (diff) | |
parent | e5c8d4376b81df6c5c9d96e8bb0ba8650f047859 (diff) | |
download | libdbusmenu-cbcbaf8ee1fa6fd498f691acbd39032994ed113d.tar.gz libdbusmenu-cbcbaf8ee1fa6fd498f691acbd39032994ed113d.tar.bz2 libdbusmenu-cbcbaf8ee1fa6fd498f691acbd39032994ed113d.zip |
Switching menu updating to be friendlier
-rw-r--r-- | libdbusmenu-glib/client.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 09a663a..f5546a2 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -779,7 +779,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it xmlNodePtr children; guint position; - GList * oldchildren = dbusmenu_menuitem_take_children(item); + GList * oldchildren = g_list_copy(dbusmenu_menuitem_get_children(item)); /* g_debug("Starting old children: %d", g_list_length(oldchildren)); */ for (children = node->children, position = 0; children != NULL; children = children->next, position++) { @@ -800,8 +800,16 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it } } - childmi = parse_layout_xml(client, children, childmi, item, proxy); - dbusmenu_menuitem_child_add_position(item, childmi, position); + DbusmenuMenuitem * newchildmi = parse_layout_xml(client, children, childmi, item, proxy); + + if (newchildmi != childmi) { + if (childmi != NULL) { + dbusmenu_menuitem_child_delete(item, childmi); + } + dbusmenu_menuitem_child_add_position(item, newchildmi, position); + } else { + dbusmenu_menuitem_child_reorder(item, childmi, position); + } } /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ @@ -811,7 +819,7 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it #ifdef MASSIVEDEBUGGING g_debug("Unref'ing menu item with layout update. ID: %d", dbusmenu_menuitem_get_id(oldmi)); #endif - g_object_unref(G_OBJECT(oldmi)); + dbusmenu_menuitem_child_delete(item, oldmi); } g_list_free(oldchildren); |