changeset 14220:1d793e808e5b

[gaim-migrate @ 16901] Alt+n window switching for libgnt committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Sun, 20 Aug 2006 16:20:45 +0000
parents fe8c31618e6f
children d6d3dbe85a4c
files console/libgnt/gntmain.c
diffstat 1 files changed, 31 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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);
+				}
 			}
 		}
 	}