[meld/meld-3-12] sourceview: Change binding time to fix bad gutter drawing (bgo#739927)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/meld-3-12] sourceview: Change binding time to fix bad gutter drawing (bgo#739927)
- Date: Sun, 23 Nov 2014 04:22:00 +0000 (UTC)
commit ca7c67fe0f415c405ec64d44bf8dbe84115faf0f
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 e936d46..3d9f8b1 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]