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;
}
} else {
g_warning("Invalid output from pipe-menu: %s", self->execute);
}
+
+ g_free(output);
}
static ObMenu* menu_from_name(gchar *name)
static void menu_destroy_hash_value(ObMenu *self)
{
- /* XXX make sure its not visible */
+ /* make sure its not visible */
+ {
+ GList *it;
+ ObMenuFrame *f;
+
+ for (it = menu_frame_visible; it; it = g_list_next(it)) {
+ f = it->data;
+ if (f->menu == self)
+ menu_frame_hide_all();
+ }
+ }
if (self->destroy_func)
self->destroy_func(self, self->data);
g_free(self->name);
g_free(self->title);
g_free(self->execute);
+
+ g_free(self);
}
void menu_free(ObMenu *menu)
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);
void menu_clear_entries(ObMenu *self)
{
- /* XXX assert that the menu isn't visible */
+#ifdef DEBUG
+ /* assert that the menu isn't visible */
+ {
+ GList *it;
+ ObMenuFrame *f;
+
+ for (it = menu_frame_visible; it; it = g_list_next(it)) {
+ f = it->data;
+ g_assert(f->menu != self);
+ }
+ }
+#endif
while (self->entries) {
menu_entry_free(self->entries->data);