Mercurial > pidgin.yaz
comparison pidgin/gtkconv.c @ 24268:1335376ba33f
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.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Wed, 29 Oct 2008 19:38:14 +0000 |
parents | ea5909557bc5 |
children | 8282911d5e17 |
comparison
equal
deleted
inserted
replaced
24267:ea5909557bc5 | 24268:1335376ba33f |
---|---|
1909 if (most_active != NULL && most_active != gtkconv) | 1909 if (most_active != NULL && most_active != gtkconv) |
1910 pidgin_conv_window_switch_gtkconv(win, most_active); | 1910 pidgin_conv_window_switch_gtkconv(win, most_active); |
1911 } | 1911 } |
1912 | 1912 |
1913 static gboolean | 1913 static gboolean |
1914 gtkconv_cycle_focus(PidginConversation *gtkconv, GtkDirectionType dir) | |
1915 { | |
1916 PurpleConversation *conv = gtkconv->active_conv; | |
1917 gboolean chat = purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT; | |
1918 GtkWidget *next = NULL; | |
1919 struct { | |
1920 GtkWidget *from; | |
1921 GtkWidget *to; | |
1922 } transitions[] = { | |
1923 {gtkconv->entry, gtkconv->imhtml}, | |
1924 {gtkconv->imhtml, chat ? gtkconv->u.chat->list : gtkconv->entry}, | |
1925 {chat ? gtkconv->u.chat->list : NULL, gtkconv->entry}, | |
1926 {NULL, NULL} | |
1927 }, *ptr; | |
1928 | |
1929 for (ptr = transitions; !next && ptr->from; ptr++) { | |
1930 GtkWidget *from, *to; | |
1931 if (dir == GTK_DIR_TAB_FORWARD) { | |
1932 from = ptr->from; | |
1933 to = ptr->to; | |
1934 } else { | |
1935 from = ptr->to; | |
1936 to = ptr->from; | |
1937 } | |
1938 if (gtk_widget_is_focus(from)) | |
1939 next = to; | |
1940 } | |
1941 | |
1942 if (next) | |
1943 gtk_widget_grab_focus(next); | |
1944 return !!next; | |
1945 } | |
1946 | |
1947 static gboolean | |
1914 conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event) | 1948 conv_keypress_common(PidginConversation *gtkconv, GdkEventKey *event) |
1915 { | 1949 { |
1916 PidginWindow *win; | 1950 PidginWindow *win; |
1917 PurpleConversation *conv; | 1951 PurpleConversation *conv; |
1918 int curconv; | 1952 int curconv; |
1969 #else | 2003 #else |
1970 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | 2004 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); |
1971 #endif | 2005 #endif |
1972 return TRUE; | 2006 return TRUE; |
1973 break; | 2007 break; |
1974 | 2008 case GDK_F6: |
2009 if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD)) | |
2010 return TRUE; | |
2011 break; | |
1975 } /* End of switch */ | 2012 } /* End of switch */ |
1976 } | 2013 } |
1977 | 2014 |
1978 /* If ALT (or whatever) was held down... */ | 2015 /* If ALT (or whatever) was held down... */ |
1979 else if (event->state & GDK_MOD1_MASK) | 2016 else if (event->state & GDK_MOD1_MASK) |
1995 case GDK_F2: | 2032 case GDK_F2: |
1996 if (gtk_widget_is_focus(GTK_WIDGET(win->notebook))) { | 2033 if (gtk_widget_is_focus(GTK_WIDGET(win->notebook))) { |
1997 infopane_entry_activate(gtkconv); | 2034 infopane_entry_activate(gtkconv); |
1998 return TRUE; | 2035 return TRUE; |
1999 } | 2036 } |
2037 break; | |
2038 case GDK_F6: | |
2039 if (gtkconv_cycle_focus(gtkconv, event->state & GDK_SHIFT_MASK ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD)) | |
2040 return TRUE; | |
2000 break; | 2041 break; |
2001 } | 2042 } |
2002 } | 2043 } |
2003 return FALSE; | 2044 return FALSE; |
2004 } | 2045 } |