+static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+ gpointer data)
+{
+ g_message("%s", __FUNCTION__);
+ parse_menu_full(i, doc, node, data, TRUE);
+}
+
+
+void parse_menu_full(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+ gpointer data, gboolean newmenu)
+{
+ ObAction *act;
+ xmlNodePtr nact;
+
+ gchar *id = NULL, *title = NULL, *label = NULL, *plugin;
+ ObMenu *menu = NULL, *parent;
+
+ if (newmenu == TRUE) {
+ if (!parse_attr_string("id", node, &id))
+ goto parse_menu_fail;
+ if (!parse_attr_string("label", node, &title))
+ goto parse_menu_fail;
+ ob_debug("menu label %s\n", title);
+
+ if (parse_attr_string("plugin", node, &plugin)) {
+ PluginMenuCreateData data;
+ data.parse_inst = i;
+ data.doc = doc;
+ data.node = node;
+ data.parent = menu;
+
+ if (plugin_open_reopen(plugin, i))
+ parent = plugin_create(plugin, &data);
+ g_free(plugin);
+ } else
+ menu = menu_new(title, id, data ? *((ObMenu**)data) : NULL);
+
+ if (data)
+ *((ObMenu**)data) = menu;
+ } else {
+ menu = (ObMenu *)data;
+ }
+
+ node = node->xmlChildrenNode;
+
+ while (node) {
+ if (!xmlStrcasecmp(node->name, (const xmlChar*) "menu")) {
+ if (parse_attr_string("plugin", node, &plugin)) {
+ PluginMenuCreateData data;
+ data.doc = doc;
+ data.node = node;
+ data.parent = menu;
+ if (plugin_open_reopen(plugin, i))
+ parent = plugin_create(plugin, &data);
+ g_free(plugin);
+ } else {
+ parent = menu;
+ parse_menu(i, doc, node, &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)) {
+ if ((nact = parse_find_node("action", node->xmlChildrenNode)))
+ act = action_parse(doc, nact);
+ else
+ act = NULL;
+ if (act)
+ menu_add_entry(menu, menu_entry_new(label, act));
+ else
+ menu_add_entry(menu, menu_entry_new_separator(label));
+ g_free(label);
+ }
+ }
+ node = node->next;
+ }