[gnome-builder] editor-frame: Process key press events in the replace entry field



commit 765ddeb11cea46c591fbcdaab98e39485c1b1ffc
Author: Matthew Leeds <mleeds redhat com>
Date:   Thu Jul 14 00:11:45 2016 -0400

    editor-frame: Process key press events in the replace entry field
    
    When the user presses Enter, Escape, Up, or Down when the search entry
    field is focused, the search is executed, exited or advanced to the next
    result, respectively. This commit replicates that behavior for the
    replace entry field.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=768809

 libide/editor/ide-editor-frame.c |   40 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 40 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-frame.c b/libide/editor/ide-editor-frame.c
index ae60f26..8e8f1be 100644
--- a/libide/editor/ide-editor-frame.c
+++ b/libide/editor/ide-editor-frame.c
@@ -664,6 +664,40 @@ ide_editor_frame__search_key_press_event (IdeEditorFrame *self,
 }
 
 static gboolean
+ide_editor_frame__replace_key_press_event (IdeEditorFrame *self,
+                                           GdkEventKey    *event,
+                                           GtkSearchEntry *entry)
+{
+  g_assert (IDE_IS_EDITOR_FRAME (self));
+  g_assert (GTK_IS_SEARCH_ENTRY (entry));
+
+  switch (event->keyval)
+    {
+    case GDK_KEY_Escape:
+      ide_widget_action (GTK_WIDGET (self->search_frame), "search-entry", "exit-search", NULL);
+      return GDK_EVENT_STOP;
+
+    case GDK_KEY_KP_Enter:
+    case GDK_KEY_Return:
+      ide_widget_action (GTK_WIDGET (self->search_frame), "search-entry", "replace", NULL);
+      return GDK_EVENT_STOP;
+
+    case GDK_KEY_Down:
+      ide_widget_action (GTK_WIDGET (self), "frame", "next-search-result", NULL);
+      return GDK_EVENT_STOP;
+
+    case GDK_KEY_Up:
+      ide_widget_action (GTK_WIDGET (self), "frame", "previous-search-result", NULL);
+      return GDK_EVENT_STOP;
+
+    default:
+      break;
+    }
+
+  return GDK_EVENT_PROPAGATE;
+}
+
+static gboolean
 ide_editor_frame__source_view_focus_in_event (IdeEditorFrame *self,
                                              GdkEventKey   *event,
                                              IdeSourceView *source_view)
@@ -881,6 +915,12 @@ ide_editor_frame_constructed (GObject *object)
                            self,
                            G_CONNECT_SWAPPED);
 
+  g_signal_connect_object (self->replace_entry,
+                           "key-press-event",
+                           G_CALLBACK (ide_editor_frame__replace_key_press_event),
+                           self,
+                           G_CONNECT_SWAPPED);
+
   g_signal_connect_object (self->search_entry,
                            "populate-popup",
                            G_CALLBACK (ide_editor_frame__search_populate_popup),


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