[pitivi/ges] Refactor the way we handle the timeline/tracks in TimelineControls/TrackControls



commit 34c4c5f2fe7bd7be3a9a22ed3353b9f45bf8294d
Author: Thibault Saunier <thibault saunier collabora com>
Date:   Thu Feb 2 19:48:05 2012 -0300

    Refactor the way we handle the timeline/tracks in TimelineControls/TrackControls

 pitivi/timeline/timeline.py |   18 ++++++++++++------
 pitivi/timeline/track.py    |   35 +++++++++++++++++++++++++++--------
 2 files changed, 39 insertions(+), 14 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 895e3a9..f1f58e0 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -455,12 +455,19 @@ class TimelineControls(gtk.VBox, Loggable):
         while self._tracks:
             self._trackRemovedCb(None, 0)
 
-        if self._timeline:
-            for track in self._timeline.get_tracks():
+        if timeline:
+            for track in timeline.get_tracks():
                 self._trackAddedCb(None, track)
 
-            self._timeline.connect("track-added", self._trackAddedCb)
-            self._timeline.connect("track-removed", self._trackRemovedCb)
+            timeline.connect("track-added", self._trackAddedCb)
+            timeline.connect("track-removed", self._trackRemovedCb)
+            self.connect = True
+
+        elif self._timeline:
+            self._timeline.disconnect_by_func(self._trackAddedCb)
+            self._timeline.disconnect_by_func(self._trackRemovedCb)
+
+        self._timeline = timeline
 
     timeline = property(getTimeline, setTimeline, None, "The timeline property")
 
@@ -471,9 +478,8 @@ class TimelineControls(gtk.VBox, Loggable):
         track.show()
 
     def _trackRemovedCb(self, unused_timeline, position):
-        self.timeline.disconnect_by_function(self._trackAddedCb)
-        self.timeline.disconnect_by_function(self._trackRemovedCb)
         track = self._tracks[position]
+        track.track = None
         del self._tracks[position]
         self.remove(track)
 
diff --git a/pitivi/timeline/track.py b/pitivi/timeline/track.py
index e86c43f..205a031 100644
--- a/pitivi/timeline/track.py
+++ b/pitivi/timeline/track.py
@@ -262,14 +262,19 @@ class StartHandle(TrimHandle):
 
         def drag_start(self, item, target, event):
             self.debug("Trim start %s" % target)
-            TimelineController.drag_start(self, item, target, event)
+            TrackObjectController.drag_start(self, item, target, event)
+
             if self._view.element.is_locked():
                 elem = self._view.element.get_timeline_object()
             else:
                 elem = self._view.element
-            self._context = TrimStartContext(self._view.timeline, elem, set([]))
+
+            self._context = EditingContext(elem, self._view.timeline,
+                ges.EDIT_MODE_TRIM, ges.EDGE_START, set([]),
+                self.app.settings)
             self._context.connect("clip-trim", self.clipTrimCb)
             self._context.connect("clip-trim-finished", self.clipTrimFinishedCb)
+
             self._view.app.action_log.begin("trim object")
 
         def clipTrimCb(self, unused_TrimStartContext, clip_uri, position):
@@ -661,14 +666,28 @@ class TrackControls(gtk.Label, Loggable):
         # centered vertically when the represented track has a single layer.
         self.set_padding(0, LAYER_SPACING * 2)
         self.set_markup(self._getTrackName(track))
-        self.track = track
-        self.timeline = track.get_timeline()
+        self._track = None
+        self._timeline = None
+        self.setTrack(track)
         self._setSize(layers_count=1)
 
-    def _setTrack(self):
-        self.timeline = self.track.get_timeline()
-        if self.track:
-            self._maxPriorityChanged(None, self.track.max_priority)
+    def getTrack(self):
+        return self._track
+
+    def setTrack(self, track):
+        if self._track:
+            self._timeline.disconnect_by_func(self._layerAddedCb)
+            self._timeline.disconnect_by_func(self._layerRemovedCb)
+
+        self._track = track
+        if track:
+            self._timeline = track.get_timeline()
+            self._timeline.connect("layer-added", self._layerAddedCb)
+            self._timeline.connect("layer-removed", self._layerRemovedCb)
+        else:
+            self._timeline = None
+
+    track = property(getTrack, setTrack, None, "The (GESTrack property")
 
     def _layerAddedCb(self, timeline, unused_layer):
         max_priority = len(timeline.get_layers())



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