]> Dogcows Code - chaz/openbox/commitdiff
make the combined client list menu not suck quite as bad
authorMikael Magnusson <mikachu@comhem.se>
Mon, 12 Mar 2007 01:59:49 +0000 (01:59 +0000)
committerMikael Magnusson <mikachu@comhem.se>
Mon, 12 Mar 2007 01:59:49 +0000 (01:59 +0000)
openbox/client_list_combined_menu.c

index c18c9c201d35216414d538181a3aec321932b5d7..125845de65641db414b6ebff17272157982a5028 100644 (file)
@@ -36,6 +36,7 @@ ObMenu *combined_menu;
 static void self_update(ObMenuFrame *frame, gpointer data)
 {
     ObMenu *menu = frame->menu;
+    ObMenuEntry *e;
     GList *it;
     gint i;
     gboolean icons = FALSE;
@@ -44,14 +45,22 @@ static void self_update(ObMenuFrame *frame, gpointer data)
     menu_clear_entries(menu);
 
     for (desktop = 0; desktop < screen_num_desktops; desktop++) {
+        gboolean empty = TRUE;
+
+        menu_add_separator(menu, -1);
+        e = menu_add_normal(menu, -1, NULL, NULL);
+        e->data.normal.enabled = FALSE;
+        e->data.normal.label = g_strdup(screen_desktop_names[desktop]);
+        menu_add_separator(menu, -1);
         for (it = focus_order[desktop], i = 0; it; it = g_list_next(it), ++i) {
             ObClient *c = it->data;
             if (client_normal(c) && (!c->skip_taskbar || c->iconic)) {
                 GSList *acts = NULL;
                 ObAction* act;
-                ObMenuEntry *e;
                 const ObClientIcon *icon;
 
+                empty = FALSE;
+
                 if (!icons && c->iconic) {
                     icons = TRUE;
                     menu_add_separator(menu, -1);
@@ -76,9 +85,22 @@ static void self_update(ObMenuFrame *frame, gpointer data)
                 }
             }
         }
-        menu_add_separator(menu, -1);
-        menu_add_separator(menu, -1);
         icons = FALSE;
+
+        if (empty) {
+            /* no entries */
+
+            GSList *acts = NULL;
+            ObAction* act;
+            ObMenuEntry *e;
+
+            act = action_from_string("Desktop", OB_USER_ACTION_MENU_SELECTION);
+            act->data.desktop.desk = desktop;
+            acts = g_slist_append(acts, act);
+            e = menu_add_normal(menu, 0, _("Go there..."), acts);
+            if (desktop == screen_desktop)
+                e->data.normal.enabled = FALSE;
+        }
     }
 }
 
@@ -103,7 +125,9 @@ static void client_dest(ObClient *client, gpointer data)
     GList *eit;
     for (eit = combined_menu->entries; eit; eit = g_list_next(eit)) {
         ObMenuEntry *meit = eit->data;
-        if (meit->type == OB_MENU_ENTRY_TYPE_NORMAL) {
+        if (meit->type == OB_MENU_ENTRY_TYPE_NORMAL &&
+            meit->data.normal.actions)
+        {
             ObAction *a = meit->data.normal.actions->data;
             ObClient *c = a->data.any.c;
             if (c == client)
This page took 0.024311 seconds and 4 git commands to generate.