X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenu.c;h=d00ef05e0c40b17b520caa678f54f9be9a83fb4d;hb=88f83fc927638aef2ca0e174ba12db822df9b7ef;hp=8cc1c872f2c642fb36704fceff3ccde993406922;hpb=b543af60b3b625f978bec0eacc7da31cd9d347f6;p=chaz%2Fopenbox diff --git a/openbox/menu.c b/openbox/menu.c index 8cc1c872..d00ef05e 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -18,6 +18,7 @@ typedef struct _ObMenuParseState ObMenuParseState; struct _ObMenuParseState { GSList *menus; + ObMenu *pipe_creator; }; static GHashTable *menu_hash = NULL; @@ -55,14 +56,14 @@ static gboolean menu_open(gchar *file, xmlDocPtr *doc, xmlNodePtr *node) return loaded; } -static void client_dest(ObClient *c) +static void client_dest(gpointer client) { /* menus can be associated with a client, so close any that are since we are disappearing now */ - menu_frame_hide_all_client(c); + menu_frame_hide_all_client(client); } -void menu_startup() +void menu_startup(gboolean reconfig) { xmlDocPtr doc; xmlNodePtr node; @@ -78,6 +79,7 @@ void menu_startup() menu_parse_inst = parse_startup(); menu_parse_state.menus = NULL; + menu_parse_state.pipe_creator = NULL; parse_register(menu_parse_inst, "menu", parse_menu, &menu_parse_state); parse_register(menu_parse_inst, "item", parse_menu_item, &menu_parse_state); @@ -92,7 +94,7 @@ void menu_startup() } } if (!loaded) { - if (menu_open("menu", &doc, &node)) { + if (menu_open("menu.xml", &doc, &node)) { parse_tree(menu_parse_inst, doc, node->xmlChildrenNode); xmlFreeDoc(doc); } @@ -100,12 +102,14 @@ void menu_startup() g_assert(menu_parse_state.menus == NULL); - client_add_destructor(client_dest); + if (!reconfig) + client_add_destructor(client_dest); } -void menu_shutdown() +void menu_shutdown(gboolean reconfig) { - client_remove_destructor(client_dest); + if (!reconfig) + client_remove_destructor(client_dest); parse_shutdown(menu_parse_inst); menu_parse_inst = NULL; @@ -115,6 +119,12 @@ void menu_shutdown() menu_hash = NULL; } +static gboolean menu_pipe_submenu(gpointer key, gpointer val, gpointer data) +{ + ObMenu *menu = val; + return menu->pipe_creator == data; +} + void menu_pipe_execute(ObMenu *self) { xmlDocPtr doc; @@ -135,14 +145,19 @@ void menu_pipe_execute(ObMenu *self) if (parse_load_mem(output, strlen(output), "openbox_pipe_menu", &doc, &node)) { + g_hash_table_foreach_remove(menu_hash, menu_pipe_submenu, self); menu_clear_entries(self); + menu_parse_state.pipe_creator = self; menu_parse_state.menus = g_slist_prepend(NULL, self); parse_tree(menu_parse_inst, doc, node->xmlChildrenNode); menu_parse_state.menus = g_slist_remove(menu_parse_state.menus, self); + menu_parse_state.pipe_creator = NULL; xmlFreeDoc(doc); g_assert(menu_parse_state.menus == NULL); + } else { + g_warning("Invalid output from pipe-menu: %s", self->execute); } } @@ -202,6 +217,7 @@ static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, goto parse_menu_fail; if ((menu = menu_new(name, title, NULL))) { + menu->pipe_creator = state->pipe_creator; if (parse_attr_string("execute", node, &script)) { menu->execute = ob_expand_tilde(script); } else {