Index: src/tabwin.c =================================================================== --- src/tabwin.c (revision 28197) +++ src/tabwin.c (working copy) @@ -25,13 +25,17 @@ #endif #ifndef WIN_ICON_SIZE -#define WIN_ICON_SIZE 48 +#define WIN_ICON_SIZE 32 #endif #ifndef WIN_ICON_BORDER #define WIN_ICON_BORDER 5 #endif +#ifndef ICON_LABEL_TRUNC_WIDTH +#define ICON_LABEL_TRUNC_WIDTH 28 +#endif + #include #include #include @@ -111,17 +115,6 @@ gtk_label_set_markup (GTK_LABEL (t->class), markup); g_free (markup); - - if (t->display_workspace) - { - message = g_strdup_printf ("[%i] - %s", workspace + 1, label); - } - else - { - message = g_strdup_printf ("%s", label); - } - gtk_label_set_text (GTK_LABEL (t->label), message); - g_free (message); } static void @@ -185,16 +178,61 @@ } static GtkWidget * +createIconLabel(const gchar *str, int truncate, Tabwin *t, int workspace) +{ + GtkWidget *icon_label; + gchar *label_text, *trunc_label_text; + int l_paren_index; + + /* chop non-essential info */ + label_text = g_strstr_len(str, -1, "("); + + if ( label_text != NULL ) + { + label_text = g_strndup(str, label_text - str); + } + else + { + label_text = g_strdup(str); + } + /* handle multiple workspaces */ + if (t->display_workspace) + { + trunc_label_text = g_strdup_printf("[%i] - %s", workspace + 1, label_text); + g_free(label_text); + label_text = trunc_label_text; + } + /* handle gazillions of windows */ + if ( truncate && strlen(label_text) > ICON_LABEL_TRUNC_WIDTH) + { + trunc_label_text = g_strndup(label_text, ICON_LABEL_TRUNC_WIDTH - 3); + g_free (label_text); + label_text = trunc_label_text; + + trunc_label_text = g_strdup_printf("%s...", label_text); + g_free (label_text); + label_text = trunc_label_text; + } + icon_label = gtk_label_new(""); + gtk_label_set_text( GTK_LABEL(icon_label), label_text); + g_free(label_text); + gtk_misc_set_alignment( GTK_MISC(icon_label), 0.0, 0.5); + return icon_label; +} + +static GtkWidget * createWindowlist (GdkScreen * scr, Client * current, Client * new, unsigned int cycle_range, Tabwin * t) { ScreenInfo *screen_info; Client *c2; GdkRectangle monitor_sz; - GtkWidget *windowlist, *icon; + GtkWidget *windowlist, *icon, *icon_label; GList *next; unsigned int grid_cols; unsigned int n_clients; unsigned int grid_rows; + unsigned int table_x; + unsigned int table_y; int i, packpos; int msx, msy; gint monitor; @@ -216,23 +254,30 @@ monitor = find_monitor_at_point (scr, msx, msy); gdk_screen_get_monitor_geometry (scr, monitor, &monitor_sz); - /* add the width of the border on each side */ - grid_cols = (monitor_sz.width / (WIN_ICON_SIZE + 2 * WIN_ICON_BORDER)) * 0.75; - grid_rows = n_clients / grid_cols + 1; + /* add the width of the border on top and bottom */ + grid_rows = (monitor_sz.height / (WIN_ICON_SIZE + 2 * WIN_ICON_BORDER)) * 0.75; + grid_cols = 2 * (n_clients / grid_rows + 1); windowlist = gtk_table_new (grid_rows, grid_cols, FALSE); t->grid_cols = grid_cols; t->grid_rows = grid_rows; - /* pack the client icons */ + /* pack the client icons and labels */ for (c2 = current, i = 0; c2 && i < n_clients; i++, c2 = c2->next) { if (!clientSelectMask (c2, cycle_range, WINDOW_REGULAR_FOCUSABLE)) continue; icon = createWindowIcon (c2); + table_x = 2 * (packpos / grid_rows); + table_y = packpos % grid_rows; gtk_table_attach (GTK_TABLE (windowlist), GTK_WIDGET (icon), - packpos % grid_cols, packpos % grid_cols + 1, - packpos / grid_cols, packpos / grid_cols + 1, - GTK_FILL, GTK_FILL, 7, 7); + table_x, table_x + 1, + table_y, table_y + 1, + GTK_FILL, GTK_FILL, 5, 5); + icon_label = createIconLabel(c2->name, table_x > 0, t, c2->win_workspace); + gtk_table_attach (GTK_TABLE (windowlist), GTK_WIDGET( icon_label ), + table_x + 1, table_x + 2, + table_y, table_y + 1, + GTK_FILL, GTK_FILL, 5, 5); packpos++; t->head = g_list_append (t->head, icon); if (c2 == new) @@ -295,12 +340,6 @@ gtk_container_set_border_width (GTK_CONTAINER (frame), 0); gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0); - tabwin->label = gtk_label_new (""); - gtk_label_set_use_markup (GTK_LABEL (tabwin->label), FALSE); - gtk_label_set_justify (GTK_LABEL (tabwin->label), GTK_JUSTIFY_CENTER); - gtk_box_pack_start (GTK_BOX (vbox), tabwin->label, TRUE, TRUE, 0); - gtk_widget_set_size_request (GTK_WIDGET (tabwin->label), 240, -1); - windowlist = createWindowlist (scr, current, new, cycle_range, tabwin); tabwin->container = windowlist; gtk_container_add (GTK_CONTAINER (frame), windowlist); @@ -314,7 +353,6 @@ #if 0 if (GTK_CHECK_VERSION (2, 6, 2)) { - gtk_label_set_ellipsize (GTK_LABEL (tabwin->label), PANGO_ELLIPSIZE_END); gtk_label_set_ellipsize (GTK_LABEL (tabwin->class), PANGO_ELLIPSIZE_END); } #endif Index: src/tabwin.h =================================================================== --- src/tabwin.h (revision 28197) +++ src/tabwin.h (working copy) @@ -40,7 +40,6 @@ /* these don't have to be */ GtkWidget *class; - GtkWidget *label; GtkWidget *container; GList *current; gulong selected_callback;