diff options
author | Ted Gould <ted@gould.cx> | 2010-01-22 14:53:39 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-01-22 14:53:39 -0600 |
commit | d82766dc0f4e240c92809b39dcea6967628071d7 (patch) | |
tree | ee90487f68dfbae75bea6eb2fca1968f863d386e | |
parent | 4ca2136146ef6276e2be11bb3014786131645a54 (diff) | |
parent | 921eaf7f51026b56b0a504c91214d40d07ce6040 (diff) | |
download | libdbusmenu-d82766dc0f4e240c92809b39dcea6967628071d7.tar.gz libdbusmenu-d82766dc0f4e240c92809b39dcea6967628071d7.tar.bz2 libdbusmenu-d82766dc0f4e240c92809b39dcea6967628071d7.zip |
Sync to trunk
-rw-r--r-- | libdbusmenu-glib/client.c | 31 | ||||
-rw-r--r-- | libdbusmenu-glib/dbus-menu.xml | 10 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem-private.h | 2 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 15 | ||||
-rw-r--r-- | libdbusmenu-glib/server.c | 6 |
5 files changed, 19 insertions, 45 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8b8d6e6..e9d57b4 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -514,34 +514,6 @@ build_proxies (DbusmenuClient * client) return; } -/* Get the "revision" attribute of the node, parse it and - return it. Also we're checking to ensure the node - is a 'menu' here. */ -static gint -parse_node_get_revision (xmlNodePtr node) -{ - if (g_strcmp0((gchar *)node->name, "menu") != 0) { - /* This kills some nodes early */ - g_warning("XML Node is not 'menu' it is '%s'", node->name); - return 0; - } - - xmlAttrPtr attrib; - for (attrib = node->properties; attrib != NULL; attrib = attrib->next) { - if (g_strcmp0((gchar *)attrib->name, "revision") == 0) { - if (attrib->children != NULL) { - guint revision = (guint)g_ascii_strtoull((gchar *)attrib->children->content, NULL, 10); - /* g_debug ("Found ID: %d", id); */ - return revision; - } - break; - } - } - - g_warning("Unable to find a revision on the node"); - return 0; -} - /* Get the ID attribute of the node, parse it and return it. Also we're checking to ensure the node is a 'menu' here. */ @@ -764,7 +736,6 @@ parse_layout (DbusmenuClient * client, const gchar * layout) xmldoc = xmlReadMemory(layout, g_utf8_strlen(layout, 16*1024), "dbusmenu.xml", NULL, 0); xmlNodePtr root = xmlDocGetRootElement(xmldoc); - gint revision = parse_node_get_revision(root); DbusmenuMenuitem * oldroot = priv->root; priv->root = parse_layout_xml(client, root, priv->root, NULL, priv->menuproxy); @@ -781,7 +752,7 @@ parse_layout (DbusmenuClient * client, const gchar * layout) g_signal_emit(G_OBJECT(client), signals[ROOT_CHANGED], 0, priv->root, TRUE); } - return revision; + return 1; } /* When the layout property returns, here's where we take care of that. */ diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 4ec03ef..06d9f35 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -50,13 +50,13 @@ Provides an XML representation of the menu hierarchy XML syntax: -<menu id="1" revision="2"> # Root container - <menu id="2" revision="2"> # First level menu, for example "File" - <menu id="3" revision="2"/> ~ Second level menu, for example "Open" - <menu id="4" revision="3"/> +<menu id="1"> # Root container + <menu id="2"> # First level menu, for example "File" + <menu id="3"/> ~ Second level menu, for example "Open" + <menu id="4"/> ... </menu> - <menu id="5" revision="2"> # Another first level menu, say "Edit" + <menu id="5"> # Another first level menu, say "Edit" ... </menu> ... diff --git a/libdbusmenu-glib/menuitem-private.h b/libdbusmenu-glib/menuitem-private.h index 0120435..1c7c16a 100644 --- a/libdbusmenu-glib/menuitem-private.h +++ b/libdbusmenu-glib/menuitem-private.h @@ -33,7 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS -void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array, gint revision); +void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array); G_END_DECLS diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index e50b2d8..06d6200 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -1048,7 +1048,6 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) dbusmenu_menuitem_buildxml: @mi: #DbusmenuMenuitem to represent in XML @array: A list of string that will be turned into an XML file - @revision: The revision of the layout to embed in the XML This function will add strings to the array @array. It will put at least one entry if this menu item has no children. If it has @@ -1057,18 +1056,22 @@ dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) children to place their own tags in the array in between those two. */ void -dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array, gint revision) +dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array) { g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + guint id = 0; + if (!dbusmenu_menuitem_get_root(mi)) { + id = dbusmenu_menuitem_get_id(mi); + } + GList * children = dbusmenu_menuitem_get_children(mi); - /* TODO: Only put revision info in the root node. Save some bandwidth. */ if (children == NULL) { - g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\" revision=\"%d\" />", dbusmenu_menuitem_get_id(mi), revision)); + g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\"/>", id)); } else { - g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\" revision=\"%d\">", dbusmenu_menuitem_get_id(mi), revision)); + g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\">", id)); for ( ; children != NULL; children = children->next) { - dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array, revision); + dbusmenu_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array); } g_ptr_array_add(array, g_strdup("</menu>")); } diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 44bbe1b..8bbd758 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -376,13 +376,13 @@ _dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revi if (parent == 0) { if (priv->root == NULL) { /* g_debug("Getting layout without root node!"); */ - g_ptr_array_add(xmlarray, g_strdup_printf("<menu revision=\"%d\" />", priv->layout_revision)); + g_ptr_array_add(xmlarray, g_strdup("<menu/>")); } else { - dbusmenu_menuitem_buildxml(priv->root, xmlarray, priv->layout_revision); + dbusmenu_menuitem_buildxml(priv->root, xmlarray); } } else { DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent); - dbusmenu_menuitem_buildxml(item, xmlarray, priv->layout_revision); + dbusmenu_menuitem_buildxml(item, xmlarray); } g_ptr_array_add(xmlarray, NULL); |