[pitivi] Create audio and video controls for each layer



commit bdd53168349b4d6b65da15ac9d4e7aa54d6aeab5
Author: Paul Lange <palango gmx de>
Date:   Thu May 10 13:34:48 2012 -0500

    Create audio and video controls for each layer

 pitivi/timeline/layercontrols.py |    4 ++
 pitivi/timeline/timeline.py      |   58 ++++++++++++++++++++-----------------
 2 files changed, 35 insertions(+), 27 deletions(-)
---
diff --git a/pitivi/timeline/layercontrols.py b/pitivi/timeline/layercontrols.py
index 39a14b4..f10b516 100644
--- a/pitivi/timeline/layercontrols.py
+++ b/pitivi/timeline/layercontrols.py
@@ -97,6 +97,8 @@ class VideoLayerControl(BaseLayerControl):
     Layer control class for video layers
     """
 
+    __gtype_name__ = 'VideoLayerControl'
+
     def __init__(self):
         BaseLayerControl.__init__(self, "video")
 
@@ -118,6 +120,8 @@ class AudioLayerControl(BaseLayerControl):
     Layer control class for audio layers
     """
 
+    __gtype_name__ = 'AudioLayerControl'
+
     def __init__(self):
         BaseLayerControl.__init__(self, "audio")
 
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 99d9c0f..3c52a72 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -476,7 +476,7 @@ class TimelineControls(gtk.VBox, Loggable):
     def __init__(self):
         gtk.VBox.__init__(self)
         Loggable.__init__(self)
-        self._tracks_controls = []
+        self._track_controls = {}
         self._timeline = None
         self.set_spacing(LAYER_SPACING)
         #self.set_size_request(TRACK_CONTROL_WIDTH, -1)
@@ -489,44 +489,48 @@ class TimelineControls(gtk.VBox, Loggable):
     def setTimeline(self, timeline):
         self.debug("Setting timeline %s", timeline)
 
-        while self._tracks_controls:
-            self._trackRemovedCb(None, 0)
+        # remove old layer controls
+        print self._track_controls
+        for layer in self._track_controls.copy():
+            self._layerRemovedCb(None, layer)
 
         if timeline:
-            for track in timeline.get_tracks():
-                self._trackAddedCb(None, track)
+            for layer in timeline.get_layers():
+                self._layerAddedCb(None, layer)
 
-            timeline.connect("track-added", self._trackAddedCb)
-            timeline.connect("track-removed", self._trackRemovedCb)
+            timeline.connect("layer-added", self._layerAddedCb)
+            timeline.connect("layer-removed", self._layerRemovedCb)
             self.connect = True
 
         elif self._timeline:
-            self._timeline.disconnect_by_func(self._trackAddedCb)
-            self._timeline.disconnect_by_func(self._trackRemovedCb)
+            self._timeline.disconnect_by_func(self._layerAddedCb)
+            self._timeline.disconnect_by_func(self._layerRemovedCb)
 
         self._timeline = timeline
 
     timeline = property(getTimeline, setTimeline, None, "The timeline property")
 
-    def _trackAddedCb(self, timeline, track):
-        track_control = self._getControlForTrack(track)
-        self._tracks_controls.append(track_control)
-        self.pack_start(track_control, False, False)
-        track_control.show()
+    def _layerAddedCb(self, timeline, layer):
+        video_control = VideoLayerControl()
+        audio_control = AudioLayerControl()
 
-    def _trackRemovedCb(self, unused_timeline, position):
-        track = self._tracks_controls[position]
-        track.track = None
-        del self._tracks_controls[position]
-        self.remove(track)
-
-    def _getControlForTrack(self, track):
-        if track.props.track_type == ges.TRACK_TYPE_AUDIO:
-            return AudioLayerControl()
-        elif track.props.track_type == ges.TRACK_TYPE_VIDEO:
-            return VideoLayerControl()
-        elif track.props.track_type == ges.TRACK_TYPE_TEXT:
-            return None
+        map = {"audio": audio_control, "video": video_control}
+        self._track_controls[layer] = map
+
+        self.pack_start(video_control, False, False)
+        self.pack_start(audio_control, False, False)
+
+        audio_control.show()
+        video_control.show()
+
+    def _layerRemovedCb(self, timeline, layer):
+        audio_control = self._track_controls[layer]["audio"]
+        video_control = self._track_controls[layer]["video"]
+
+        self.remove(audio_control)
+        self.remove(video_control)
+
+        del self._track_controls[layer]
 
 
 class InfoStub(gtk.HBox, Loggable):



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