pitivi r1405 - trunk/pitivi/ui



Author: edwardrv
Date: Fri Nov 28 17:35:44 2008
New Revision: 1405
URL: http://svn.gnome.org/viewvc/pitivi?rev=1405&view=rev

Log:
moved zoom ratio calculation methods of Timeline to classmethods of zoominterface. removed dependency from gtk.Adjustment

Modified:
   trunk/pitivi/ui/timeline.py
   trunk/pitivi/ui/zoominterface.py

Modified: trunk/pitivi/ui/timeline.py
==============================================================================
--- trunk/pitivi/ui/timeline.py	(original)
+++ trunk/pitivi/ui/timeline.py	Fri Nov 28 17:35:44 2008
@@ -90,7 +90,7 @@
     unit_width = 10 
     # specific levels of zoom, in (multiplier, unit) pairs which 
     # from zoomed out to zoomed in
-    zoom_levels = (1, 5, 10, 20, 50, 100, 150) 
+
 
     def __init__(self):
         gst.log("Creating Timeline")
@@ -100,13 +100,6 @@
         self.instance = instance.PiTiVi
         self.playground = instance.PiTiVi.playground
 
-        self._zoom_adj = gtk.Adjustment()
-        self._zoom_adj.lower = self._computeZoomRatio(0)
-        self._zoom_adj.upper = self._computeZoomRatio(-1)
-        self._cur_zoom = 2
-        Zoomable.setZoomAdjustment(self._zoom_adj)
-        Zoomable.setZoomRatio(self._computeZoomRatio(self._cur_zoom))
-
         self._createUI()
 
     def _createUI(self):
@@ -229,12 +222,10 @@
         return self.zoom_levels[index]
 
     def _zoomInCb(self, unused_action):
-        self._cur_zoom = min(len(self.zoom_levels) - 1, self._cur_zoom + 1)
-        self._zoom_adj.set_value(self._computeZoomRatio(self._cur_zoom))
+        Zoomable.zoomIn()
 
     def _zoomOutCb(self, unused_action):
-        self._cur_zoom = max(0, self._cur_zoom - 1)
-        self._zoom_adj.set_value(self._computeZoomRatio(self._cur_zoom))
+        Zoomable.zoomOut()
 
     def deleteSelected(self, unused_action):
         instance.PiTiVi.current.timeline.deleteSelection()

Modified: trunk/pitivi/ui/zoominterface.py
==============================================================================
--- trunk/pitivi/ui/zoominterface.py	(original)
+++ trunk/pitivi/ui/zoominterface.py	Fri Nov 28 17:35:44 2008
@@ -26,7 +26,6 @@
 """
 
 import gst
-from pitivi.receiver import receiver, handler
 
 #
 # Complex Timeline interfaces v2 (01 Jul 2008)
@@ -42,9 +41,6 @@
 # ex : 1.0 = 1 pixel for a second
 #
 # Class Methods
-# . setZoomAdjustment(adj)
-# . getZoomAdjustment()
-# . getZoomRatio
 # . pixelToNs(pixels)
 # . nsToPixels(time)
 # . setZoomRatio
@@ -54,9 +50,11 @@
 class Zoomable(object):
 
     zoomratio = 10
-    zoom_adjustment = None
     sigid = None
     __instances = []
+    zoom_levels = (1, 5, 10, 20, 50, 100, 150) 
+    __cur_zoom = 2
+
 
     def __init__(self):
         object.__init__(self)
@@ -67,28 +65,23 @@
             self.__instances.remove(self)
 
     @classmethod
-    def _zoom_changed_cb(cls, adjustment):
-        cls.zoomratio = adjustment.get_value()
+    def setZoomRatio(cls, ratio):
+        cls.zoomratio = ratio
         cls.__zoomChanged()
 
     @classmethod
-    def setZoomAdjustment(cls, adjustment):
-        if cls.zoom_adjustment:
-            cls.zoom_adjustment.disconnect(cls.sigid)
-            cls.zoom_adjustment = None
-        if adjustment:
-            cls.sigid = adjustment.connect("value-changed", 
-                cls._zoom_changed_cb)
-            cls.zoom_adjustment = adjustment
-            cls._zoom_changed_cb(adjustment)
+    def zoomIn(cls):
+        cls.__cur_zoom = min(len(cls.zoom_levels) - 1, cls.__cur_zoom + 1)
+        cls.setZoomRatio(cls._computeZoomRatio(cls.__cur_zoom))
 
     @classmethod
-    def getZoomAdjustment(cls):
-        return cls.zoom_adjustment
+    def zoomOut(cls):
+        cls.__cur_zoom = max(0, cls.__cur_zoom - 1)
+        cls.setZoomRatio(cls._computeZoomRatio(cls.__cur_zoom))
 
     @classmethod
-    def setZoomRatio(cls, ratio):
-        cls.zoom_adjustment.set_value(ratio)
+    def _computeZoomRatio(cls, index):
+        return cls.zoom_levels[index]
 
     @classmethod
     def pixelToNs(cls, pixel):



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