diff options
author | Matthias Clasen <mclasen@redhat.com> | 2015-01-24 13:32:31 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2015-01-24 13:32:31 -0500 |
commit | b3c28e14fe184ee61f1904021ba42af5052bc9da (patch) | |
tree | 19f43072656204cda844c2f30672d309a73be144 /gtk/gtkfilechooserwidget.c | |
parent | 8f9c8120b9d8a4cfa9ed1777da37f7a2d618a3a6 (diff) | |
download | gtk+-b3c28e14fe184ee61f1904021ba42af5052bc9da.tar.gz |
file chooser: search improvements
Make it so that typing switches to search unless we have a better
use for the key events, and stop search if the entry is emptied.
Diffstat (limited to 'gtk/gtkfilechooserwidget.c')
-rw-r--r-- | gtk/gtkfilechooserwidget.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 8e039a6ef5..c6bd8ddbd3 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -64,6 +64,7 @@ #include "gtkrecentfilter.h" #include "gtkrecentmanager.h" #include "gtkscrolledwindow.h" +#include "gtksearchentry.h" #include "gtkseparatormenuitem.h" #include "gtksettings.h" #include "gtksizegroup.h" @@ -418,7 +419,9 @@ static void gtk_file_chooser_widget_hierarchy_changed (GtkWidget *w GtkWidget *previous_toplevel); static void gtk_file_chooser_widget_style_updated (GtkWidget *widget); static void gtk_file_chooser_widget_screen_changed (GtkWidget *widget, - GdkScreen *previous_screen); + GdkScreen *previous_screen); +static gboolean gtk_file_chooser_widget_key_press_event (GtkWidget *widget, + GdkEventKey *event); static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser, GFile *folder, @@ -1239,6 +1242,22 @@ browse_files_key_press_event_cb (GtkWidget *widget, return FALSE; } +static gboolean +gtk_file_chooser_widget_key_press_event (GtkWidget *widget, + GdkEventKey *event) +{ + GtkFileChooserWidget *impl = (GtkFileChooserWidget *) widget; + GtkFileChooserWidgetPrivate *priv = impl->priv; + + if (priv->operation_mode != OPERATION_MODE_SEARCH) + operation_mode_set (impl, OPERATION_MODE_SEARCH); + + if (gtk_search_entry_handle_event (GTK_SEARCH_ENTRY (priv->search_entry), (GdkEvent *)event)) + return TRUE; + + return FALSE; +} + /* Callback used when the file list's popup menu is detached */ static void popup_menu_detach_cb (GtkWidget *attach_widget, @@ -6247,8 +6266,6 @@ search_entry_activate_cb (GtkEntry *entry, const char *text; text = gtk_entry_get_text (GTK_ENTRY (priv->search_entry)); - if (strlen (text) == 0) - return; /* reset any existing query object */ if (priv->search_query) @@ -6257,6 +6274,9 @@ search_entry_activate_cb (GtkEntry *entry, priv->search_query = NULL; } + if (strlen (text) == 0) + return; + search_start_query (impl, text); } @@ -7039,6 +7059,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class) widget_class->hierarchy_changed = gtk_file_chooser_widget_hierarchy_changed; widget_class->style_updated = gtk_file_chooser_widget_style_updated; widget_class->screen_changed = gtk_file_chooser_widget_screen_changed; + widget_class->key_press_event = gtk_file_chooser_widget_key_press_event; /* * Signals |