[gnome-builder] source-view: scroll if no previous scroll has occurred



commit 55d7464b911e721c8409ce8f849ac93618d3b811
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 11 12:58:30 2016 +0300

    source-view: scroll if no previous scroll has occurred
    
    If the user has previously started scrolling, we won't be at the lower
    bound (likely). We should only begin scrolling to the insert mark if they
    have not yet moved the view.

 libide/ide-source-view.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index 7fc7804..a4af452 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -1364,9 +1364,12 @@ ide_source_view__buffer_loaded_cb (IdeSourceView *self,
                                    IdeBuffer     *buffer)
 {
   IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+  GtkAdjustment *adj;
   GtkTextMark *insert;
   GtkTextIter iter;
 
+  IDE_ENTRY;
+
   g_assert (IDE_IS_SOURCE_VIEW (self));
   g_assert (IDE_IS_BUFFER (buffer));
 
@@ -1380,13 +1383,17 @@ ide_source_view__buffer_loaded_cb (IdeSourceView *self,
     }
 
   insert = gtk_text_buffer_get_insert (GTK_TEXT_BUFFER (buffer));
-  ide_source_view_scroll_to_mark (self, insert, 0.0, TRUE, 0.5, 0.5, TRUE);
 
-  /*
-   * Store the line offset so movements are correct.
-   */
+  /* Store the line offset so movements are correct. */
   gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &iter, insert);
   priv->target_line_offset = gtk_text_iter_get_line_offset (&iter);
+
+  /* Only scroll if the user hasn't started an intermediate scroll */
+  adj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self));
+  if (gtk_adjustment_get_value (adj) == gtk_adjustment_get_lower (adj))
+    ide_source_view_scroll_to_mark (self, insert, 0.0, TRUE, 0.5, 0.5, TRUE);
+
+  IDE_EXIT;
 }
 
 static void


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