[pitivi: 2/2] Implement playback from the sourcelist. Fixes #573



commit d0226c929d8400082a04956e3b9372f83295c270
Author: Alessandro Decina <alessandro decina collabora co uk>
Date:   Tue Mar 3 13:55:14 2009 +0100

    Implement playback from the sourcelist. Fixes #573887.
---
 pitivi/project.py        |    3 +++
 pitivi/ui/mainwindow.py  |   27 +++++++++++++++++----------
 pitivi/ui/projecttabs.py |    6 +++---
 pitivi/ui/sourcelist.py  |   10 ++++++++--
 4 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/pitivi/project.py b/pitivi/project.py
index a4be1a2..538428c 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -40,6 +40,7 @@ from pitivi.configure import APPNAME
 from pitivi.serializable import Serializable, to_object_from_data_type
 from pitivi.projectsaver import ProjectSaver, ProjectLoadError
 from pitivi.signalinterface import Signallable
+from pitivi.action import ViewAction
 
 class Project(Serializable, Signallable, Loggable):
     """ The base class for PiTiVi projects
@@ -111,6 +112,8 @@ class Project(Serializable, Signallable, Loggable):
 
         self.factory = TimelineSourceFactory(self.timeline)
         self.pipeline = Pipeline()
+        self.view_action = ViewAction()
+        self.view_action.addProducers(self.factory)
 
         # don't want to make calling load() necessary for blank projects
         if self.uri == None:
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index ea2503e..87437fb 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -298,6 +298,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
         hpaned = gtk.HPaned()
         vpaned.pack1(hpaned, resize=False, shrink=True)
         self.projecttabs = ProjectTabs()
+        self._connectToSourceList()
+
         hpaned.pack1(self.projecttabs, resize=True, shrink=False)
 
         self.timeline.ruler.connect('seek', self._timelineRulerSeekCb)
@@ -337,6 +339,12 @@ class PitiviMainWindow(gtk.Window, Loggable):
         self.set_icon_from_file(get_global_pixmap_dir()
             + "/pitivi.png")
 
+    def _connectToSourceList(self):
+        # FIXME: projecttabs creates the "components" but then has no API to get
+        # them back
+        sourcelist = self.projecttabs._full_list[0]
+        sourcelist.connect('play', self._sourceListPlayCb)
+
     def toggleFullScreen(self):
         """ Toggle the fullscreen mode of the application """
         if not self.is_fullscreen:
@@ -433,6 +441,9 @@ class PitiviMainWindow(gtk.Window, Loggable):
         if gtk.gdk.keyval_name(event.keyval) in ['f', 'F', 'F11']:
             self.toggleFullScreen()
 
+    def _sourceListPlayCb(self, sourcelist, factory):
+        self._viewFactory(factory)
+
 ## Toolbar/Menu actions callback
 
     def _newProjectMenuCb(self, unused_action):
@@ -659,20 +670,20 @@ class PitiviMainWindow(gtk.Window, Loggable):
             context.finish(False, False, ctime)
             return
 
-        # FIXME: we change the viewer pipeline unconditionally for now
-
         from pitivi.factories.file import FileSourceFactory
+        self._viewFactory(FileSourceFactory(uri))
+        context.finish(True, False, ctime)
+
+    def _viewFactory(self, factory):
+        # FIXME: we change the viewer pipeline unconditionally for now
         # we need a pipeline for playback
         pipeline = Pipeline()
-        factory = FileSourceFactory(uri)
         action = ViewAction()
         action.addProducers(factory)
         # FIXME: why do I have to call viewer.setAction ?
         self.viewer.setAction(action)
         self.viewer.setPipeline(pipeline)
-        pipeline.pause()
-
-        context.finish(True, False, ctime)
+        pipeline.play()
 
     def _timelineDragMotionCb(self, unused_layout, unused_context, x, y, timestamp):
         # FIXME: temporarily add source to timeline, and put it in drag mode
@@ -694,12 +705,8 @@ class PitiviMainWindow(gtk.Window, Loggable):
         self.app.current.timeline.addSourceFactory(factory)
         context.finish(True, False, timestamp)
 
-
     def _timelineRulerSeekCb(self, ruler, position):
         self.debug("position:%s", gst.TIME_ARGS (position))
-        if not hasattr(self.project, 'view_action'):
-            self.project.view_action = ViewAction()
-            self.project.view_action.addProducers(self.project.factory)
         self.viewer.setAction(self.project.view_action)
         self.viewer.setPipeline(self.project.pipeline)
         # everything above only needs to be done if the viewer isn't already
diff --git a/pitivi/ui/projecttabs.py b/pitivi/ui/projecttabs.py
index 4bfffb1..b4a49ff 100644
--- a/pitivi/ui/projecttabs.py
+++ b/pitivi/ui/projecttabs.py
@@ -72,7 +72,7 @@ class ProjectTabs(gtk.Notebook):
     def __init__(self):
         """ initialize """
         gtk.Notebook.__init__(self)
-        self.__full_list = []
+        self._full_list = []
         self.connect("switch-page", self.__switchPage)
         self._createUi()
 
@@ -84,7 +84,7 @@ class ProjectTabs(gtk.Notebook):
 
     def addComponent(self, component, label):
         self.append_page(component, DetachLabel(self, component, label))
-        self.__full_list.append(component)
+        self._full_list.append(component)
 
     def windowizeComponent(self, component, label):
         self.remove_page(self.page_num(component))
@@ -99,7 +99,7 @@ class ProjectTabs(gtk.Notebook):
     def __replaceComponent(self, window, component, label):
         window.remove(component)
         self.set_current_page(self.insert_page(component, label,
-            self.__full_list.index(component)))
+            self._full_list.index(component)))
         self.show()
 
     def __switchPage(self, unused_widget, unused_page, num):
diff --git a/pitivi/ui/sourcelist.py b/pitivi/ui/sourcelist.py
index e194e6f..d52c38a 100644
--- a/pitivi/ui/sourcelist.py
+++ b/pitivi/ui/sourcelist.py
@@ -112,6 +112,11 @@ def beautify_factory(factory):
 class SourceList(gtk.VBox, Loggable):
     """ Widget for listing sources """
 
+    __gsignals__ = {
+        'play': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
+                (gobject.TYPE_PYOBJECT,))
+        }
+
     def __init__(self):
         gtk.VBox.__init__(self)
         Loggable.__init__(self)
@@ -516,7 +521,7 @@ class SourceList(gtk.VBox, Loggable):
         path = paths[0]
         factory = model[path][COL_FACTORY]
         self.debug("Let's play %s", factory.name)
-        self.error("FIXME : IMPLEMENT PROPER TEMPORARY PLAYBACK USING PIPELINE/ACTION")
+        self.emit('play', factory)
 
     def _treeViewButtonPressEventCb(self, unused_treeview, event):
         if event.button == 3:
@@ -524,7 +529,7 @@ class SourceList(gtk.VBox, Loggable):
 
     def _rowActivatedCb(self, unused_treeview, path, unused_column):
         factory = self.storemodel[path][COL_FACTORY]
-        self.error("FIXME : IMPLEMENT PROPER TEMPORARY PLAYBACK USING PIPELINE/ACTION")
+        self.emit('play', factory)
 
     def _newProjectLoadedCb(self, unused_pitivi, project):
         # clear the storemodel
@@ -722,3 +727,4 @@ class InfoStub(gtk.HBox, Loggable):
         self.log("hiding")
         gtk.VBox.hide(self)
         self.showing = False
+gobject.type_register(SourceList)



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