[pitivi/ges] medialibrary: Wait for all TrackObject-s to be in Tracks before seeking



commit d28eeb363d02cc61dcad4fb252d3aec91724a1e9
Author: Thibault Saunier <thibault saunier collabora com>
Date:   Wed May 16 21:51:41 2012 -0400

    medialibrary: Wait for all TrackObject-s to be in Tracks before seeking
    
    We currently need to work around the fact that TrackObject-s are created
    async and first added to the TimelineObject-s before the tracks. So we
    need to wait the TrackObject to be in the tracks before the timeline duration
    is updated, and the composition actually contains the gnlobject for the clips we
    are adding to the timeline.

 pitivi/medialibrary.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index d75fc3a..e66ac01 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -27,6 +27,7 @@ Handles the list of source for a project
 import gst
 import ges
 import gobject
+import glib
 import gtk
 import pango
 import os
@@ -581,10 +582,10 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
         timeline = self.app.current.timeline
 
         if not self._sources_to_insert:
-            # OK, we added all the sources!
-            if timeline.props.duration <= 0:
-                self.error("The timeline duration is still 0, which makes no sense")
-            self.app.current.seeker.seek(timeline.props.duration)
+            # We need to wait (100ms is enoug for sure) for TrackObject-s to
+            # be added to the Tracks
+            # FIXME remove this "hack" when Materials are merged
+            glib.timeout_add(100, self._seekToEnd)
             self.app.action_log.commit()
             return
 
@@ -598,6 +599,11 @@ class MediaLibraryWidget(gtk.VBox, Loggable):
         # adding several sources at a time.
         source.connect("track-object-added", self._trackObjectAddedCb)
 
+    def _seekToEnd(self):
+        timeline = self.app.current.timeline
+        self.app.current.seeker.seek(timeline.props.duration)
+        return False
+
     def _trackObjectAddedCb(self, source, trackobj):
         """ After an object has been added to the first track, position it
         correctly and request the next source to be processed. """



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