[meld] sourceview: Change binding time to fix bad gutter drawing (bgo#739927)



commit abf9b8232c447f9058a191773d751b746d7b4b7c
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun Nov 23 14:06:41 2014 +1000

    sourceview: Change binding time to fix bad gutter drawing (bgo#739927)
    
    Why, my future self may ask, does this exist? What the hell? Well,
    see... here's how it is.
    
    In the past, we set all of these properties on a GtkSourceView
    manually, and GtkSourceView lazily instantiated its gutter objects and
    connected their signal handlers and everything was fine. Then we
    started doing construct-time binding with gsettings, which changed when
    the gutter was created. This then meant that instead of our signal
    handler for the textview's 'draw' signal being connected *before* the
    signal handler for doing gutter drawing it was connected *after*, but
    *only when* the show-line-numbers preference was active when we created
    our MeldSourceView object. The result was that our signal handler drew
    all over the GtkSourceGutter drawings and everyone was sad.
    
    The 'solution' is to *not* bind show-line-numbers during GObject construction
    and instead bind it after we've connected our other signal handler.

 meld/filediff.py   |    1 +
 meld/sourceview.py |    8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 33ce9ab..1c72a8c 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -203,6 +203,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
             buf.connect('end_user_action', self.on_textbuffer_end_user_action)
             v.set_buffer(buf)
             buf.data.connect('file-changed', self.notify_file_changed)
+            v.late_bind()
         self._keymask = 0
         self.load_font()
         self.meta = {}
diff --git a/meld/sourceview.py b/meld/sourceview.py
index a0c9e4f..97bc65b 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -20,7 +20,7 @@ from gi.repository import GLib
 from gi.repository import Gtk
 from gi.repository import GtkSource
 
-from meld.settings import bind_settings
+from meld.settings import bind_settings, settings
 
 
 class LanguageManager(object):
@@ -51,7 +51,6 @@ class MeldSourceView(GtkSource.View):
     __gsettings_bindings__ = (
         ('indent-width', 'tab-width'),
         ('insert-spaces-instead-of-tabs', 'insert-spaces-instead-of-tabs'),
-        ('show-line-numbers', 'show-line-numbers'),
         ('draw-spaces', 'draw-spaces'),
         ('wrap-mode', 'wrap-mode'),
     )
@@ -82,6 +81,11 @@ class MeldSourceView(GtkSource.View):
         for key, modifiers in self.replaced_entries:
             Gtk.binding_entry_remove(binding_set, key, modifiers)
 
+    def late_bind(self):
+        settings.bind(
+            'show-line-numbers', self, 'show-line-numbers',
+            Gio.SettingsBindFlags.DEFAULT)
+
     def get_y_for_line_num(self, line):
         buf = self.get_buffer()
         it = buf.get_iter_at_line(line)


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