[meld] Draw currently displayed page area in DiffMap (closes bgo#470729)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Draw currently displayed page area in DiffMap (closes bgo#470729)
- Date: Tue, 20 Dec 2011 20:29:00 +0000 (UTC)
commit 3855a4fc9da2e57a48c0e49188e13a5118d6d957
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Dec 21 06:19:42 2011 +1000
Draw currently displayed page area in DiffMap (closes bgo#470729)
While ideally the scrollbar thumb should give a decent indication of
the location and size of the current viewing pane in terms of the
whole file, it doesn't always correspond very well. For example, in
long files, the scroll thumb will not shrink below a certain size for
usability purposes, which damages its use as an indicator.
This commit introduces a relatively subtle overlay on our DiffMaps to
show which part of the file is currently being displayed.
meld/diffmap.py | 23 ++++++++++++++++++++---
1 files changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/meld/diffmap.py b/meld/diffmap.py
index f723ac7..d30d1e6 100644
--- a/meld/diffmap.py
+++ b/meld/diffmap.py
@@ -52,8 +52,14 @@ class DiffMap(gtk.DrawingArea):
self.on_scrollbar_style_set)
scroll_size_hid = scrollbar.connect("size-allocate",
self.on_scrollbar_size_allocate)
+ adj_change_hid = self._scrolladj.connect("changed",
+ lambda w: self.queue_draw())
+ adj_val_hid = self._scrolladj.connect("value-changed",
+ lambda w: self.queue_draw())
self._handlers = [(scrollbar, scroll_style_hid),
- (scrollbar, scroll_size_hid)]
+ (scrollbar, scroll_size_hid),
+ (self._scrolladj, adj_change_hid),
+ (self._scrolladj, adj_val_hid)]
self._difffunc = change_chunk_fn
self.ctab = colour_map
self.queue_draw()
@@ -91,7 +97,7 @@ class DiffMap(gtk.DrawingArea):
context = self.window.cairo_create()
context.translate(0, y_start)
context.set_line_width(1)
- context.rectangle(x0 - 1, -1, x1 + 2, height + 1)
+ context.rectangle(x0 - 3, -1, x1 + 6, height + 1)
context.clip()
darken = lambda color: [x * 0.8 for x in color]
@@ -105,6 +111,17 @@ class DiffMap(gtk.DrawingArea):
context.set_source_rgb(*darken(color))
context.stroke()
+ page_color = (0., 0., 0., 0.1)
+ page_outline_color = (0.0, 0.0, 0.0, 0.3)
+ adj = self._scrolladj
+ s = round(height * (adj.value / adj.upper)) - 0.5
+ e = round(height * (adj.page_size / adj.upper))
+ context.set_source_rgba(*page_color)
+ context.rectangle(x0 - 2, s, x1 + 4, e)
+ context.fill_preserve()
+ context.set_source_rgba(*page_outline_color)
+ context.stroke()
+
def do_button_press_event(self, event):
if event.button == 1:
y_start = self.allocation.y - self._scroll_y - self._y_offset
@@ -132,7 +149,7 @@ gtk.widget_class_install_style_property(DiffMap,
'Width-wise padding',
'Padding to be left between left and '
'right edges and change blocks',
- 0.0, gobject.G_MAXFLOAT, 2.5,
+ 0.0, gobject.G_MAXFLOAT, 3.5,
gobject.PARAM_READABLE))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]