when a pipe menu is killed, kill all its submenus as well
This commit is contained in:
parent
32b381fbca
commit
3d1e2ab1b4
2 changed files with 17 additions and 0 deletions
|
@ -18,6 +18,7 @@ typedef struct _ObMenuParseState ObMenuParseState;
|
||||||
struct _ObMenuParseState
|
struct _ObMenuParseState
|
||||||
{
|
{
|
||||||
GSList *menus;
|
GSList *menus;
|
||||||
|
ObMenu *pipe_creator;
|
||||||
};
|
};
|
||||||
|
|
||||||
static GHashTable *menu_hash = NULL;
|
static GHashTable *menu_hash = NULL;
|
||||||
|
@ -78,6 +79,7 @@ void menu_startup(gboolean reconfig)
|
||||||
menu_parse_inst = parse_startup();
|
menu_parse_inst = parse_startup();
|
||||||
|
|
||||||
menu_parse_state.menus = NULL;
|
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, "menu", parse_menu, &menu_parse_state);
|
||||||
parse_register(menu_parse_inst, "item", parse_menu_item,
|
parse_register(menu_parse_inst, "item", parse_menu_item,
|
||||||
&menu_parse_state);
|
&menu_parse_state);
|
||||||
|
@ -117,6 +119,12 @@ void menu_shutdown(gboolean reconfig)
|
||||||
menu_hash = NULL;
|
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)
|
void menu_pipe_execute(ObMenu *self)
|
||||||
{
|
{
|
||||||
xmlDocPtr doc;
|
xmlDocPtr doc;
|
||||||
|
@ -137,14 +145,19 @@ void menu_pipe_execute(ObMenu *self)
|
||||||
if (parse_load_mem(output, strlen(output),
|
if (parse_load_mem(output, strlen(output),
|
||||||
"openbox_pipe_menu", &doc, &node))
|
"openbox_pipe_menu", &doc, &node))
|
||||||
{
|
{
|
||||||
|
g_hash_table_foreach_remove(menu_hash, menu_pipe_submenu, self);
|
||||||
menu_clear_entries(self);
|
menu_clear_entries(self);
|
||||||
|
|
||||||
|
menu_parse_state.pipe_creator = self;
|
||||||
menu_parse_state.menus = g_slist_prepend(NULL, self);
|
menu_parse_state.menus = g_slist_prepend(NULL, self);
|
||||||
parse_tree(menu_parse_inst, doc, node->xmlChildrenNode);
|
parse_tree(menu_parse_inst, doc, node->xmlChildrenNode);
|
||||||
menu_parse_state.menus = g_slist_remove(menu_parse_state.menus, self);
|
menu_parse_state.menus = g_slist_remove(menu_parse_state.menus, self);
|
||||||
|
menu_parse_state.pipe_creator = NULL;
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
|
||||||
g_assert(menu_parse_state.menus == NULL);
|
g_assert(menu_parse_state.menus == NULL);
|
||||||
|
} else {
|
||||||
|
g_warning("Invalid output from pipe-menu: %s", self->execute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,6 +217,7 @@ static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
|
||||||
goto parse_menu_fail;
|
goto parse_menu_fail;
|
||||||
|
|
||||||
if ((menu = menu_new(name, title, NULL))) {
|
if ((menu = menu_new(name, title, NULL))) {
|
||||||
|
menu->pipe_creator = state->pipe_creator;
|
||||||
if (parse_attr_string("execute", node, &script)) {
|
if (parse_attr_string("execute", node, &script)) {
|
||||||
menu->execute = ob_expand_tilde(script);
|
menu->execute = ob_expand_tilde(script);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -42,6 +42,9 @@ struct _ObMenu
|
||||||
ObMenuUpdateFunc update_func;
|
ObMenuUpdateFunc update_func;
|
||||||
ObMenuExecuteFunc execute_func;
|
ObMenuExecuteFunc execute_func;
|
||||||
ObMenuDestroyFunc destroy_func;
|
ObMenuDestroyFunc destroy_func;
|
||||||
|
|
||||||
|
/* Pipe-menu parent, we get destroyed when it is destroyed */
|
||||||
|
ObMenu *pipe_creator;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
Loading…
Reference in a new issue