[gnome-text-editor] searchbar: handle up/down keys while focused on search entry
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] searchbar: handle up/down keys while focused on search entry
- Date: Wed, 30 Jun 2021 21:25:29 +0000 (UTC)
commit 4c6733a3e4248706516d951bee50c8173c2969e0
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 30 14:24:19 2021 -0700
searchbar: handle up/down keys while focused on search entry
src/editor-search-bar.c | 31 +++++++++++++++++++++++++++++++
src/editor-search-bar.ui | 5 +++++
2 files changed, 36 insertions(+)
---
diff --git a/src/editor-search-bar.c b/src/editor-search-bar.c
index c45596b..619a1c1 100644
--- a/src/editor-search-bar.c
+++ b/src/editor-search-bar.c
@@ -306,6 +306,36 @@ on_notify_search_text_cb (EditorSearchBar *self,
self->scroll_to_first_match = TRUE;
}
+static gboolean
+on_search_key_pressed_cb (GtkEventControllerKey *key,
+ guint keyval,
+ guint keycode,
+ GdkModifierType state,
+ EditorSearchBar *self)
+{
+ g_assert (GTK_IS_EVENT_CONTROLLER_KEY (key));
+ g_assert (EDITOR_IS_SEARCH_BAR (self));
+
+ if (state == 0)
+ {
+ switch (keyval)
+ {
+ case GDK_KEY_Up:
+ _editor_search_bar_move_next (self, FALSE);
+ return TRUE;
+
+ case GDK_KEY_Down:
+ _editor_search_bar_move_previous (self, FALSE);
+ return TRUE;
+
+ default:
+ break;
+ }
+ }
+
+ return FALSE;
+}
+
static void
editor_search_bar_dispose (GObject *object)
{
@@ -409,6 +439,7 @@ editor_search_bar_class_init (EditorSearchBarClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorSearchBar, search_entry);
gtk_widget_class_bind_template_child (widget_class, EditorSearchBar, word_button);
gtk_widget_class_bind_template_callback (widget_class, editor_search_bar_search_activate_cb);
+ gtk_widget_class_bind_template_callback (widget_class, on_search_key_pressed_cb);
signals [MOVE_NEXT_SEARCH] =
g_signal_new_class_handler ("move-next-search",
diff --git a/src/editor-search-bar.ui b/src/editor-search-bar.ui
index d69ff22..341011c 100644
--- a/src/editor-search-bar.ui
+++ b/src/editor-search-bar.ui
@@ -17,6 +17,11 @@
<property name="row">0</property>
<property name="column">0</property>
</layout>
+ <child>
+ <object class="GtkEventControllerKey">
+ <signal name="key-pressed" handler="on_search_key_pressed_cb"/>
+ </object>
+ </child>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]