[gaim-migrate @ 16901]

Sun, 20 Aug 2006 16:20:45 +0000

author
Ethan Blanton <elb@pidgin.im>
date
Sun, 20 Aug 2006 16:20:45 +0000
changeset 14282
4b948c7a0eb4
parent 14281
bb395cb6e106
child 14283
7dc594b6a6db

[gaim-migrate @ 16901]
Alt+n window switching for libgnt

console/libgnt/gntmain.c file | annotate | diff | comparison | revisions
--- a/console/libgnt/gntmain.c	Sun Aug 20 14:56:53 2006 +0000
+++ b/console/libgnt/gntmain.c	Sun Aug 20 16:20:45 2006 +0000
@@ -12,6 +12,7 @@
 #include <locale.h>
 #include <unistd.h>
 #include <string.h>
+#include <ctype.h>
 
 /**
  * Notes: Interesting functions to look at:
@@ -240,6 +241,27 @@
 }
 
 static void
+switch_window_n(int n)
+{
+	GntWidget *w = NULL;
+	GList *l;
+
+	if (focus_list)
+		w = focus_list->data;
+
+	if ((l = g_list_nth(g_list_first(focus_list), n)) != NULL)
+	{
+		focus_list = l;
+		bring_on_top(focus_list->data);
+	}
+
+	if (w && (!focus_list || w != focus_list->data))
+	{
+		gnt_widget_set_focus(w, FALSE);
+	}
+}
+
+static void
 window_list_activate(GntTree *tree, gpointer null)
 {
 	GntWidget *widget = gnt_tree_get_selection_data(GNT_TREE(tree));
@@ -531,6 +553,15 @@
 					update_screen(NULL);
 					draw_taskbar();
 				}
+				else if (strlen(buffer) == 2 && isdigit(*(buffer + 1)))
+				{
+					int n = *(buffer + 1) - '0';
+
+					if (n == 0)
+						n = 10;
+
+					switch_window_n(n - 1);
+				}
 			}
 		}
 	}

mercurial