[meld/ui-next: 15/35] sourceview: Pull some GTK+ helper methods into a mixin class for reuse
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/ui-next: 15/35] sourceview: Pull some GTK+ helper methods into a mixin class for reuse
- Date: Sat, 16 Feb 2019 21:45:03 +0000 (UTC)
commit 2a7cfc06dfc147da7cc26f2bfca5e95d2126e6bd
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Nov 26 07:36:10 2018 +1000
sourceview: Pull some GTK+ helper methods into a mixin class for reuse
meld/sourceview.py | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/meld/sourceview.py b/meld/sourceview.py
index 7977afe8..906fd221 100644
--- a/meld/sourceview.py
+++ b/meld/sourceview.py
@@ -90,7 +90,21 @@ class TextviewLineAnimation:
self.anim_type = anim_type
-class MeldSourceView(GtkSource.View):
+class SourceViewHelperMixin:
+
+ def get_y_for_line_num(self, line):
+ buf = self.get_buffer()
+ it = buf.get_iter_at_line(line)
+ y, h = self.get_line_yrange(it)
+ if line >= buf.get_line_count():
+ return y + h
+ return y
+
+ def get_line_num_for_y(self, y):
+ return self.get_line_at_y(y)[0].get_line()
+
+
+class MeldSourceView(GtkSource.View, SourceViewHelperMixin):
__gtype_name__ = "MeldSourceView"
@@ -201,17 +215,6 @@ class MeldSourceView(GtkSource.View):
clipboard = self.get_clipboard(Gdk.SELECTION_CLIPBOARD)
clipboard.request_text(text_received_cb)
- def get_y_for_line_num(self, line):
- buf = self.get_buffer()
- it = buf.get_iter_at_line(line)
- y, h = self.get_line_yrange(it)
- if line >= buf.get_line_count():
- return y + h
- return y
-
- def get_line_num_for_y(self, y):
- return self.get_line_at_y(y)[0].get_line()
-
def add_fading_highlight(
self, mark0, mark1, colour_name, duration,
anim_type=TextviewLineAnimationType.fill, starting_alpha=1.0):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]