summaryrefslogtreecommitdiff
path: root/openbox/menu.c
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2003-08-28 07:49:57 +0000
committerDana Jansens <danakj@orodu.net>2003-08-28 07:49:57 +0000
commitc34915ae8d49f61426912ef332e8097be516bdd3 (patch)
tree83f0a5eb4334f67c2830dd2ade09b125ac485f73 /openbox/menu.c
parentf7eb47dba4b091b67a28404ce461b15dffcb4298 (diff)
make submenus not require the menu to exist when they are created, not until they are shown.
crash fix in client_menu
Diffstat (limited to 'openbox/menu.c')
-rw-r--r--openbox/menu.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/openbox/menu.c b/openbox/menu.c
index 324b3629..d742b972 100644
--- a/openbox/menu.c
+++ b/openbox/menu.c
@@ -253,6 +253,8 @@ static void menu_entry_free(ObMenuEntry *self)
}
break;
case OB_MENU_ENTRY_TYPE_SUBMENU:
+ g_free(self->data.submenu.name);
+ break;
case OB_MENU_ENTRY_TYPE_SEPARATOR:
break;
}
@@ -296,14 +298,13 @@ void menu_add_normal(gchar *name, gint id, gchar *label, GSList *actions)
void menu_add_submenu(gchar *name, gint id, gchar *submenu)
{
- ObMenu *self, *sub;
+ ObMenu *self;
ObMenuEntry *e;
if (!(self = menu_from_name(name))) return;
- if (!(sub = menu_from_name(submenu))) return;
e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_SUBMENU, id);
- e->data.submenu.submenu = sub;
+ e->data.submenu.name = g_strdup(submenu);
self->entries = g_list_append(self->entries, e);
}
@@ -359,3 +360,15 @@ ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id)
}
return ret;
}
+
+void menu_find_submenus(ObMenu *self)
+{
+ GList *it;
+
+ for (it = self->entries; it; it = g_list_next(it)) {
+ ObMenuEntry *e = it->data;
+
+ if (e->type == OB_MENU_ENTRY_TYPE_SUBMENU)
+ e->data.submenu.submenu = menu_from_name(e->data.submenu.name);
+ }
+}