[nautilus] query-editor: cancel search with entry's signal



commit dc2dffd6de00102d926f245cc7a1e40357fc92e8
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Mar 1 20:49:30 2015 -0300

    query-editor: cancel search with entry's signal
    
    After the introduction of GtkSearchEntry by commit
    5521f24f, the Esc key stopped working, specifically
    after the introduction of the GtkSearchEntry::'stop-search'
    signal.
    
    The old approach of adding a GtkBindingSet directly to the
    NautilusQueryEditor class then stopped working, as the Esc
    key won't be propagated by the search entry. Without the key
    catch, the NautlisQueryEditor::'cancel' signal couldn't be
    fired, which causes the Esc issue.
    
    By listening to the GtkSearchEntry::'stop-search' signal
    and sending NautilusQueryEditor::'cancel' right after,
    the Esc key is correctly detected and the problem is
    solved.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745305

 src/nautilus-query-editor.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/nautilus-query-editor.c b/src/nautilus-query-editor.c
index 14218ad..0e07bb2 100644
--- a/src/nautilus-query-editor.c
+++ b/src/nautilus-query-editor.c
@@ -202,7 +202,6 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class)
 {
        GObjectClass *gobject_class;
        GtkWidgetClass *widget_class;
-       GtkBindingSet *binding_set;
 
        gobject_class = G_OBJECT_CLASS (class);
         gobject_class->dispose = nautilus_query_editor_dispose;
@@ -237,9 +236,6 @@ nautilus_query_editor_class_init (NautilusQueryEditorClass *class)
                              g_cclosure_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);
 
-       binding_set = gtk_binding_set_by_class (class);
-       gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0);
-
        g_type_class_add_private (class, sizeof (NautilusQueryEditorDetails));
 }
 
@@ -268,6 +264,13 @@ entry_changed_cb (GtkWidget *entry, NautilusQueryEditor *editor)
        nautilus_query_editor_changed (editor);
 }
 
+static void
+nautilus_query_editor_on_stop_search (GtkWidget           *entry,
+                                      NautilusQueryEditor *editor)
+{
+       g_signal_emit (editor, signals[CANCEL], 0);
+}
+
 /* Type */
 
 static gboolean
@@ -936,6 +939,8 @@ setup_widgets (NautilusQueryEditor *editor)
                          G_CALLBACK (entry_activate_cb), editor);
        g_signal_connect (editor->details->entry, "search-changed",
                          G_CALLBACK (entry_changed_cb), editor);
+       g_signal_connect (editor->details->entry, "stop-search",
+                          G_CALLBACK (nautilus_query_editor_on_stop_search), editor);
 
        /* create the Current/All Files selector */
        editor->details->search_current_button = gtk_radio_button_new_with_label (NULL, _("Current"));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]