[pitivi/ges: 98/287] Initial fix for the "Insert at End of Timeline" feature with GES



commit 06fe5214073dace337f4d7851f617696c1b37b96
Author: Jean-FranÃois Fortin Tam <nekohayo gmail com>
Date:   Mon Dec 19 13:26:37 2011 -0500

    Initial fix for the "Insert at End of Timeline" feature with GES
    
    Also rename sourcelist's "getUri" method to "getInfoFromUri"

 pitivi/sourcelist.py      |    2 +-
 pitivi/ui/mainwindow.py   |    2 +-
 pitivi/ui/sourcelist.py   |   18 ++++++++++++------
 pitivi/ui/timeline.py     |    3 ++-
 tests/test_integration.py |    2 +-
 5 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/pitivi/sourcelist.py b/pitivi/sourcelist.py
index f82a98a..0d499ec 100644
--- a/pitivi/sourcelist.py
+++ b/pitivi/sourcelist.py
@@ -129,7 +129,7 @@ class SourceList(Signallable, Loggable):
             for obj in layer.get_objects():
                 self.addUri(obj.get_uri())
 
-    def getUri(self, uri):
+    def getInfoFromUri(self, uri):
         """
         Get the source corresponding to C{uri}.
         """
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index 5c98a20..0111f68 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -1065,7 +1065,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
 
         # Use factory from our source list if we have the given uri
         try:
-            fact = self.project.sources.getUri(uri)
+            fact = self.project.sources.getInfoFromUri(uri)
         except SourceListError:
             from pitivi.factories.file import FileSourceFactory
             fact = FileSourceFactory(uri)
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index 32a91a8..f163b17 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -26,6 +26,8 @@ import pango
 import os
 import time
 
+from ges import TimelineFileSource
+
 from urllib import unquote
 from gettext import gettext as _
 
@@ -390,15 +392,19 @@ class SourceList(gtk.VBox, Loggable):
 
     def _insertEndCb(self, unused_action):
         self.app.action_log.begin("add clip")
-        timeline = self.app.current.timeline
+        GEStimeline = self.app.current.timeline
+        ptvtimeline = self.app.gui.timeline
+        ptvtimeline._ensureLayer()  # Handle the case of a blank project
         sources = self.app.current.sources
-        start = timeline.duration
+        start = GEStimeline.props.duration
         self.app.current.seeker.seek(start)
+        layers = GEStimeline.get_layers()
         for uri in self.getSelectedItems():
-            factory = sources.getUri(uri)
-            source = timeline.addSourceFactory(factory)
-            source.setStart(start)
-            start += source.duration
+            source = TimelineFileSource(uri)
+            layer = layers[0]  # TODO: use the longest layer instead
+            layer.add_object(source)
+            source.props.start = start
+            start += source.props.duration
         self.app.action_log.commit()
 
     def searchEntryChangedCb(self, entry):
diff --git a/pitivi/ui/timeline.py b/pitivi/ui/timeline.py
index 06ea508..430a57a 100644
--- a/pitivi/ui/timeline.py
+++ b/pitivi/ui/timeline.py
@@ -513,7 +513,8 @@ class Timeline(gtk.Table, Loggable, Zoomable):
 
         if targetType == dnd.TYPE_PITIVI_FILESOURCE:
             uris = selection.data.split("\n")
-            self._factories = [self._project.sources.getUri(uri) for uri in uris]
+            self._factories = \
+                [self._project.sources.getInfoFromUri(uri) for uri in uris]
         else:
             if not self._duration:
                 return False
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 63e9f78..af5aa85 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -280,7 +280,7 @@ class InstanceRunner(Signallable):
 
     def _setupTimeline(self, configuration):
         for name, uri, props in configuration:
-            factory = self.project.sources.getUri(uri)
+            factory = self.project.sources.getInfoFromUri(uri)
             if not factory:
                 raise Exception("Could not find '%s' in sourcelist" %
                     source)



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