[gnome-builder] editor: use Return to activate next search result
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: use Return to activate next search result
- Date: Wed, 26 Jul 2017 02:13:08 +0000 (UTC)
commit 5dfc19edf534293f839c2f240f78acabd2c9b255
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 25 19:12:59 2017 -0700
editor: use Return to activate next search result
This refocuses the source view and advances to the next search result,
selecting it.
libide/editor/ide-editor-search-bar.c | 18 ++++++++++++++++++
libide/editor/ide-editor-view-actions.c | 20 ++++++++++++++++++++
2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/libide/editor/ide-editor-search-bar.c b/libide/editor/ide-editor-search-bar.c
index 78fbcaa..931fa9c 100644
--- a/libide/editor/ide-editor-search-bar.c
+++ b/libide/editor/ide-editor-search-bar.c
@@ -454,6 +454,19 @@ search_entry_stop_search (IdeEditorSearchBar *self,
}
static void
+ide_editor_search_bar_activate (IdeEditorSearchBar *self,
+ GtkSearchEntry *search_entry)
+{
+ g_assert (IDE_IS_EDITOR_SEARCH_BAR (self));
+ g_assert (GTK_IS_SEARCH_ENTRY (search_entry));
+
+ dzl_gtk_widget_action (GTK_WIDGET (self),
+ "editor-view",
+ "activate-next-search-result",
+ NULL);
+}
+
+static void
ide_editor_search_bar_destroy (GtkWidget *widget)
{
IdeEditorSearchBar *self = (IdeEditorSearchBar *)widget;
@@ -571,6 +584,11 @@ ide_editor_search_bar_init (IdeEditorSearchBar *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
+ g_signal_connect_swapped (self->search_entry,
+ "activate",
+ G_CALLBACK (ide_editor_search_bar_activate),
+ self);
+
self->buffer_signals = dzl_signal_group_new (IDE_TYPE_BUFFER);
dzl_signal_group_connect_swapped (self->buffer_signals,
diff --git a/libide/editor/ide-editor-view-actions.c b/libide/editor/ide-editor-view-actions.c
index 8f00f17..cd0c0ec 100644
--- a/libide/editor/ide-editor-view-actions.c
+++ b/libide/editor/ide-editor-view-actions.c
@@ -486,6 +486,25 @@ ide_editor_view_actions_move_previous_error (GSimpleAction *action,
}
static void
+ide_editor_view_actions_activate_next_search_result (GSimpleAction *action,
+ GVariant *variant,
+ gpointer user_data)
+{
+ IdeEditorView *self = user_data;
+ GtkTextIter begin;
+ GtkTextIter end;
+
+ g_assert (IDE_IS_EDITOR_VIEW (self));
+
+ ide_editor_view_move_next_search_result (self);
+
+ gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (self->buffer), &begin, &end);
+ gtk_widget_grab_focus (GTK_WIDGET (self->source_view));
+ gtk_text_buffer_select_range (GTK_TEXT_BUFFER (self->buffer), &begin, &end);
+ ide_source_view_scroll_to_insert (self->source_view);
+}
+
+static void
ide_editor_view_actions_move_next_search_result (GSimpleAction *action,
GVariant *variant,
gpointer user_data)
@@ -516,6 +535,7 @@ ide_editor_view_actions_properties (GSimpleAction *action,
}
static const GActionEntry editor_view_entries[] = {
+ { "activate-next-search-result", ide_editor_view_actions_activate_next_search_result },
{ "find", ide_editor_view_actions_find },
{ "find-replace", ide_editor_view_actions_find_replace },
{ "hide-search", ide_editor_view_actions_hide_search },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]