From d55ff39ad0e8cdfa2ce37c2551b2177026436c65 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Mon, 27 Jul 2009 19:24:42 -0500 Subject: [PATCH] bgo#161489 - In the file chooser, let the left/right arrow keys switch focus between the file list and shortcuts Based on a patch by Christian Neumair Signed-off-by: Federico Mena Quintero --- gtk/gtkfilechooserdefault.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index f296621abf..ff4d1cfe97 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -4055,14 +4055,28 @@ shortcuts_pane_create (GtkFileChooserDefault *impl, return vbox; } +static gboolean +key_is_left_or_right (GdkEventKey *event) +{ + guint modifiers; + + modifiers = gtk_accelerator_get_default_mod_mask (); + + return ((event->keyval == GDK_Right + || event->keyval == GDK_KP_Right + || event->keyval == GDK_Left + || event->keyval == GDK_KP_Left) + && (event->state & modifiers) == 0); +} + /* Handles key press events on the file list, so that we can trap Enter to * activate the default button on our own. Also, checks to see if '/' has been * pressed. See comment by tree_view_keybinding_cb() for more details. */ static gboolean -trap_activate_cb (GtkWidget *widget, - GdkEventKey *event, - gpointer data) +browse_files_key_press_event_cb (GtkWidget *widget, + GdkEventKey *event, + gpointer data) { GtkFileChooserDefault *impl; int modifiers; @@ -4082,6 +4096,12 @@ trap_activate_cb (GtkWidget *widget, return TRUE; } + if (key_is_left_or_right (event)) + { + gtk_widget_grab_focus (impl->browse_shortcuts_tree_view); + return TRUE; + } + if ((event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter || event->keyval == GDK_KP_Enter @@ -4660,7 +4680,7 @@ create_file_list (GtkFileChooserDefault *impl) g_signal_connect (impl->browse_files_tree_view, "row-activated", G_CALLBACK (list_row_activated), impl); g_signal_connect (impl->browse_files_tree_view, "key-press-event", - G_CALLBACK (trap_activate_cb), impl); + G_CALLBACK (browse_files_key_press_event_cb), impl); g_signal_connect (impl->browse_files_tree_view, "popup-menu", G_CALLBACK (list_popup_menu_cb), impl); g_signal_connect (impl->browse_files_tree_view, "button-press-event", @@ -10774,6 +10794,12 @@ shortcuts_key_press_event_cb (GtkWidget *widget, modifiers = gtk_accelerator_get_default_mod_mask (); + if (key_is_left_or_right (event)) + { + gtk_widget_grab_focus (impl->browse_files_tree_view); + return TRUE; + } + if ((event->keyval == GDK_BackSpace || event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete)