diff options
| author | Scott Moynes <smoynes@nexus.carleton.ca> | 2003-07-17 01:40:27 +0000 |
|---|---|---|
| committer | Scott Moynes <smoynes@nexus.carleton.ca> | 2003-07-17 01:40:27 +0000 |
| commit | 22ff8c587d815c021cad13f46094a31cc79243cf (patch) | |
| tree | 619056a5881cd5836ca0c47ae673fced623c5745 /openbox/menu.c | |
| parent | 5fce782499aa821c3a25bfdbf475066c2c21a7ed (diff) | |
Menu parsing updates for plugins.
FIFO menus are the only plugin that takes advantage of this.
Example:
<menu id="root" label="Openbox 3">
<menu id="fonk" label="fonk" plugin="fifo_menu">
</menu>
</menu>
This creates a FIFO ~/.openbox/fifo_menu/fonk to which you can send
menus to. The menus sent to it must be like
<fifo>
<item>
etc...
</fifo>
I think. If my memory serves me right.
It is all hideous, but I just wanted to experiment and see if it was
possible.
Diffstat (limited to 'openbox/menu.c')
| -rw-r--r-- | openbox/menu.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/openbox/menu.c b/openbox/menu.c index a8a51117..e2c55c6d 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -18,28 +18,51 @@ GSList *menu_visible = NULL; 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)) { |
