[gnome-builder/wip/libide-merge] allow stashing the search query
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/libide-merge] allow stashing the search query
- Date: Fri, 20 Mar 2015 03:37:37 +0000 (UTC)
commit d779b2b0a0c6ac30590124161fd796c57c20a33d
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 19 20:35:30 2015 -0700
allow stashing the search query
libide/ide-source-view.c | 31 ++++++++++++++++++++++++++++++-
libide/ide-source-view.h | 1 +
2 files changed, 31 insertions(+), 1 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 75a6677..2e95679 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -86,6 +86,7 @@ typedef struct
IdeSourceViewCapture *capture;
IdeSourceViewMode *mode;
GList *providers;
+ gchar *saved_search_text;
GQueue *selections;
GQueue *snippets;
GtkSourceCompletionProvider *snippets_provider;
@@ -3184,8 +3185,13 @@ ide_source_view_real_move_search (IdeSourceView *self,
gtk_source_search_settings_set_at_word_boundaries (settings, word_boundaries);
search_text = gtk_source_search_settings_get_search_text (settings);
+
if (search_text == NULL || search_text[0] == '\0')
- return;
+ {
+ if (priv->saved_search_text == NULL)
+ return;
+ gtk_source_search_settings_set_search_text (settings, priv->saved_search_text);
+ }
buffer = gtk_text_view_get_buffer (text_view);
gtk_text_buffer_get_selection_bounds (buffer, &begin, &end);
@@ -6212,3 +6218,26 @@ ide_source_view_get_visual_position (IdeSourceView *self,
if (column)
*column = gtk_source_view_get_visual_column (GTK_SOURCE_VIEW (self), &iter);
}
+
+void
+ide_source_view_clear_search (IdeSourceView *self)
+{
+ IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+ GtkSourceSearchSettings *search_settings;
+ const gchar *search_text;
+
+ g_return_if_fail (IDE_IS_SOURCE_VIEW (self));
+
+ search_settings = gtk_source_search_context_get_settings (priv->search_context);
+ search_text = gtk_source_search_settings_get_search_text (search_settings);
+
+ if ((search_text != NULL) &&
+ (search_text [0] != 0) &&
+ (0 != g_strcmp0 (priv->saved_search_text, search_text)))
+ {
+ g_free (priv->saved_search_text);
+ priv->saved_search_text = g_strdup (search_text);
+ }
+
+ gtk_source_search_settings_set_search_text (search_settings, NULL);
+}
diff --git a/libide/ide-source-view.h b/libide/ide-source-view.h
index 735fdaf..219055f 100644
--- a/libide/ide-source-view.h
+++ b/libide/ide-source-view.h
@@ -331,6 +331,7 @@ void ide_source_view_set_back_forward_list (IdeSource
gboolean ide_source_view_move_mark_onscreen (IdeSourceView *self,
GtkTextMark *mark);
gboolean ide_source_view_place_cursor_onscreen (IdeSourceView *self);
+void ide_source_view_clear_search (IdeSourceView *self);
void ide_source_view_scroll_mark_onscreen (IdeSourceView *self,
GtkTextMark *mark);
void ide_source_view_scroll_to_mark (IdeSourceView *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]