[gnome-builder] editor: fix search movements while focused in search entry



commit fca6e80aade1b6cf5dd618f940a393dbf0dc0a71
Author: Christian Hergert <chergert redhat com>
Date:   Mon Aug 7 10:55:51 2017 -0700

    editor: fix search movements while focused in search entry
    
    The GtkSearchEntry registers keybindings for ctrl+g/ctrl+shift+g to emit
    the previous-match/next-match signals. We need to connect those to our
    action implementations.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=785934

 libide/editor/ide-editor-search-bar.c |   44 ++++++++++++++++++++++++++++++---
 1 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/libide/editor/ide-editor-search-bar.c b/libide/editor/ide-editor-search-bar.c
index 931fa9c..6a0d056 100644
--- a/libide/editor/ide-editor-search-bar.c
+++ b/libide/editor/ide-editor-search-bar.c
@@ -454,11 +454,37 @@ search_entry_stop_search (IdeEditorSearchBar *self,
 }
 
 static void
-ide_editor_search_bar_activate (IdeEditorSearchBar *self,
-                                GtkSearchEntry     *search_entry)
+search_entry_previous_match (IdeEditorSearchBar *self,
+                             GtkSearchEntry     *entry)
 {
   g_assert (IDE_IS_EDITOR_SEARCH_BAR (self));
-  g_assert (GTK_IS_SEARCH_ENTRY (search_entry));
+  g_assert (GTK_IS_SEARCH_ENTRY (entry));
+
+  dzl_gtk_widget_action (GTK_WIDGET (self),
+                         "editor-view",
+                         "move-previous-search-result",
+                         NULL);
+}
+
+static void
+search_entry_next_match (IdeEditorSearchBar *self,
+                         GtkSearchEntry     *entry)
+{
+  g_assert (IDE_IS_EDITOR_SEARCH_BAR (self));
+  g_assert (GTK_IS_SEARCH_ENTRY (entry));
+
+  dzl_gtk_widget_action (GTK_WIDGET (self),
+                         "editor-view",
+                         "move-next-search-result",
+                         NULL);
+}
+
+static void
+search_entry_activate (IdeEditorSearchBar *self,
+                       GtkSearchEntry     *entry)
+{
+  g_assert (IDE_IS_EDITOR_SEARCH_BAR (self));
+  g_assert (GTK_IS_SEARCH_ENTRY (entry));
 
   dzl_gtk_widget_action (GTK_WIDGET (self),
                          "editor-view",
@@ -586,7 +612,7 @@ ide_editor_search_bar_init (IdeEditorSearchBar *self)
 
   g_signal_connect_swapped (self->search_entry,
                             "activate",
-                            G_CALLBACK (ide_editor_search_bar_activate),
+                            G_CALLBACK (search_entry_activate),
                             self);
 
   self->buffer_signals = dzl_signal_group_new (IDE_TYPE_BUFFER);
@@ -647,6 +673,16 @@ ide_editor_search_bar_init (IdeEditorSearchBar *self)
                             G_CALLBACK (search_entry_stop_search),
                             self);
 
+  g_signal_connect_swapped (self->search_entry,
+                            "previous-match",
+                            G_CALLBACK (search_entry_previous_match),
+                            self);
+
+  g_signal_connect_swapped (self->search_entry,
+                            "next-match",
+                            G_CALLBACK (search_entry_next_match),
+                            self);
+
   _ide_editor_search_bar_init_actions (self);
   _ide_editor_search_bar_init_shortcuts (self);
 }


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