[gnome-builder/wip/chergert/editorsearch] editor: interaction tweaks for search
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/chergert/editorsearch] editor: interaction tweaks for search
- Date: Wed, 11 Oct 2017 03:26:32 +0000 (UTC)
commit 7dee0897b4734f8408df5fb8e292ae4682ec979e
Author: Christian Hergert <chergert redhat com>
Date: Tue Oct 10 20:25:32 2017 -0700
editor: interaction tweaks for search
This tries to tweak things to be more like what we had before
the search refactoring.
src/libide/editor/ide-editor-search.c | 12 +++++++-----
src/libide/editor/ide-editor-view.c | 2 ++
src/plugins/command-bar/gb-vim.c | 13 ++++---------
3 files changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/src/libide/editor/ide-editor-search.c b/src/libide/editor/ide-editor-search.c
index da0b929..71b8de7 100644
--- a/src/libide/editor/ide-editor-search.c
+++ b/src/libide/editor/ide-editor-search.c
@@ -637,7 +637,7 @@ ide_editor_search_release_context (IdeEditorSearch *self)
g_assert (IDE_IS_EDITOR_SEARCH (self));
g_assert (self->context != NULL);
- if (self->context != NULL && self->interactive == 0)
+ if (self->context != NULL && self->interactive == 0 && self->visible == FALSE)
{
g_signal_handlers_disconnect_by_func (self->context,
G_CALLBACK (ide_editor_search_notify_occurrences_count),
@@ -898,10 +898,9 @@ ide_editor_search_set_visible (IdeEditorSearch *self,
if (visible != self->visible)
{
self->visible = visible;
- /* TODO: Dispose the context, but keep the search settings around.
- * Upon next movement, we can restore visibility that way.
- */
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_VISIBLE]);
+ if (!visible)
+ ide_editor_search_release_context (self);
}
}
@@ -1518,8 +1517,11 @@ ide_editor_search_end_interactive (IdeEditorSearch *self)
/* If we are leaving interactive mode, we want to disable the search
* highlight unless they were requested manually by other code.
*/
- if (self->context != NULL && self->interactive == 0)
+ if (self->context != NULL && self->interactive == 0 && self->visible == FALSE)
gtk_source_search_context_set_highlight (self->context, self->visible);
+
+ /* Maybe cleanup our search context. */
+ ide_editor_search_release_context (self);
}
/**
diff --git a/src/libide/editor/ide-editor-view.c b/src/libide/editor/ide-editor-view.c
index c5560dd..610c752 100644
--- a/src/libide/editor/ide-editor-view.c
+++ b/src/libide/editor/ide-editor-view.c
@@ -589,6 +589,7 @@ ide_editor_view_clear_search (IdeEditorView *self,
g_assert (IDE_IS_SOURCE_VIEW (view));
ide_editor_search_set_search_text (self->search, NULL);
+ ide_editor_search_set_visible (self->search, FALSE);
}
static void
@@ -613,6 +614,7 @@ ide_editor_view_move_search (IdeEditorView *self,
sel = IDE_EDITOR_SEARCH_SELECT_TO_RESULT;
ide_editor_search_set_extend_selection (self->search, sel);
+ ide_editor_search_set_visible (self->search, TRUE);
if (apply_count)
{
diff --git a/src/plugins/command-bar/gb-vim.c b/src/plugins/command-bar/gb-vim.c
index 664413a..91584ac 100644
--- a/src/plugins/command-bar/gb-vim.c
+++ b/src/plugins/command-bar/gb-vim.c
@@ -719,17 +719,12 @@ gb_vim_command_nohl (GtkWidget *active_widget,
if (IDE_IS_EDITOR_VIEW (active_widget))
{
- GtkSourceSearchContext *context = NULL;
- IdeSourceView *source_view = ide_editor_view_get_view (IDE_EDITOR_VIEW (active_widget));
-
- g_object_get (source_view, "search-context", &context, NULL);
- g_object_set (context, "highlight", FALSE, NULL);
- g_clear_object (&context);
-
+ IdeEditorSearch *search = ide_editor_view_get_search (IDE_EDITOR_VIEW (active_widget));
+ ide_editor_search_set_visible (search, FALSE);
return TRUE;
}
- else
- return gb_vim_set_source_view_error (error);
+
+ return gb_vim_set_source_view_error (error);
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]