diff options
author | Sadrul Habib Chowdhury <sadrul@pidgin.im> | 2008-10-29 19:38:14 +0000 |
---|---|---|
committer | Sadrul Habib Chowdhury <sadrul@pidgin.im> | 2008-10-29 19:38:14 +0000 |
commit | 35e38cfa917d1f789e0d96b4d93a15c4a8f4d3d2 (patch) | |
tree | c45afc7e342e5742a4b12965c5a0dc62d9d1d1b4 | |
parent | 2d598da49192084318e8f91124b5981928588308 (diff) | |
download | pidgin-35e38cfa917d1f789e0d96b4d93a15c4a8f4d3d2.tar.gz |
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.
-rw-r--r-- | pidgin/gtkconv.c | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/pidgin/gtkconv.c b/pidgin/gtkconv.c index f7c9b8e6ea..ac73fa03dc 100644 --- a/pidgin/gtkconv.c +++ b/pidgin/gtkconv.c @@ -1911,6 +1911,40 @@ move_to_next_unread_tab(PidginConversation *gtkconv, gboolean forward) } 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 *gtkconv, GdkEventKey *event) #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 *gtkconv, GdkEventKey *event) 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; |