Vertical alt-tab cycle window patch
David Pokorny
dbpokorny at gmail.com
Sun Oct 12 02:52:52 CEST 2008
Hello Xfce list,
I came recently to Xfce (from KDE...) and everything worked just fine except
the alt-tab cycle window. I very often have 8 or so windows of gvim open,
and I am very used to alt-tabbing through them. It was a major inconvenience
to go from the KDE-style "vertical tab window" with a label for every open
window to the Xfce-style "horizonal tab window" where a label is displayed
only for the currently selected window. I searched for a while for a
solution, but couldn't find one, so here is the diff for a hacked-up
tabwin.c and tabwin.h. The label is rather crudely chopped at the first left
parentheses (if it exists), which happens to work great for displaying gvim
window titles...haven't tested this out for more than 20 minutes, so there
may be unforeseen problems and so on. Hope someone finds this useful...any
comments most appreciated :)
David
diff -U 2 ./tabwin.c /xfwm4-4.4.2/src/tabwin.c
--- ./tabwin.c 2007-11-17 11:32:13.000000000 -0800
+++ /xfwm4-4.4.2/src/tabwin.c 2008-10-11 17:21:48.000000000 -0700
@@ -24,5 +24,5 @@
#ifndef WIN_ICON_SIZE
-#define WIN_ICON_SIZE 48
+#define WIN_ICON_SIZE 36
#endif
@@ -111,15 +111,4 @@
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);
}
@@ -162,4 +151,19 @@
}
+static int g_strfind(gchar *str,gchar c) {
+ int i;
+ i = 0;
+ while ( 1 ) {
+ if ( *str == c) {
+ return i;
+ } else if ( ! *str) {
+ break;
+ }
+ str++;
+ i++;
+ }
+ return -1;
+}
+
static GtkWidget *
createWindowlist (GdkScreen * scr, Client * current, Client * new, unsigned
int cycle_range, Tabwin * t)
@@ -168,5 +172,6 @@
Client *c2;
GdkRectangle monitor_sz;
- GtkWidget *windowlist, *icon;
+ GtkWidget *windowlist, *icon, *icon_label;
+ gchar *icon_label_text;
GList *next;
unsigned int grid_cols;
@@ -175,4 +180,5 @@
int i, packpos;
int msx, msy;
+ int l_paren_index;
gint monitor;
@@ -195,6 +201,6 @@
/* 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;
+ grid_cols = 2;
+ grid_rows = n_clients + 1;
windowlist = gtk_table_new (grid_rows, grid_cols, FALSE);
@@ -208,7 +214,21 @@
icon = createWindowIcon (c2);
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);
+ 0, 1,
+ packpos , packpos + 1,
+ GTK_FILL, GTK_FILL, 5, 5);
+ icon_label = gtk_label_new("");
+ l_paren_index = g_strfind(c2->name, '(');
+ if ( l_paren_index > 0 ) {
+ icon_label_text = g_strndup(c2->name, l_paren_index);
+ gtk_label_set_text( GTK_LABEL(icon_label) , icon_label_text);
+ g_free(icon_label_text);
+ } else {
+ gtk_label_set_text( GTK_LABEL(icon_label) , c2->name);
+ }
+ gtk_misc_set_alignment( GTK_MISC(icon_label),0.0,0.5);
+ gtk_table_attach (GTK_TABLE (windowlist), GTK_WIDGET( icon_label ),
+ 1, 2,
+ packpos, packpos + 1,
+ GTK_FILL, GTK_FILL, 5, 5);
packpos++;
t->head = g_list_append (t->head, icon);
@@ -273,10 +293,4 @@
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;
@@ -292,5 +306,4 @@
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);
}
diff -U 2 ./tabwin.h /xfwm4-4.4.2/src/tabwin.h
--- ./tabwin.h 2007-11-17 11:32:13.000000000 -0800
+++ /xfwm4-4.4.2/src/tabwin.h 2008-10-11 16:46:24.000000000 -0700
@@ -39,5 +39,4 @@
/* these don't have to be */
GtkWidget *class;
- GtkWidget *label;
GtkWidget *container;
GList *current;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.xfce.org/pipermail/xfce/attachments/20081011/57e2287f/attachment.html>
More information about the Xfce
mailing list