[gnome-builder/wip/libide-merge] handle enter, shift+enter, and escape from the search box
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] handle enter, shift+enter, and escape from the search box
- Date: Fri, 20 Mar 2015 03:38:07 +0000 (UTC)
commit 854d445c91c8135951fd269e337f90262f0751ad
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 19 20:37:26 2015 -0700
handle enter, shift+enter, and escape from the search box
next/previous search result, escape to go back to source view
src/editor/gb-editor-frame.c | 51 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 51 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-editor-frame.c b/src/editor/gb-editor-frame.c
index 0cb7a50..df85fbd 100644
--- a/src/editor/gb-editor-frame.c
+++ b/src/editor/gb-editor-frame.c
@@ -195,6 +195,45 @@ gb_editor_frame__drag_data_received (GbEditorFrame *self,
}
}
+static gboolean
+gb_editor_frame__search_key_press_event (GbEditorFrame *self,
+ GdkEventKey *event,
+ GdTaggedEntry *entry)
+{
+ g_assert (GB_IS_EDITOR_FRAME (self));
+ g_assert (GD_IS_TAGGED_ENTRY (entry));
+
+ if (event->keyval == GDK_KEY_Escape)
+ {
+ ide_source_view_clear_search (self->source_view);
+ gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
+ return TRUE;
+ }
+ else if ((event->keyval == GDK_KEY_KP_Enter) || (event->keyval == GDK_KEY_Return))
+ {
+ if ((event->state & GDK_SHIFT_MASK) == 0)
+ gb_widget_activate_action (GTK_WIDGET (self), "frame", "next-search-result", NULL);
+ else
+ gb_widget_activate_action (GTK_WIDGET (self), "frame", "previous-search-result", NULL);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static gboolean
+gb_editor_frame__source_view_focus_in_event (GbEditorFrame *self,
+ GdkEventKey *event,
+ IdeSourceView *source_view)
+{
+ g_assert (GB_IS_EDITOR_FRAME (self));
+ g_assert (IDE_IS_SOURCE_VIEW (source_view));
+
+ gtk_revealer_set_reveal_child (self->search_revealer, FALSE);
+
+ return FALSE;
+}
+
static void
gb_editor_frame_constructed (GObject *object)
{
@@ -207,6 +246,18 @@ gb_editor_frame_constructed (GObject *object)
G_CALLBACK (gb_editor_frame__drag_data_received),
self,
G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->source_view,
+ "focus-in-event",
+ G_CALLBACK (gb_editor_frame__source_view_focus_in_event),
+ self,
+ G_CONNECT_SWAPPED);
+
+ g_signal_connect_object (self->search_entry,
+ "key-press-event",
+ G_CALLBACK (gb_editor_frame__search_key_press_event),
+ self,
+ G_CONNECT_SWAPPED);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]