[pitivi] viewer: Fix viewer ratio lost when docking/undocking
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] viewer: Fix viewer ratio lost when docking/undocking
- Date: Fri, 25 Jan 2019 21:36:37 +0000 (UTC)
commit dea38fda0ab38e99ce4534c0c22b45e93121b0a4
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Tue Jan 15 03:10:49 2019 +0100
viewer: Fix viewer ratio lost when docking/undocking
Now ViewerContainer has direct access the project, without having to go
through `self.app.project_manager`.
This moves some functionality from the EditorPerspective, making it more
clear that the ViewerContainer is tightly integrated with the current
project.
pitivi/editorperspective.py | 14 --------------
pitivi/viewer/viewer.py | 26 ++++++++++++++++++++++++++
2 files changed, 26 insertions(+), 14 deletions(-)
---
diff --git a/pitivi/editorperspective.py b/pitivi/editorperspective.py
index a92748fe..1d7850f2 100644
--- a/pitivi/editorperspective.py
+++ b/pitivi/editorperspective.py
@@ -644,8 +644,6 @@ class EditorPerspective(Perspective, Loggable):
def _connectToProject(self, project):
project.connect("project-changed", self._projectChangedCb)
- project.connect("rendering-settings-changed",
- self._rendering_settings_changed_cb)
project.ges_timeline.connect("notify::duration",
self._timelineDurationChangedCb)
@@ -659,8 +657,6 @@ class EditorPerspective(Perspective, Loggable):
self.warning("Current project instance does not exist")
return False
- self.viewer.setPipeline(project.pipeline)
- self._reset_viewer_aspect_ratio(project)
self.clipconfig.project = project
# When creating a blank project there's no project URI yet.
@@ -670,18 +666,8 @@ class EditorPerspective(Perspective, Loggable):
def _disconnectFromProject(self, project):
project.disconnect_by_func(self._projectChangedCb)
- project.disconnect_by_func(self._rendering_settings_changed_cb)
project.ges_timeline.disconnect_by_func(self._timelineDurationChangedCb)
- def _rendering_settings_changed_cb(self, project, unused_item):
- """Handles Project metadata changes."""
- self._reset_viewer_aspect_ratio(project)
-
- def _reset_viewer_aspect_ratio(self, project):
- """Resets the viewer aspect ratio."""
- self.viewer.target.update_aspect_ratio(project)
- self.viewer.timecode_entry.setFramerate(project.videorate)
-
def _timelineDurationChangedCb(self, timeline, unused_duration):
"""Updates the render button.
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index e0111ce5..aa727bef 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -84,6 +84,7 @@ class ViewerContainer(Gtk.Box, Loggable):
Loggable.__init__(self)
self.log("New ViewerContainer")
+ self.project = None
self.pipeline = None
self.docked = True
self.target = None
@@ -104,6 +105,30 @@ class ViewerContainer(Gtk.Box, Loggable):
self.__cursor = None
self.__translation = None
+ pm = self.app.project_manager
+ pm.connect("new-project-loaded", self._project_manager_new_project_loaded_cb)
+ pm.connect("project-closed", self._projectManagerProjectClosedCb)
+
+ def _project_manager_new_project_loaded_cb(self, unused_project_manager, project):
+ project.connect("rendering-settings-changed",
+ self._project_rendering_settings_changed_cb)
+ self.project = project
+ self.setPipeline(project.pipeline)
+
+ def _projectManagerProjectClosedCb(self, unused_project_manager, project):
+ if self.project == project:
+ project.disconnect_by_func(self._project_rendering_settings_changed_cb)
+ self.project = None
+
+ def _project_rendering_settings_changed_cb(self, project, unused_item):
+ """Handles Project metadata changes."""
+ self._reset_viewer_aspect_ratio(project)
+
+ def _reset_viewer_aspect_ratio(self, project):
+ """Resets the viewer aspect ratio."""
+ self.target.update_aspect_ratio(project)
+ self.timecode_entry.setFramerate(project.videorate)
+
def setPipeline(self, pipeline, position=None):
"""Sets the displayed pipeline.
@@ -139,6 +164,7 @@ class ViewerContainer(Gtk.Box, Loggable):
self.overlay_stack = OverlayStack(self.app, sink_widget)
self.target = ViewerWidget(self.overlay_stack)
+ self._reset_viewer_aspect_ratio(self.project)
if self.docked:
self.pack_start(self.target, expand=True, fill=True, padding=0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]