[meld] Tighten viewport restrictions when navigating changes (bgo#699310)



commit 1f549b9fc05dda860505f9560f130b198b6ebb3f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun May 5 08:42:56 2013 +1000

    Tighten viewport restrictions when navigating changes (bgo#699310)
    
    With this change, the first automatic diff centring forces the change
    to appear in the centre of the pane. Subsequent navigation still uses
    margins to avoid too much movement, but this patch also tightens those
    margins slightly to try to avoid having changes positioned too low on
    the screen.

 meld/filediff.py |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 3bc9ac1..18b2a6d 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1163,7 +1163,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
 
             if self.cursor.next is not None:
                 self.scheduler.add_task(
-                    lambda: self.next_diff(gtk.gdk.SCROLL_DOWN), True)
+                    lambda: self.next_diff(gtk.gdk.SCROLL_DOWN, True), True)
             else:
                 buf = self.textbuffer[1 if self.num_panes > 1 else 0]
                 self.on_cursor_position_changed(buf, None, True)
@@ -1813,7 +1813,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             self.queue_draw()
             self.recompute_label()
 
-    def next_diff(self, direction):
+    def next_diff(self, direction, centered=False):
         pane = self._get_focused_pane()
         if pane == -1:
             if len(self.textview) > 1:
@@ -1835,7 +1835,11 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             # Warp the cursor to the first line of next chunk
             if self.cursor.line != c[1]:
                 buf.place_cursor(buf.get_iter_at_line(c[1]))
-            self.textview[pane].scroll_to_mark(buf.get_insert(), 0.1)
+            if centered:
+                self.textview[pane].scroll_to_mark(buf.get_insert(), 0.0,
+                                                   True)
+            else:
+                self.textview[pane].scroll_to_mark(buf.get_insert(), 0.2)
 
     def copy_chunk(self, src, dst, chunk, copy_up):
         b0, b1 = self.textbuffer[src], self.textbuffer[dst]


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