From 16409418547098616e9f0d53ead53b339d533d64 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Mon, 7 May 2007 11:42:24 +0100 Subject: Add key binding for the Search shortcut Add "search-shortcut", an action signal bound to MOD1+S. It will activate the Search shortcut item of the GtkFileChooserDefault widget. Signed-off-by: Emmanuele Bassi --- gtk/gtkfilechooserdefault.c | 43 +++++++++++++++++++++++++++++++++---------- 1 files changed, 33 insertions(+), 10 deletions(-) diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index d54e1d6..bb88e41 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -164,6 +164,8 @@ enum { QUICK_BOOKMARK, LOCATION_TOGGLE_POPUP, SHOW_HIDDEN, + SEARCH_SHORTCUT, + LAST_SIGNAL }; @@ -344,18 +346,19 @@ static void gtk_file_chooser_default_get_resizable_hints (GtkFileCh static gboolean gtk_file_chooser_default_should_respond (GtkFileChooserEmbed *chooser_embed); static void gtk_file_chooser_default_initial_focus (GtkFileChooserEmbed *chooser_embed); -static void location_popup_handler (GtkFileChooserDefault *impl, - const gchar *path); +static void location_popup_handler (GtkFileChooserDefault *impl, + const gchar *path); static void location_popup_on_paste_handler (GtkFileChooserDefault *impl); static void location_toggle_popup_handler (GtkFileChooserDefault *impl); -static void up_folder_handler (GtkFileChooserDefault *impl); -static void down_folder_handler (GtkFileChooserDefault *impl); -static void home_folder_handler (GtkFileChooserDefault *impl); -static void desktop_folder_handler (GtkFileChooserDefault *impl); -static void quick_bookmark_handler (GtkFileChooserDefault *impl, - gint bookmark_index); -static void show_hidden_handler (GtkFileChooserDefault *impl); -static void update_appearance (GtkFileChooserDefault *impl); +static void up_folder_handler (GtkFileChooserDefault *impl); +static void down_folder_handler (GtkFileChooserDefault *impl); +static void home_folder_handler (GtkFileChooserDefault *impl); +static void desktop_folder_handler (GtkFileChooserDefault *impl); +static void quick_bookmark_handler (GtkFileChooserDefault *impl, + gint bookmark_index); +static void show_hidden_handler (GtkFileChooserDefault *impl); +static void search_shortcut_handler (GtkFileChooserDefault *impl); +static void update_appearance (GtkFileChooserDefault *impl); static void set_current_filter (GtkFileChooserDefault *impl, GtkFileFilter *filter); @@ -594,6 +597,14 @@ _gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) NULL, NULL, _gtk_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[SEARCH_SHORTCUT] = + _gtk_binding_signal_new ("search-shortcut", + G_OBJECT_CLASS_TYPE (class), + G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, + G_CALLBACK (search_shortcut_handler), + NULL, NULL, + _gtk_marshal_VOID__VOID, + G_TYPE_NONE, 0); binding_set = gtk_binding_set_by_class (class); @@ -660,6 +671,10 @@ _gtk_file_chooser_default_class_init (GtkFileChooserDefaultClass *class) GDK_h, GDK_CONTROL_MASK, "show-hidden", 0); + gtk_binding_entry_add_signal (binding_set, + GDK_s, GDK_MOD1_MASK, + "search-shortcut", + 0); for (i = 0; i < 10; i++) gtk_binding_entry_add_signal (binding_set, @@ -9572,6 +9587,14 @@ desktop_folder_handler (GtkFileChooserDefault *impl) switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_DESKTOP)); } +/* Handler for the "search-shortcut" keybinding signal */ +static void +search_shortcut_handler (GtkFileChooserDefault *impl) +{ + if (impl->has_search) + switch_to_shortcut (impl, shortcuts_get_index (impl, SHORTCUTS_SEARCH)); +} + static void quick_bookmark_handler (GtkFileChooserDefault *impl, gint bookmark_index) -- 1.4.4.2