[meld/ui-next: 14/35] sourceview: Support limiting the width of source maps



commit 5cbca8d99157acab01378846da8701d1fc3149bf
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat Nov 24 13:54:15 2018 +1000

    sourceview: Support limiting the width of source maps
    
    When we've got three of these side-by-side, it adds up. The compact
    width of 40 pixels is scientifically pulled from thin air, but also it's
    only slightly more than we currently take up with a non-overlay
    scrollbars and a DiffMap.

 meld/sourceview.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/meld/sourceview.py b/meld/sourceview.py
index 62af96bf..7977afe8 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -404,6 +404,14 @@ class MeldSourceMap(GtkSource.Map):
 
     __gtype_name__ = "MeldSourceMap"
 
+    compact_view = GObject.Property(
+        type=bool,
+        nick="Limit the view to a fixed width",
+        default=False,
+    )
+
+    COMPACT_MODE_WIDTH = 40
+
     def do_draw_layer(self, layer, context):
         if layer != Gtk.TextViewLayer.BELOW_TEXT:
             return GtkSource.Map.do_draw_layer(self, layer, context)
@@ -451,3 +459,9 @@ class MeldSourceMap(GtkSource.Map):
         context.restore()
 
         return GtkSource.Map.do_draw_layer(self, layer, context)
+
+    def do_get_preferred_width(self):
+        if self.props.compact_view:
+            return (self.COMPACT_MODE_WIDTH, self.COMPACT_MODE_WIDTH)
+        else:
+            return GtkSource.Map.do_get_preferred_width(self)


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