[pitivi/ges: 108/287] ui/sourcelist: clarify _addNextSource and _trackObjectAddedCb



commit 38fd53478c33b4757c18534f5fa41a73a8014a72
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Tue Dec 20 12:17:23 2011 -0500

    ui/sourcelist: clarify _addNextSource and _trackObjectAddedCb

 pitivi/ui/sourcelist.py |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index 33f9d3c..29c6bd7 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -400,10 +400,11 @@ class SourceList(gtk.VBox, Loggable):
         self.app.gui.timeline._ensureLayer()
 
         self._sources_to_add = self.getSelectedItems()
-        #Start adding sources in the timeline
+        # Start adding sources in the timeline
         self._addNextSource()
 
     def _addNextSource(self):
+        """ Insert a source at the end of the timeline's first track """
         timeline = self.app.current.timeline
 
         if not self._sources_to_add:
@@ -411,12 +412,11 @@ class SourceList(gtk.VBox, Loggable):
             timeline.enable_update(True)
             self.app.current.seeker.seek(timeline.props.duration)
             self.app.action_log.commit()
-
             return
 
         uri = self._sources_to_add.pop()
         source = TimelineFileSource(uri)
-        layer = timeline.get_layers()[0]
+        layer = timeline.get_layers()[0]  # FIXME Get the longest layer
         layer.add_object(source)
 
         # Waiting for the TrackObject to be created because of a race
@@ -425,19 +425,20 @@ class SourceList(gtk.VBox, Loggable):
         source.connect("track-object-added", self._trackObjectAddedCb)
 
     def _trackObjectAddedCb(self, source, trackobj):
-        #FIXME Get the longest layer
+        """ After an object has been added to the first track, position it
+        correctly and request the next source to be processed. """
         timeline = self.app.current.timeline
-        start = timeline.props.duration
+        layer = timeline.get_layers()[0]  # FIXME Get the longest layer
 
-        #Handle the case where are adding the first source
-        if len(timeline.get_layers()[0].get_objects()) == 1:
+        # Handle the case where we just inserted the first clip
+        if len(layer.get_objects()) == 1:
             source.props.start = 0
         else:
-            source.props.start = start
+            source.props.start = timeline.props.duration
 
-        # Getting only one TrackObject is enough
+        # We only need one TrackObject to estimate the new duration.
+        # Process the next source.
         source.disconnect_by_func(self._trackObjectAddedCb)
-
         self._addNextSource()
 
     def searchEntryChangedCb(self, entry):



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