[epiphany] Emit close Signal to GtkDialog if GtkSearchEntry is focused



commit 4ffe4a4ea13727238f0b11a93f5f978185c9ad8f
Author: G√ľnther Wutz <info gunibert de>
Date:   Thu Mar 31 12:52:47 2016 +0200

    Emit close Signal to GtkDialog if GtkSearchEntry is focused
    
    https://bugzilla.gnome.org/show_bug.cgi?id=764408

 src/ephy-history-window.c       |   14 ++++++++++++++
 src/resources/history-dialog.ui |    1 +
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 67314ef..6aced0f 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -516,6 +516,19 @@ on_search_entry_changed (GtkSearchEntry    *entry,
   filter_now (self);
 }
 
+static gboolean
+on_search_key_press_event (GtkWidget        *widget,
+                          GdkEventKey       *event,
+                          EphyHistoryWindow *self)
+{
+  if (event->keyval == GDK_KEY_Escape) {
+    g_signal_emit_by_name (self, "close", NULL);
+    return GDK_EVENT_STOP;
+  }
+
+  return GDK_EVENT_PROPAGATE;
+}
+
 static void
 update_selection_actions (GActionGroup *action_group,
                           gboolean      has_selection)
@@ -690,6 +703,7 @@ ephy_history_window_class_init (EphyHistoryWindowClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, on_treeview_selection_changed);
   gtk_widget_class_bind_template_callback (widget_class, on_treeview_column_clicked_event);
   gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed);
+  gtk_widget_class_bind_template_callback (widget_class, on_search_key_press_event);
 }
 
 static void
diff --git a/src/resources/history-dialog.ui b/src/resources/history-dialog.ui
index 86425a4..ef6b226 100644
--- a/src/resources/history-dialog.ui
+++ b/src/resources/history-dialog.ui
@@ -70,6 +70,7 @@
             <property name="primary_icon_sensitive">False</property>
             <property name="placeholder_text" translatable="yes">Search history</property>
             <signal name="search-changed" handler="on_search_entry_changed"/>
+            <signal name="key-press-event" handler="on_search_key_press_event"/>
           </object>
         </child>
         <child>


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