pidgin: 61ca2fe9: Allow focusing conversation history and ...

sadrul at pidgin.im sadrul at pidgin.im
Wed Oct 29 17:45:36 EDT 2008


-----------------------------------------------------------------
Revision: 61ca2fe9d6a8984b52d59c8692a78c71a00fb443
Ancestor: 60193e450f3d2697db72618bd7b32ba469e53a31
Author: sadrul at pidgin.im
Date: 2008-10-29T19:38:14
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/61ca2fe9d6a8984b52d59c8692a78c71a00fb443

Modified files:
        pidgin/gtkconv.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- pidgin/gtkconv.c	611aa9dcd187a5f62f774fb20acd3a1cdda56936
+++ pidgin/gtkconv.c	774147c5a06f8527f74e6feba906d6b1d56abad7
@@ -1911,6 +1911,40 @@ static gboolean
 }
 
 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 @@ conv_keypress_common(PidginConversation 
 #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 @@ conv_keypress_common(PidginConversation 
 				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;


More information about the Commits mailing list