[pitivi] timeline: Combine the setting of the timeline and of the project



commit 40cd336c9a78507c98543b7643fa697e5ba006b7
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Mon Jan 13 13:10:54 2014 +0100

    timeline: Combine the setting of the timeline and of the project

 pitivi/mainwindow.py        |    2 +-
 pitivi/project.py           |    2 +-
 pitivi/timeline/timeline.py |   34 +++++++++++++++++++---------------
 3 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index ee90f63..6327eb9 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -929,7 +929,7 @@ class PitiviMainWindow(Gtk.Window, Loggable):
 
         self.info("Project closed - clearing the media library and timeline")
         self.medialibrary.storemodel.clear()
-        self.timeline_ui.setTimeline(None)
+        self.timeline_ui.setProject(None)
         self.clipconfig.timeline = None
         return False
 
diff --git a/pitivi/project.py b/pitivi/project.py
index 19079bd..bf59c0d 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -422,8 +422,8 @@ class ProjectManager(Signallable, Loggable):
         project.author = getpwuid(os.getuid()).pw_gecos.split(",")[0]
 
         project.createTimeline()
-        self.emit("new-project-created", project)
         self.current_project = project
+        self.emit("new-project-created", project)
 
         project.connect("project-changed", self._projectChangedCb)
         self.emit("new-project-loaded", self.current_project, emission)
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index e4c5d94..bd002fe 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -132,14 +132,16 @@ class TimelineStage(Clutter.ScrollActor, Zoomable):
     # Public API
 
     def setProject(self, project):
-        self._project = project
-        self._project.pipeline.connect('position', self._positionCb)
-
-    def setTimeline(self, bTimeline):
         """
-        @param bTimeline : the backend GES.Timeline which we interface.
-        Does all the necessary connections.
+        Connects with the GES.Timeline holding the project.
         """
+        self._project = project
+        if self._project:
+            self._project.pipeline.connect('position', self._positionCb)
+            bTimeline = self._project.timeline
+        else:
+            bTimeline = None
+
         if self.bTimeline is not None:
             self.bTimeline.disconnect_by_func(self._trackAddedCb)
             self.bTimeline.disconnect_by_func(self._trackRemovedCb)
@@ -775,10 +777,17 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         self.pressed = True
         self._seeker.seek(position)
 
-    def setTimeline(self, bTimeline):
-        self.bTimeline = bTimeline
+    def setProject(self, project):
+        self._project = project
+        if self._project:
+            self._project.connect("rendering-settings-changed",
+                                  self._renderingSettingsChangedCb)
+            self.bTimeline = project.timeline
+        else:
+            self.bTimeline = None
+
+        self.timeline.setProject(self._project)
         self.timeline.selection.connect("selection-changed", self._selectionChangedCb)
-        self.timeline.setTimeline(bTimeline)
 
     def getEditionMode(self, isAHandle=False):
         if self._shiftMask or self._autoripple_active:
@@ -1373,7 +1382,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
         assert self._project is project
         if self._project:
             self._seeker = self._project.seeker
-            self.timeline.setProject(self._project)
             self.ruler.setPipeline(self._project.pipeline)
 
             self.ruler.setProjectFrameRate(self._project.videorate)
@@ -1398,11 +1406,7 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
             self.timeline._pipeline = None
             self._seeker = None
 
-        self._project = project
-        if self._project:
-            self._project.connect("rendering-settings-changed",
-                                  self._renderingSettingsChangedCb)
-            self.setTimeline(project.timeline)
+        self.setProject(project)
 
     def _zoomInCb(self, unused_action):
         Zoomable.zoomIn()


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