Allow focusing conversation history and the userlist focusable via

Wed, 29 Oct 2008 19:38:14 +0000

author
Sadrul Habib Chowdhury <sadrul@pidgin.im>
date
Wed, 29 Oct 2008 19:38:14 +0000
changeset 24543
324d12c36342
parent 24542
974dc8d888e4
child 24545
95b50f8a2161

Allow focusing conversation history and the userlist focusable via
keyboard. We used to have this feature in older versions (2.3 and below),
thanks to the GtkPaned widget we used to use (for the resizable entry!).
The bindings are F6, or Ctrl+F6. Fixes #7148.

pidgin/gtkconv.c file | annotate | diff | comparison | revisions
--- a/pidgin/gtkconv.c	Wed Oct 29 16:46:38 2008 +0000
+++ b/pidgin/gtkconv.c	Wed Oct 29 19:38:14 2008 +0000
@@ -1911,6 +1911,40 @@
 }
 
 static gboolean
+gtkconv_cycle_focus(PidginConversation *gtkconv, GtkDirectionType dir)
+{
+	PurpleConversation *conv = gtkconv->active_conv;
+	gboolean chat = purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT;
+	GtkWidget *next = NULL;
+	struct {
+		GtkWidget *from;
+		GtkWidget *to;
+	} transitions[] = {
+		{gtkconv->entry, gtkconv->imhtml},
+		{gtkconv->imhtml, chat ? gtkconv->u.chat->list : gtkconv->entry},
+		{chat ? gtkconv->u.chat->list : NULL, gtkconv->entry},
+		{NULL, NULL}
+	}, *ptr;
+
+	for (ptr = transitions; !next && ptr->from; ptr++) {
+		GtkWidget *from, *to;
+		if (dir == GTK_DIR_TAB_FORWARD) {
+			from = ptr->from;
+			to = ptr->to;
+		} else {
+			from = ptr->to;
+			to = ptr->from;
+		}
+		if (gtk_widget_is_focus(from))
+			next = to;
+	}
+
+	if (next)
+		gtk_widget_grab_focus(next);
+	return !!next;
+}
+
+static gboolean
 conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event)
 {
 	PidginWindow *win;
@@ -1971,7 +2005,10 @@
 #endif
 				return TRUE;
 				break;
-
+			case GDK_F6:
+				if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD))
+					return TRUE;
+				break;
 		} /* End of switch */
 	}
 
@@ -1998,6 +2035,10 @@
 				return TRUE;
 			}
 			break;
+		case GDK_F6:
+			if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD))
+				return TRUE;
+			break;
 		}
 	}
 	return FALSE;

mercurial