Commit f218843f authored by Alexandru Băluț's avatar Alexandru Băluț

timeline: Call setProject only from EditorPerspective

setProject(None) was being called by EditorPerspective when the project
was being closed. For consistency, now the EditorPerspective is also
responsible for calling it when a new project has been loaded, instead
of detecting that on its own.
parent 9a17bd10
......@@ -438,7 +438,7 @@ class EditorPerspective(Perspective, Loggable):
# Project management callbacks
def _projectManagerNewProjectLoadedCb(self, project_manager, project):
"""Starts connecting the UI to the specified project.
"""Connects the UI to the specified project.
Args:
project_manager (ProjectManager): The project manager.
......@@ -448,7 +448,15 @@ class EditorPerspective(Perspective, Loggable):
self._connectToProject(project)
project.pipeline.activatePositionListener()
self._setProject(project)
self.clipconfig.project = project
self.timeline_ui.setProject(project)
# When creating a blank project there's no project URI yet.
if project.uri:
folder_path = os.path.dirname(path_from_uri(project.uri))
self.settings.lastProjectFolder = folder_path
self.updateTitle()
......@@ -619,23 +627,6 @@ class EditorPerspective(Perspective, Loggable):
project.ges_timeline.connect("notify::duration",
self._timelineDurationChangedCb)
def _setProject(self, project):
"""Disconnects and then reconnects callbacks to the specified project.
Args:
project (Project): The new current project.
"""
if not project:
self.warning("Current project instance does not exist")
return False
self.clipconfig.project = project
# When creating a blank project there's no project URI yet.
if project.uri:
folder_path = os.path.dirname(path_from_uri(project.uri))
self.settings.lastProjectFolder = folder_path
def _disconnectFromProject(self, project):
project.disconnect_by_func(self._projectChangedCb)
project.ges_timeline.disconnect_by_func(self._timelineDurationChangedCb)
......
......@@ -1416,8 +1416,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self._createUi()
self._createActions()
self.app.project_manager.connect("new-project-loaded",
self._projectLoadedCb)
self.timeline.connect("size-allocate", self.__timeline_size_allocate_cb)
# Public API
......@@ -1529,15 +1527,37 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self._scrollToPixel(x)
def setProject(self, project):
self._project = project
"""Connects to the project's timeline and pipeline."""
if self._project:
self._project.connect("rendering-settings-changed",
self._rendering_settings_changed_cb)
self._project.disconnect_by_func(self._rendering_settings_changed_cb)
try:
self.timeline._pipeline.disconnect_by_func(
self.timeline.positionCb)
except AttributeError:
pass
except TypeError:
pass # We were not connected no problem
self.timeline._pipeline = None
self._project = project
if project:
project.connect("rendering-settings-changed",
self._rendering_settings_changed_cb)
self.ges_timeline = project.ges_timeline
else:
self.ges_timeline = None
self.timeline.setProject(self._project)
self.timeline.setProject(project)
if project:
self.ruler.setPipeline(project.pipeline)
self.ruler.zoomChanged()
self._update_ruler(project.videorate)
self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
self.timeline.update_snapping_distance()
def updateActions(self):
selection = self.timeline.selection
......@@ -2022,29 +2042,6 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
fits = self.timeline.layout.props.height <= allocation.height
self.vscrollbar.set_opacity(0 if fits else 1)
def _projectLoadedCb(self, unused_project_manager, project):
"""Connects to the project's timeline and pipeline."""
if self._project:
self._project.disconnect_by_func(self._rendering_settings_changed_cb)
try:
self.timeline._pipeline.disconnect_by_func(
self.timeline.positionCb)
except AttributeError:
pass
except TypeError:
pass # We were not connected no problem
self.timeline._pipeline = None
self.setProject(project)
if project:
self.ruler.setPipeline(project.pipeline)
self.ruler.zoomChanged()
self._update_ruler(project.videorate)
self.timeline.set_best_zoom_ratio(allow_zoom_in=True)
self.timeline.update_snapping_distance()
def _zoom_in_cb(self, unused_action, unused_parameter):
Zoomable.zoomIn()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment