[gnome-text-editor] openpopover: return to editor page upon Escape



commit a7ad3b9d07f08f9b1ad3af1a7662091b7c02e58a
Author: Christian Hergert <chergert redhat com>
Date:   Wed Oct 6 11:07:12 2021 -0700

    openpopover: return to editor page upon Escape

 src/editor-open-popover.c  | 22 ++++++++++++++++++++++
 src/editor-open-popover.ui |  1 +
 2 files changed, 23 insertions(+)
---
diff --git a/src/editor-open-popover.c b/src/editor-open-popover.c
index d241120..167854d 100644
--- a/src/editor-open-popover.c
+++ b/src/editor-open-popover.c
@@ -201,6 +201,27 @@ on_search_entry_activate_cb (EditorOpenPopover *self,
     on_list_view_activate_cb (self, 0, self->list_view);
 }
 
+static void
+on_search_entry_stop_search_cb (EditorOpenPopover *self,
+                                GtkSearchEntry    *search_entry)
+{
+  EditorWindow *window;
+
+  g_assert (EDITOR_IS_OPEN_POPOVER (self));
+  g_assert (GTK_IS_SEARCH_ENTRY (search_entry));
+
+  window = EDITOR_WINDOW (gtk_widget_get_root (GTK_WIDGET (self)));
+
+  gtk_popover_popdown (GTK_POPOVER (self));
+
+  if (window != NULL)
+    {
+      EditorPage *page = editor_window_get_visible_page (window);
+
+      gtk_widget_child_focus (GTK_WIDGET (page), GTK_DIR_TAB_FORWARD);
+    }
+}
+
 static void
 editor_open_popover_show (GtkWidget *widget)
 {
@@ -297,6 +318,7 @@ editor_open_popover_class_init (EditorOpenPopoverClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, on_list_view_activate_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_search_entry_activate_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_search_entry_changed_cb);
+  gtk_widget_class_bind_template_callback (widget_class, on_search_entry_stop_search_cb);
 }
 
 static void
diff --git a/src/editor-open-popover.ui b/src/editor-open-popover.ui
index 8e5c1b0..fce5680 100644
--- a/src/editor-open-popover.ui
+++ b/src/editor-open-popover.ui
@@ -31,6 +31,7 @@
             <property name="width-chars">25</property>
             <signal name="changed" handler="on_search_entry_changed_cb" swapped="true" 
object="EditorOpenPopover"/>
             <signal name="activate" handler="on_search_entry_activate_cb" swapped="true" 
object="EditorOpenPopover"/>
+            <signal name="stop-search" handler="on_search_entry_stop_search_cb" swapped="true" 
object="EditorOpenPopover"/>
           </object>
         </child>
         <child>


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