static gboolean desk_menu_update(ObMenuFrame *frame, gpointer data) { ObMenu *menu = frame->menu; DesktopData *d = data; GList *it; gboolean empty = TRUE; gboolean onlyiconic = TRUE; menu_clear_entries(menu); for (it = focus_order; it; it = g_list_next(it)) { ObClient *c = it->data; if (focus_valid_target(c, d->desktop, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE)) { ObMenuEntry *e; empty = FALSE; if (c->iconic) { gchar *title = g_strdup_printf("(%s)", c->icon_title); e = menu_add_normal(menu, d->desktop, title, NULL, FALSE); g_free(title); } else { onlyiconic = FALSE; e = menu_add_normal(menu, d->desktop, c->title, NULL, FALSE); } if (config_menu_show_icons) { e->data.normal.icon = client_icon(c); RrImageRef(e->data.normal.icon); e->data.normal.icon_alpha = c->iconic ? OB_ICONIC_ALPHA : 0xff; } e->data.normal.data = c; } } if (empty || onlyiconic) { ObMenuEntry *e; /* no entries or only iconified windows, so add a * way to go to this desktop without uniconifying a window */ if (!empty) menu_add_separator(menu, SEPARATOR, NULL); e = menu_add_normal(menu, d->desktop, _("Go there..."), NULL, TRUE); if (d->desktop == screen_desktop) e->data.normal.enabled = FALSE; } return TRUE; /* always show */ }
static void parse_menu_item(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *label; gchar *icon; ObMenuEntry *e; if (state->parent) { /* Don't try to extract "icon" attribute if icons in user-defined menus are not enabled. */ if (obt_xml_attr_string(node, "label", &label)) { xmlNodePtr c; GSList *acts = NULL; c = obt_xml_find_node(node->children, "action"); while (c) { ObActionsAct *action = actions_parse(c); if (action) acts = g_slist_append(acts, action); c = obt_xml_find_node(node->next, "action"); } e = menu_add_normal(state->parent, -1, label, acts, TRUE); if (config_menu_show_icons && obt_xml_attr_string(node, "icon", &icon)) { RrImage *ic; ic = RrImageCacheFindName(ob_rr_icons, icon); if (ic) RrImageRef(ic); else { ic = RrImageNew(ob_rr_icons); if (!RrImageAddPictureName(ic, icon)) { RrImageUnref(ic); /* no need to keep it around */ ic = NULL; } } e->data.normal.icon = ic; if (e->data.normal.icon) e->data.normal.icon_alpha = 0xff; g_free(icon); } g_free(label); } } }
static gboolean self_update(ObMenuFrame *frame, gpointer data) { ObMenu *menu = frame->menu; ObMenuEntry *e; GList *it; guint desktop; menu_clear_entries(menu); for (desktop = 0; desktop < screen_num_desktops; desktop++) { gboolean empty = TRUE; gboolean onlyiconic = TRUE; menu_add_separator(menu, SEPARATOR, screen_desktop_names[desktop]); for (it = client_list; it; it = g_list_next(it)) { ObClient *c = it->data; if (focus_valid_target(c, desktop, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE)) { empty = FALSE; if (c->iconic) { gchar *title = g_strdup_printf("(%s)", c->icon_title); e = menu_add_normal(menu, desktop, title, NULL, FALSE); g_free(title); } else { onlyiconic = FALSE; e = menu_add_normal(menu, desktop, c->title, NULL, FALSE); e->data.normal.indent = get_order(c, desktop); } if (config_menu_show_icons) { e->data.normal.icon = client_icon(c); RrImageRef(e->data.normal.icon); e->data.normal.icon_alpha = c->iconic ? OB_ICONIC_ALPHA : 0xff; } e->data.normal.data = c; } } if (empty || onlyiconic) { /* no entries or only iconified windows, so add a * way to go to this desktop without uniconifying a window */ if (!empty) menu_add_separator(menu, SEPARATOR, NULL); e = menu_add_normal(menu, desktop, _("Go there..."), NULL, TRUE); if (desktop == screen_desktop) e->data.normal.enabled = FALSE; } } if (config_menu_manage_desktops) { menu_add_separator(menu, SEPARATOR, _("Manage desktops")); menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE); menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"), NULL, TRUE); } return TRUE; /* always show the menu */ }