[openbox] client_list_menu
Artyom Mirgorodsky
man at alkar.net
Thu Feb 23 10:23:52 EST 2006
@@ -28,7 +28,8 @@
#include <glib.h>
-#define MENU_NAME "client-list-menu"
+#define DESKTOP_MENU_NAME "desktop-list-menu"
+#define CLIENT_MENU_NAME "client-list-menu"
static GSList *desktop_menus;
@@ -129,7 +130,7 @@ static void self_update(ObMenuFrame *fra
for (i = 0; i < screen_num_desktops; ++i) {
if (!it) {
ObMenu *submenu;
- gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i);
+ gchar *name = g_strdup_printf("%s-%u", DESKTOP_MENU_NAME, i);
DesktopData *data = g_new(DesktopData, 1);
data->desktop = i;
@@ -154,10 +155,64 @@ static void self_update(ObMenuFrame *fra
}
}
+static void client_self_update(ObMenuFrame *frame, gpointer gdata)
+{
+ ObMenu *menu = frame->menu;
+ menu->title = screen_desktop_names[screen_desktop];
+ menu_clear_entries(menu);
+
+ GList *it;
+ gint i;
+ gboolean icons = FALSE;
+ gboolean empty = TRUE;
+
+ for (it = focus_order[screen_desktop], i = 0; it; it = g_list_next(it),
++i)
+ {
+ ObClient *c = it->data;
+ if (client_normal(c) && !c->skip_taskbar) {
+ GSList *acts = NULL;
+ ObAction* act;
+ ObMenuEntry *e;
+ const ObClientIcon *icon;
+
+ empty = FALSE;
+
+ if (!icons && c->iconic) {
+ icons = TRUE;
+ menu_add_separator(menu, -1);
+ }
+
+ act = action_from_string("Activate",
+ OB_USER_ACTION_MENU_SELECTION);
+ act->data.activate.any.c = c;
+ acts = g_slist_append(acts, act);
+ e = menu_add_normal(menu, i,
+ (c->iconic ? c->icon_title : c->title),
acts);
+
+ if ((icon = client_icon(c, 32, 32))) {
+ e->data.normal.icon_width = icon->width;
+ e->data.normal.icon_height = icon->height;
+ e->data.normal.icon_data = icon->data;
+ }
+ }
+ }
+
+ if (empty)
+ {
+ ObMenuEntry *e;
+ e = menu_add_normal(menu, 0, _("No clients"), 0);
+ e->data.normal.enabled = FALSE;
+ }
+}
+
void client_list_menu_startup()
{
ObMenu *menu;
- menu = menu_new(MENU_NAME, _("Desktops"), NULL);
+ menu = menu_new(CLIENT_MENU_NAME, _("Clients"), NULL);
+ menu_set_update_func(menu, client_self_update);
+ menu_set_execute_func(menu, desk_menu_execute);
+
+ menu = menu_new(DESKTOP_MENU_NAME, _("Desktops"), NULL);
menu_set_update_func(menu, self_update);
}
--
С уважением,
Артём Миргородский
сотрудник технического отдела
mailto:man at alkar.net
More information about the openbox
mailing list