[pitivi] ruler: Reuse the scroll logic of the timeline



commit 1df2069b728f5c8f4d5d09f49c8764f0910eaaa2
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Fri Nov 13 02:12:18 2015 +0100

    ruler: Reuse the scroll logic of the timeline
    
    Now when CTRL+scroll on the ruler, the time at the current
    mouse cursor position remains in place.
    
    Reviewed-by: Thibault Saunier <tsaunier gnome org>
    Differential Revision: https://phabricator.freedesktop.org/D563

 pitivi/timeline/ruler.py    |   15 +--------------
 pitivi/timeline/timeline.py |    4 +---
 2 files changed, 2 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/timeline/ruler.py b/pitivi/timeline/ruler.py
index ba65d7d..99b4e61 100644
--- a/pitivi/timeline/ruler.py
+++ b/pitivi/timeline/ruler.py
@@ -212,20 +212,7 @@ class ScaleRuler(Gtk.DrawingArea, Zoomable, Loggable):
         return False
 
     def do_scroll_event(self, event):
-        if event.state & Gdk.ModifierType.CONTROL_MASK:
-            # Control + scroll = zoom
-            if event.direction == Gdk.ScrollDirection.UP:
-                Zoomable.zoomIn()
-            elif event.direction == Gdk.ScrollDirection.DOWN:
-                Zoomable.zoomOut()
-        else:
-            # No modifier key held down, just scroll
-            if event.direction in (Gdk.ScrollDirection.UP,
-                                   Gdk.ScrollDirection.LEFT):
-                self.timeline.scroll_left()
-            elif event.direction in (Gdk.ScrollDirection.DOWN,
-                                     Gdk.ScrollDirection.RIGHT):
-                self.timeline.scroll_right()
+        self.timeline.timeline.do_scroll_event(event)
 
     def setProjectFrameRate(self, rate):
         """
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 1c82249..3903791 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -263,8 +263,6 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
         self.get_accessible().set_name("timeline canvas")
         self.__fake_event_widget = None
 
-        self.connect("scroll-event", self.__scrollEventCb)
-
         # A lot of operations go through these callbacks.
         self.add_events(Gdk.EventType.BUTTON_PRESS | Gdk.EventType.BUTTON_RELEASE)
         self.connect("button-press-event", self.__buttonPressEventCb)
@@ -544,7 +542,7 @@ class Timeline(Gtk.EventBox, Zoomable, Loggable):
 
     # Gtk events management
 
-    def __scrollEventCb(self, unused_widget, event):
+    def do_scroll_event(self, event):
         res, delta_x, delta_y = event.get_scroll_deltas()
         if not res:
             res, direction = event.get_scroll_direction()


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