[gtk+] file chooser: search improvements
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] file chooser: search improvements
- Date: Sat, 24 Jan 2015 18:36:16 +0000 (UTC)
commit b3c28e14fe184ee61f1904021ba42af5052bc9da
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Jan 24 13:32:31 2015 -0500
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.
gtk/gtkfilechooserwidget.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 8e039a6..c6bd8dd 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]