aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-08-17 11:02:45 -0500
committerTed Gould <ted@gould.cx>2010-08-17 11:02:45 -0500
commit40409bc0979f50e39187b06c8a16e79a7f5dcb2d (patch)
tree65a40add35b0c55aeba24e3e88518f397235c97f
parent466fa0fc57ab1bec842a158f549387e141464221 (diff)
parentd2bd004b2cbb7a383d1b75200fe857091f6fe89c (diff)
downloadlibdbusmenu-40409bc0979f50e39187b06c8a16e79a7f5dcb2d.tar.gz
libdbusmenu-40409bc0979f50e39187b06c8a16e79a7f5dcb2d.tar.bz2
libdbusmenu-40409bc0979f50e39187b06c8a16e79a7f5dcb2d.zip
Makes the layout handle commend nodes better (and thus the KDE layouts).
-rw-r--r--libdbusmenu-glib/client.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index 7c73b7b..73a7aac 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -1126,6 +1126,9 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it
/* g_debug("Looking at child: %d", position); */
gint childid = parse_node_get_id(children);
if (childid < 0) {
+ /* Don't increment the position when there isn't a valid
+ node in the XML tree. It's probably a comment. */
+ position--;
continue;
}
DbusmenuMenuitem * childmi = NULL;
@@ -1143,11 +1146,17 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it
}
if (childmi == NULL) {
+ #ifdef MASSIVEDEBUGGING
+ g_debug("Building new menu item %d at position %d", childid, position);
+ #endif
/* If we can't recycle, then we build a new one */
childmi = parse_layout_new_child(childid, client, item);
dbusmenu_menuitem_child_add_position(item, childmi, position);
g_object_unref(childmi);
} else {
+ #ifdef MASSIVEDEBUGGING
+ g_debug("Recycling menu item %d at position %d", childid, position);
+ #endif
/* If we can recycle, make sure it's in the right place */
dbusmenu_menuitem_child_reorder(item, childmi, position);
parse_layout_update(childmi, client);
@@ -1175,6 +1184,19 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it
children = node->children;
GList * childmis = dbusmenu_menuitem_get_children(item);
while (children != NULL && childmis != NULL) {
+ gint xmlid = parse_node_get_id(children);
+ /* If this isn't a valid menu item we need to move on
+ until we have one. This avoids things like comments. */
+ if (xmlid < 0) {
+ children = children->next;
+ continue;
+ }
+
+ #ifdef MASSIVEDEBUGGING
+ gint miid = dbusmenu_menuitem_get_id(DBUSMENU_MENUITEM(childmis->data));
+ g_debug("Recursing parse_layout_xml. XML ID: %d MI ID: %d", xmlid, miid);
+ #endif
+
parse_layout_xml(client, children, DBUSMENU_MENUITEM(childmis->data), item, proxy);
children = children->next;