pitivi r1374 - in trunk/pitivi: timeline ui



Author: edwardrv
Date: Fri Nov 28 17:04:11 2008
New Revision: 1374
URL: http://svn.gnome.org/viewvc/pitivi?rev=1374&view=rev

Log:
moved TimelineObject instantiation from pitivi.ui.timeline.Timeline to pitivi.timeline.timeline.Timeline

Modified:
   trunk/pitivi/timeline/timeline.py
   trunk/pitivi/ui/timeline.py

Modified: trunk/pitivi/timeline/timeline.py
==============================================================================
--- trunk/pitivi/timeline/timeline.py	(original)
+++ trunk/pitivi/timeline/timeline.py	Fri Nov 28 17:04:11 2008
@@ -28,7 +28,7 @@
 from pitivi.settings import ExportSettings
 from composition import TimelineComposition
 from objects import MEDIA_TYPE_AUDIO, MEDIA_TYPE_VIDEO
-from source import TimelineBlankSource
+from source import TimelineBlankSource, TimelineFileSource
 from pitivi.serializable import Serializable
 
 class Timeline(Serializable):
@@ -78,6 +78,37 @@
         self.audiocomp.gnlobject.connect("pad-removed", self._removedAudioPadCb)
         self.videocomp.gnlobject.connect("pad-removed", self._removedVideoPadCb)
 
+    def addFactory(self, factory, time=gst.CLOCK_TIME_NONE, shift=False):
+        """Add a factory to the timeline using the the specified time as the
+        start time. If shift is true, then move overlapping sources out of the
+        way."""
+
+        if not factory:
+            return
+
+        #FIXME: need simple, generic, createFromFactory() type thing so we
+        # have to care about all of this...
+        if factory.is_video:
+            video_source = TimelineFileSource(factory=factory,
+                media_type=MEDIA_TYPE_VIDEO,
+                name=factory.name)
+            # WARNING: this won't actually catch the linked source, so if the
+            # source is ever unlinked its edges will not be seen. On the other
+            # hand, this won't matter once we switch to the parent-child
+            # model.
+            #self.register_instance(video_source)
+            # TODO: insert source in proper location
+            self.videocomp.appendSource(video_source)
+        # must be elif because of auto-linking, this just catches case where
+        # factory is only audio
+        elif factory.is_audio:
+            audio_source = TimelineFileSource(factory=factory,
+                media_type=MEDIA_TYPE_VIDEO,
+                name=factory.name)
+            #self.register_instance(audio_source)
+            # TODO: insert source in proper location
+            self.audiocomp.appendSource(audio_source)
+
     def _newAudioPadCb(self, unused_audiocomp, pad):
         asrc = gst.GhostPad("asrc", pad)
         asrc.set_active(True)
@@ -117,7 +148,6 @@
         return max(self.audiocomp.duration, self.videocomp.duration)
 
     # Serializable methods
-
     def toDataFormat(self):
         ret = Serializable.toDataFormat(self)
         ret["compositions"] = dict((\

Modified: trunk/pitivi/ui/timeline.py
==============================================================================
--- trunk/pitivi/ui/timeline.py	(original)
+++ trunk/pitivi/ui/timeline.py	Fri Nov 28 17:04:11 2008
@@ -71,31 +71,6 @@
         self.hscroll.emit("scroll-event", event)
 
 ## Drag and Drop callbacks
-
-    def _gotFileFactory(self, filefactory, x, y):
-        """ got a filefactory at the given position """
-        # remove the slot
-        if not filefactory or not filefactory.is_video:
-            return
-        #pos_ = self.items.point_to_index(pixel_coords(self, (x, y)))
-        pos_ = 0
-        gst.debug("_got_filefactory pos : %d" % pos_)
-        # we just add it here, the drawing will be done in the condensed_list
-        # callback
-        source = TimelineFileSource(factory=filefactory,
-            media_type=MEDIA_TYPE_VIDEO,
-            name=filefactory.name)
-
-        # FIXME: access of instance.PiTiVi
-        timeline = instance.PiTiVi.current.timeline
-        if pos_ == -1:
-            timeline.videocomp.appendSource(source)
-        elif pos_:
-            timeline.videocomp.insertSourceAfter(source,
-                self.condensed[pos_ - 1])
-        else:
-            timeline.videocomp.prependSource(source)
-
     def _dragMotionCb(self, unused_layout, unused_context, x, y, timestamp):
 
         # FIXME: temporarily add source to timeline, and put it in drag mode
@@ -116,9 +91,8 @@
             uri = selection.data
         else:
             context.finish(False, False, timestamp)
-        self._gotFileFactory(instance.PiTiVi.current.sources[uri], x, y)
-        context.finish(True, False, timestamp)
         # FIXME: access of instance, and playground
+        factory = instance.PiTiVi.current.sources[uri]
+        instance.PiTiVi.current.timeline.addFactory(factory)
+        context.finish(True, False, timestamp)
         instance.PiTiVi.playground.switchToTimeline()
-
-



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