[gnome-builder] source-view: don't expose named textmarks



commit 72705a7e409d8c1bc7b611af5545774067837822
Author: Christian Hergert <christian hergert me>
Date:   Sat May 9 17:06:49 2015 -0700

    source-view: don't expose named textmarks
    
    This doesn't work right with multiple views, since the mark names would
    collide during concurrent scrolls.

 libide/ide-internal.h              |    1 +
 libide/ide-source-view-movements.c |    5 +++--
 libide/ide-source-view.c           |   15 ++++++++++++++-
 3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/libide/ide-internal.h b/libide/ide-internal.h
index cf84a45..a3b275c 100644
--- a/libide/ide-internal.h
+++ b/libide/ide-internal.h
@@ -101,6 +101,7 @@ IdeSettings        *_ide_settings_new                  (IdeContext            *c
                                                         gboolean               ignore_project_settings);
 IdeSourceRange     *_ide_source_range_new              (IdeSourceLocation     *begin,
                                                         IdeSourceLocation     *end);
+GtkTextMark        *_ide_source_view_get_scroll_mark   (IdeSourceView         *self);
 gboolean            _ide_source_view_mode_do_event     (IdeSourceViewMode     *mode,
                                                         GdkEventKey           *event,
                                                         gboolean              *remove);
diff --git a/libide/ide-source-view-movements.c b/libide/ide-source-view-movements.c
index 2d65a11..7f33cfc 100644
--- a/libide/ide-source-view-movements.c
+++ b/libide/ide-source-view-movements.c
@@ -20,6 +20,7 @@
 
 #include "ide-debug.h"
 #include "ide-enums.h"
+#include "ide-internal.h"
 #include "ide-source-iter.h"
 #include "ide-source-view-movements.h"
 #include "ide-vim-iter.h"
@@ -742,7 +743,7 @@ ide_source_view_movements_move_page (Movement *mv)
       text_iter_forward_to_nonspace_captive (&mv->insert);
       ide_source_view_movements_select_range (mv);
 
-      mark = gtk_text_buffer_get_mark (buffer, "scroll-mark");
+      mark = _ide_source_view_get_scroll_mark (mv->self);
       gtk_text_buffer_get_iter_at_line (buffer, &scroll_iter, line_top);
       gtk_text_buffer_move_mark (buffer, mark, &scroll_iter);
       gtk_text_view_scroll_to_mark (text_view, mark, 0.0, TRUE, 1.0, 1.0);
@@ -756,7 +757,7 @@ ide_source_view_movements_move_page (Movement *mv)
       text_iter_forward_to_nonspace_captive (&mv->insert);
       ide_source_view_movements_select_range (mv);
 
-      mark = gtk_text_buffer_get_mark (buffer, "scroll-mark");
+      mark = _ide_source_view_get_scroll_mark (mv->self);
       gtk_text_buffer_get_iter_at_line (buffer, &scroll_iter, line_bottom);
       gtk_text_buffer_move_mark (buffer, mark, &scroll_iter);
       gtk_text_view_scroll_to_mark (text_view, mark, 0.0, TRUE, 1.0, 0.0);
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 2e000dc..cf7d8d5 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -95,6 +95,7 @@ typedef struct
   GList                       *providers;
   GtkTextMark                 *rubberband_mark;
   GtkTextMark                 *rubberband_insert_mark;
+  GtkTextMark                 *scroll_mark;
   gchar                       *saved_search_text;
   GQueue                      *selections;
   GQueue                      *snippets;
@@ -1351,7 +1352,7 @@ ide_source_view_bind_buffer (IdeSourceView  *self,
 
   /* Create scroll mark used by movements */
   gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &iter);
-  gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (buffer), "scroll-mark", &iter, TRUE);
+  priv->scroll_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (buffer), NULL, &iter, TRUE);
 
   /* Create rubberband mark used by search rubberbanding */
   priv->rubberband_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (buffer),
@@ -1383,6 +1384,8 @@ ide_source_view_unbind_buffer (IdeSourceView  *self,
   if (priv->buffer == NULL)
     return;
 
+  priv->scroll_mark = NULL;
+
   if (priv->completion_blocked)
     {
       GtkSourceCompletion *completion;
@@ -6946,3 +6949,13 @@ ide_source_view_rollback_search (IdeSourceView *self)
 
   gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (self), priv->rubberband_mark, 0.0, TRUE, 0.0, 1.0);
 }
+
+GtkTextMark *
+_ide_source_view_get_scroll_mark (IdeSourceView *self)
+{
+  IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+
+  g_return_val_if_fail (IDE_IS_SOURCE_VIEW (self), NULL);
+
+  return priv->scroll_mark;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]