X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fmenu.c;h=cd4b5cb168fe2e2d79563b5adb1ac2f7efcf1aef;hb=b317f0140398308fce5fbd262ad99a290b54a449;hp=74a743eed4bc4dbe0cb8e0ce17a81bf211ee04ac;hpb=78282959f970d28131e6aa8d66adce359aa145dc;p=chaz%2Fopenbox diff --git a/openbox/menu.c b/openbox/menu.c index 74a743ee..cd4b5cb1 100644 --- a/openbox/menu.c +++ b/openbox/menu.c @@ -39,20 +39,27 @@ static gboolean menu_open(gchar *file, xmlDocPtr *doc, xmlNodePtr *node) gboolean loaded = TRUE; gchar *p; - p = g_build_filename(g_get_home_dir(), ".openbox", file, NULL); - if (!parse_load(p, "openbox_menu", doc, node)) { - g_free(p); - p = g_build_filename(RCDIR, file, NULL); + if (file[0] == '/') { + if (!parse_load(file, "openbox_menu", doc, node)) { + g_warning("Failed to load menu from '%s'", file); + loaded = FALSE; + } + } else { + p = g_build_filename(g_get_home_dir(), ".openbox", file, NULL); if (!parse_load(p, "openbox_menu", doc, node)) { g_free(p); - p = g_strdup(file); + p = g_build_filename(RCDIR, file, NULL); if (!parse_load(p, "openbox_menu", doc, node)) { - g_warning("Failed to load menu from '%s'", file); - loaded = FALSE; + g_free(p); + p = g_strdup(file); + if (!parse_load(p, "openbox_menu", doc, node)) { + g_warning("Failed to load menu from '%s'", file); + loaded = FALSE; + } } } + g_free(p); } - g_free(p); return loaded; } @@ -89,13 +96,13 @@ void menu_startup(gboolean reconfig) for (it = config_menu_files; it; it = g_slist_next(it)) { if (menu_open(it->data, &doc, &node)) { loaded = TRUE; - parse_tree(menu_parse_inst, doc, node->xmlChildrenNode); + parse_tree(menu_parse_inst, doc, node->children); xmlFreeDoc(doc); } } if (!loaded) { if (menu_open("menu.xml", &doc, &node)) { - parse_tree(menu_parse_inst, doc, node->xmlChildrenNode); + parse_tree(menu_parse_inst, doc, node->children); xmlFreeDoc(doc); } } @@ -149,7 +156,7 @@ void menu_pipe_execute(ObMenu *self) menu_parse_state.pipe_creator = self; menu_parse_state.parent = self; - parse_tree(menu_parse_inst, doc, node->xmlChildrenNode); + parse_tree(menu_parse_inst, doc, node->children); xmlFreeDoc(doc); } else { g_warning("Invalid output from pipe-menu: %s", self->execute); @@ -178,7 +185,7 @@ static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, if (parse_attr_string("label", node, &label)) { GSList *acts = NULL; - for (node = node->xmlChildrenNode; node; node = node->next) + for (node = node->children; node; node = node->next) if (!xmlStrcasecmp(node->name, (const xmlChar*) "action")) acts = g_slist_append(acts, action_parse (i, doc, node, @@ -222,7 +229,7 @@ static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, old = state->parent; state->parent = menu; - parse_tree(i, doc, node->xmlChildrenNode); + parse_tree(i, doc, node->children); state->parent = old; } } @@ -276,6 +283,8 @@ void menu_show(gchar *name, gint x, gint y, ObClient *client) if (!(self = menu_from_name(name))) return; + menu_frame_hide_all(); + frame = menu_frame_new(self, client); menu_frame_move(frame, x, y); menu_frame_show(frame, NULL);