12 #define MENU_NAME "client-list-menu"
14 static GSList *desktop_menus;
20 static void desk_menu_update(ObMenuFrame *frame, gpointer data)
22 ObMenu *menu = frame->menu;
23 DesktopData *d = data;
26 gboolean icons = FALSE;
28 menu_clear_entries(menu);
30 for (it = focus_order[d->desktop], i = 0; it; it = g_list_next(it), ++i) {
31 ObClient *c = it->data;
32 if (client_normal(c)) {
38 if (!icons && c->iconic) {
40 menu_add_separator(menu, -1);
43 act = action_from_string("Activate",
44 OB_USER_ACTION_MENU_SELECTION);
45 act->data.activate.any.c = c;
46 acts = g_slist_prepend(NULL, act);
47 e = menu_add_normal(menu, i,
48 (c->iconic ? c->icon_title : c->title), acts);
50 if ((icon = client_icon(c, 32, 32))) {
51 e->data.normal.icon_width = icon->width;
52 e->data.normal.icon_height = icon->height;
53 e->data.normal.icon_data = icon->data;
60 /* executes it using the client in the actions, since we set that
61 when we make the actions! */
62 static void desk_menu_execute(ObMenuEntry *self, guint state, gpointer data)
66 for (it = self->data.normal.actions; it; it = g_slist_next(it))
68 ObAction *act = it->data;
69 action_run(it->data, act->data.any.c, state);
73 static void desk_menu_destroy(ObMenu *menu, gpointer data)
75 DesktopData *d = data;
79 desktop_menus = g_slist_remove(desktop_menus, menu);
82 static void self_update(ObMenuFrame *frame, gpointer data)
84 ObMenu *menu = frame->menu;
89 for (i = 0; i < screen_num_desktops; ++i) {
92 gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i);
93 DesktopData *data = g_new(DesktopData, 1);
96 submenu = menu_new(name, screen_desktop_names[i], data);
97 menu_set_update_func(submenu, desk_menu_update);
98 menu_set_execute_func(submenu, desk_menu_execute);
99 menu_set_destroy_func(submenu, desk_menu_destroy);
101 menu_add_submenu(menu, i, name);
105 desktop_menus = g_slist_append(desktop_menus, submenu);
107 it = g_slist_next(it);
109 for (; it; it = next, ++i) {
110 next = g_slist_next(it);
112 desktop_menus = g_slist_delete_link(desktop_menus, it);
113 menu_entry_remove(menu_find_entry_id(menu, i));
117 void client_list_menu_startup()
121 menu = menu_new(MENU_NAME, _("Desktops"), NULL);
122 menu_set_update_func(menu, self_update);