+/*
+ * $Header$
+ *
+ * FFIO menu plugin
+ * Provides a menu from a FIFO located in ~/.openbox/fifo_menu/id
+ * Example:
+ * rc3:
+ * <menu id="fonk" label="fonk" plugin="fifo_menu"></menu>
+ * Menu format
+ * <fifo_menu>
+ * <item label="GLOVE.png">
+ * <action name="execute">
+ * <execute>
+ * bsetbg "/home/woodblock/.openbox/backgrounds/GLOVE.png"
+ * </execute>
+ * </action>
+ * </item>
+ * </fifo_menu>
+ *
+ * If the attribute pid="true" is in the <menu>
+ */
+
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
num_realloc);
if (num_read == 0) { /* eof */
+ ObParseInst *i;
+ xmlDocPtr doc;
+ xmlNodePtr node;
+
menu->invalid = TRUE;
menu_clear(menu);
FIFO_MENU_DATA(menu)->buf[FIFO_MENU_DATA(menu)->buflen] = '\0';
- xmlDocPtr doc = xmlParseMemory(FIFO_MENU_DATA(menu)->buf,
- FIFO_MENU_DATA(menu)->buflen);
+ i = parse_startup();
+
+ if (parse_load_mem(FIFO_MENU_DATA(menu)->buf,
+ FIFO_MENU_DATA(menu)->buflen,
+ "fifo_menu", &doc, &node))
+ parse_menu_full(i, doc, node, menu, FALSE);
+
+ parse_shutdown(i);
- xmlNodePtr node = xmlDocGetRootElement(doc);
-
- if (node &&
- !xmlStrcasecmp(node->name, (const xmlChar*) "fifo_menu")) {
- if ((node = parse_find_node("item", node->xmlChildrenNode)))
- parse_menu_full(doc, node, menu, FALSE);
- }
-
fifo_menu_clean_up(menu);
event_remove_fd(FIFO_MENU_DATA(menu)->handler->fd);
FIFO_MENU_DATA(m)->fifo = NULL;
}
+ if (FIFO_MENU_DATA(m)->buf != NULL) {
+ g_free(FIFO_MENU_DATA(m)->buf);
+ FIFO_MENU_DATA(m)->buf = NULL;
+ }
+
g_free(m->plugin_data);
menu_free(m->name);
m = menu_new( (label != NULL ? label : ""),
(id != NULL ? id : PLUGIN_NAME),
data->parent);
- menu_add_entry(data->parent, menu_entry_new_submenu(
- (label != NULL ? label : ""),
- m));
+
+ if (data->parent)
+ menu_add_entry(data->parent, menu_entry_new_submenu(
+ (label != NULL ? label : ""),
+ m));
g_free(label);
g_free(id);