[meld] Extract common code in on_key_press_event() and



commit 250066249e06241e3bfd3863c1a233fb45f40a12
Author: Vincent Legoll <vincent legoll gmail com>
Date:   Tue Apr 21 20:52:47 2009 +0200

    Extract common code in on_key_press_event() and
    on_key_release_event() to a _update_linkmap_buttons()
    helper function.
---
 filediff.py |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/filediff.py b/filediff.py
index c773520..ac5063c 100644
--- a/filediff.py
+++ b/filediff.py
@@ -298,15 +298,18 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
                 for t in self.textview:
                     t.set_insert_spaces_instead_of_tabs(value)
 
+    def _update_linkmap_buttons(self):
+        for l in self.linkmap[:self.num_panes - 1]:
+            a = l.get_allocation()
+            w = self.pixbuf_copy0.get_width()
+            l.queue_draw_area(0,      0, w, a[3])
+            l.queue_draw_area(a[2]-w, 0, w, a[3])
+
     def on_key_press_event(self, object, event):
         x = self.keylookup.get(event.keyval, 0)
         if self.keymask | x != self.keymask:
             self.keymask |= x
-            for l in self.linkmap[:self.num_panes-1]:
-                a = l.get_allocation()
-                w = self.pixbuf_copy0.get_width()
-                l.queue_draw_area(0,      0, w, a[3])
-                l.queue_draw_area(a[2]-w, 0, w, a[3])
+            self._update_linkmap_buttons()
         elif event.keyval == gtk.keysyms.Escape:
             self.findbar.hide()
 
@@ -314,11 +317,7 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
         x = self.keylookup.get(event.keyval, 0)
         if self.keymask & ~x != self.keymask:
             self.keymask &= ~x
-            for l in self.linkmap[:self.num_panes-1]:
-                a = l.get_allocation()
-                w = self.pixbuf_copy0.get_width()
-                l.queue_draw_area(0,      0, w, a[3])
-                l.queue_draw_area(a[2]-w, 0, w, a[3])
+            self._update_linkmap_buttons()
 
     def is_modified(self):
         return 1 in [b.modified for b in self.bufferdata]



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