summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechooserwidget.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-07-07 00:24:19 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-07-07 00:25:22 -0400
commit826c1db859ce1c33e34ec723dd7d72313a97a67d (patch)
treebeaea9c699552dc8933dd0a728ad2278f64c0769 /gtk/gtkfilechooserwidget.c
parentfb316156e24b1021c8680b05392be972645515fd (diff)
downloadgtk+-826c1db859ce1c33e34ec723dd7d72313a97a67d.tar.gz
file chooser: Add a shortcut to focus the sidebar
Alt+P used to do this in the gtk2 filechooser (well, sometimes). Add this back as a key binding. https://bugzilla.gnome.org/show_bug.cgi?id=720684
Diffstat (limited to 'gtk/gtkfilechooserwidget.c')
-rw-r--r--gtk/gtkfilechooserwidget.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 7d44cc909b..fb4c083fa5 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -376,6 +376,7 @@ enum {
SHOW_HIDDEN,
SEARCH_SHORTCUT,
RECENT_SHORTCUT,
+ PLACES_SHORTCUT,
LAST_SIGNAL
};
@@ -518,6 +519,7 @@ static void quick_bookmark_handler (GtkFileChooserWidget *impl,
static void show_hidden_handler (GtkFileChooserWidget *impl);
static void search_shortcut_handler (GtkFileChooserWidget *impl);
static void recent_shortcut_handler (GtkFileChooserWidget *impl);
+static void places_shortcut_handler (GtkFileChooserWidget *impl);
static void update_appearance (GtkFileChooserWidget *impl);
static void operation_mode_set (GtkFileChooserWidget *impl, OperationMode mode);
@@ -7816,6 +7818,13 @@ recent_shortcut_handler (GtkFileChooserWidget *impl)
operation_mode_set (impl, OPERATION_MODE_RECENT);
}
+/* Handler for the "places-shortcut" keybinding signal */
+static void
+places_shortcut_handler (GtkFileChooserWidget *impl)
+{
+ gtk_widget_child_focus (impl->priv->places_sidebar, GTK_DIR_LEFT);
+}
+
static void
quick_bookmark_handler (GtkFileChooserWidget *impl,
gint bookmark_index)
@@ -8127,6 +8136,26 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
_gtk_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * GtkFileChooserWidget::places-shortcut:
+ * @widget: the object which received the signal
+ *
+ * The ::places-shortcut signal is a [keybinding signal][GtkBindingSignal]
+ * which gets emitted when the user asks for it.
+ *
+ * This is used to move the focus to the places sidebar.
+ *
+ * The default binding for this signal is `Alt + P`.
+ */
+ signals[PLACES_SHORTCUT] =
+ g_signal_new_class_handler (I_("places-shortcut"),
+ G_OBJECT_CLASS_TYPE (class),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
+ G_CALLBACK (places_shortcut_handler),
+ NULL, NULL,
+ _gtk_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set,
@@ -8182,6 +8211,10 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
GDK_KEY_r, GDK_MOD1_MASK,
"recent-shortcut",
0);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_p, GDK_MOD1_MASK,
+ "places-shortcut",
+ 0);
for (i = 0; i < 10; i++)
gtk_binding_entry_add_signal (binding_set,