}
break;
case OB_MENU_ENTRY_TYPE_SUBMENU:
+ g_free(self->data.submenu.name);
+ break;
case OB_MENU_ENTRY_TYPE_SEPARATOR:
break;
}
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);
}
}
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);
+ }
+}
{
RrAppearance *item_a, *text_a;
gint th; /* temp */
+ ObMenu *sub;
item_a = ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
!self->entry->data.normal.enabled) ?
text_a->texture[0].data.text.string = self->entry->data.normal.label;
break;
case OB_MENU_ENTRY_TYPE_SUBMENU:
- text_a->texture[0].data.text.string =
- self->entry->data.submenu.submenu->title;
+ sub = self->entry->data.submenu.submenu;
+ text_a->texture[0].data.text.string = sub ? sub->title : "";
break;
case OB_MENU_ENTRY_TYPE_SEPARATOR:
break;
gint tw, th; /* temps */
GList *it;
gboolean has_icon = FALSE, has_bullet = FALSE;
+ ObMenu *sub;
XSetWindowBorderWidth(ob_display, self->window, ob_rr_theme->bwidth);
XSetWindowBorder(ob_display, self->window,
/* XXX has_icon = TRUE; */
break;
case OB_MENU_ENTRY_TYPE_SUBMENU:
- text_a->texture[0].data.text.string =
- e->entry->data.submenu.submenu->title;
+ sub = e->entry->data.submenu.submenu;
+ text_a->texture[0].data.text.string = sub ? sub->title : "";
RrMinsize(text_a, &tw, &th);
has_bullet = TRUE;
{
GList *mit, *fit;
+ menu_find_submenus(self->menu);
+
self->selected = NULL;
for (mit = self->menu->entries, fit = self->entries; mit && fit;
{
ObMenuFrame *f;
+ if (!self->entry->data.submenu.submenu) return;
+
f = menu_frame_new(self->entry->data.submenu.submenu,
self->frame->client);
menu_frame_move(f,