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 <cneumair@gnome.org>

Signed-off-by: Federico Mena Quintero <federico@novell.com>
This commit is contained in:
Federico Mena Quintero 2009-07-27 19:24:42 -05:00
parent b50548e350
commit d55ff39ad0

View File

@ -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)