pitivi r1399 - trunk/pitivi/ui



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

Log:
timeline and timelinecanvas now use receiver object to handle instance and layerInfoList signals

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

Modified: trunk/pitivi/ui/timeline.py
==============================================================================
--- trunk/pitivi/ui/timeline.py	(original)
+++ trunk/pitivi/ui/timeline.py	Fri Nov 28 17:35:17 2008
@@ -37,6 +37,7 @@
 
 from gettext import gettext as _
 from timelinecanvas import TimelineCanvas
+from pitivi.receiver import receiver, handler
 
 # tooltip text for toolbar
 DELETE = _("Delete Selected")
@@ -102,24 +103,13 @@
         self._cur_zoom = 2
         self._zoom_adj.set_value(self._computeZoomRatio(self._cur_zoom))
 
-        # common LayerInfoList
         self.layerInfoList = LayerInfoList()
-
-        instance.PiTiVi.playground.connect('position',
-           self._playgroundPositionCb)
-        # project signals
-        instance.PiTiVi.connect("new-project-loading",
-            self._newProjectLoadingCb)
-        instance.PiTiVi.connect("new-project-loaded",
-            self._newProjectLoadedCb)
-        instance.PiTiVi.connect("new-project-failed",
-            self._newProjectFailedCb)
+        self.instance = instance.PiTiVi
+        self.playground = instance.PiTiVi.playground
         self._createUI()
 
         # force update of UI
         self.layerInfoList.setTimeline(instance.PiTiVi.current.timeline)
-        self.layerInfoList.connect("start-duration-changed",
-            self._layerStartDurationChanged)
 
     def _createUI(self):
         self.leftSizeGroup = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
@@ -197,20 +187,28 @@
         context.finish(True, False, timestamp)
         instance.PiTiVi.playground.switchToTimeline()
 
-## Project callbacks
+## Instance callbacks
+
+    instance = receiver()
 
+    @handler(instance, "new-project-loading")
     def _newProjectLoadingCb(self, unused_inst, project):
         self.layerInfoList.setTimeline(project.timeline)
 
+    @handler(instance, "new-project-loaded")
     def _newProjectLoadedCb(self, unused_inst, unused_project):
         # force set deadband when new timeline loads
         self.__canvas.zoomChanged()
 
+    @handler(instance, "new-project-failed")
     def _newProjectFailedCb(self, unused_inst, unused_reason, unused_uri):
         self.layerInfoList.setTimeline(None)
 
 ## layer callbacks
 
+    layerInfoList = receiver()
+
+    @handler(layerInfoList, "start-duration-changed")
     def _layerStartDurationChanged(self, unused_layer):
         self.ruler.startDurationChanged()
 
@@ -251,7 +249,10 @@
 
 ## PlayGround timeline position callback
 
-    def _playgroundPositionCb(self, unused_playground, smartbin, value):
+    playground = receiver()
+
+    @handler(playground, "position")
+    def _positionCb(self, unused_playground, smartbin, value):
         if isinstance(smartbin, SmartTimelineBin):
             # for the time being we only inform the ruler
             self.ruler.timelinePositionChanged(value, 0)

Modified: trunk/pitivi/ui/timelinecanvas.py
==============================================================================
--- trunk/pitivi/ui/timelinecanvas.py	(original)
+++ trunk/pitivi/ui/timelinecanvas.py	Fri Nov 28 17:35:17 2008
@@ -22,8 +22,6 @@
 
 class TimelineCanvas(goocanvas.Canvas, Zoomable):
 
-    layerInfoList = receiver()
-
     __layers = None
 
     def __init__(self, layerinfolist):
@@ -58,20 +56,6 @@
         self._razor.props.visibility = goocanvas.ITEM_INVISIBLE
         root.add_child(self._razor)
 
-## methods for dealing with updating the canvas size
-
-    def block_size_request(self, status):
-        self._block_size_request = status
-
-    @handler(layerInfoList, "start-duration-changed")
-    def _request_size(self, unused_item):
-        tl, br = Point.from_widget_bounds(self)
-        pw, ph = br - tl
-        tl, br = Point.from_item_bounds(self.tracks)
-        w, h = br - tl
-        if (w > pw) or (h > ph):
-            self.set_bounds(0, 0, w + 200, h)
-
 ## mouse callbacks
 
     def _mouseEnterCb(self, unused_item, unused_target, event):
@@ -190,6 +174,17 @@
 
 ## LayerInfoList callbacks
 
+    layerInfoList = receiver()
+
+    @handler(layerInfoList, "start-duration-changed")
+    def _request_size(self, unused_item):
+        tl, br = Point.from_widget_bounds(self)
+        pw, ph = br - tl
+        tl, br = Point.from_item_bounds(self.tracks)
+        w, h = br - tl
+        if (w > pw) or (h > ph):
+            self.set_bounds(0, 0, w + 200, h)
+
     @handler(layerInfoList, "layer-added")
     def _layerAddedCb(self, unused_infolist, layer, position):
         track = Track(comp=layer.composition)



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