]> Dogcows Code - chaz/openbox/blobdiff - openbox/menu.c
Menu parsing updates for plugins.
[chaz/openbox] / openbox / menu.c
index a8a51117f92dea3a68b9a67f984f26eff161f4ce..e2c55c6de15d05cfb0e5bb9c220d93c410deb841 100644 (file)
@@ -17,29 +17,52 @@ GSList *menu_visible = NULL;
                          ButtonPressMask | ButtonReleaseMask)
 
 static void parse_menu(xmlDocPtr doc, xmlNodePtr node, void *data)
+{
+    parse_menu_full(doc, node, data, TRUE);
+}
+
+
+void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data,
+                       gboolean newmenu)
 {
     Action *act;
     xmlNodePtr nact;
-    gchar *id = NULL, *title = NULL, *label = NULL;
-    ObMenu *menu, *parent;
 
-    if (!parse_attr_string("id", node->parent, &id))
-        goto parse_menu_fail;
-    if (!parse_attr_string("label", node->parent, &title))
-        goto parse_menu_fail;
+    gchar *id = NULL, *title = NULL, *label = NULL, *plugin;
+    ObMenu *menu = NULL, *parent;
+
+    if (newmenu == TRUE) {
+        if (!parse_attr_string("id", node->parent, &id))
+            goto parse_menu_fail;
+        if (!parse_attr_string("label", node->parent, &title))
+            goto parse_menu_fail;
 
-    g_message("menu label %s", title);
+        g_message("menu label %s", title);
 
-    menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL);
-    if (data)
-        *((ObMenu**)data) = menu;
+        menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL);
 
+        if (data)
+            *((ObMenu**)data) = menu;
+    } else {
+        menu = (ObMenu *)data;
+    }
+    
     while (node) {
         if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {
-            parent = menu;
-            parse_menu(doc, node->xmlChildrenNode, &parent);
-            menu_add_entry(menu, menu_entry_new_submenu(parent->label,
-                                                        parent));
+            if (parse_attr_string("plugin", node, &plugin)) {
+                PluginMenuCreateData data = {
+                    .doc = doc,
+                    .node = node,
+                    .parent = menu
+                };
+                parent = plugin_create(plugin, &data);
+            } else {
+                parent = menu;
+                parse_menu(doc, node->xmlChildrenNode, &parent);
+                menu_add_entry(menu, menu_entry_new_submenu(parent->label,
+                                                            parent));
+            }
+
         }
         else if (!xmlStrcasecmp(node->name, (const xmlChar*) "item")) {
             if (parse_attr_string("label", node, &label)) {
This page took 0.023071 seconds and 4 git commands to generate.