[pitivi] medialibrary: Connect to new project before it starts loading
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] medialibrary: Connect to new project before it starts loading
- Date: Sun, 20 Mar 2016 23:58:44 +0000 (UTC)
commit ec66845b69f04d4c4a2ff7b3eac3cd5e290a0a8a
Author: Thibault Saunier <tsaunier gnome org>
Date: Mon Feb 15 22:35:03 2016 +0100
medialibrary: Connect to new project before it starts loading
Otherwise in the case where a project can be loaded synchronously
(because we are re using already loaded assets) the media library
would not be notified of the asset from the new project.
Differential Revision: https://phabricator.freedesktop.org/D780
pitivi/application.py | 4 ++--
pitivi/mainwindow.py | 3 ++-
pitivi/medialibrary.py | 6 +++---
pitivi/project.py | 8 ++++----
tests/test_project.py | 9 ++++-----
5 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index d764ff2..3080f22 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -261,8 +261,8 @@ class Pitivi(Gtk.Application, Loggable):
self.write_action("load-project",
{"serialized-content": content})
- def _newProjectLoadingCb(self, unused_project_manager, uri):
- self._setScenarioFile(uri)
+ def _newProjectLoadingCb(self, unused_project_manager, project):
+ self._setScenarioFile(project.get_uri())
def _newProjectLoaded(self, unused_project_manager, project):
self.action_log.clean()
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 86e1cd9..2675b94 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -728,7 +728,8 @@ class PitiviMainWindow(Gtk.ApplicationWindow, Loggable):
if project.timeline.props.duration != 0:
self.render_button.set_sensitive(True)
- def _projectManagerNewProjectLoadingCb(self, unused_project_manager, uri):
+ def _projectManagerNewProjectLoadingCb(self, unused_project_manager, project):
+ uri = project.get_uri()
if uri:
self.recent_manager.add_item(uri)
self.log("A NEW project is loading, deactivate UI")
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index a6866db..c655950 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -399,7 +399,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
# changing project.
project_manager = self.app.project_manager
project_manager.connect(
- "new-project-created", self._newProjectCreatedCb)
+ "new-project-loading", self._new_project_loading_cb)
project_manager.connect("new-project-loaded", self._newProjectLoadedCb)
project_manager.connect("new-project-failed", self._newProjectFailedCb)
project_manager.connect("project-closed", self._projectClosedCb)
@@ -451,7 +451,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
def finalize(self):
self.debug("Finalizing %s", self)
- self.app.project_manager.disconnect_by_func(self._newProjectCreatedCb)
+ self.app.project_manager.disconnect_by_func(self._new_project_loading_cb)
self.app.project_manager.disconnect_by_func(self._newProjectLoadedCb)
self.app.project_manager.disconnect_by_func(self._newProjectFailedCb)
self.app.project_manager.disconnect_by_func(self._projectClosedCb)
@@ -1406,7 +1406,7 @@ class MediaLibraryWidget(Gtk.Box, Loggable):
self._project.disconnect_by_func(self._errorCreatingAssetCb)
self._project.disconnect_by_func(self.__projectSettingsSetFromImportedAssetCb)
- def _newProjectCreatedCb(self, unused_project_manager, project):
+ def _new_project_loading_cb(self, unused_project_manager, project):
assert (not self._project)
self._project = project
diff --git a/pitivi/project.py b/pitivi/project.py
index 78caa35..4f7f275 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -170,7 +170,7 @@ class ProjectManager(GObject.Object, Loggable):
"""
__gsignals__ = {
- "new-project-loading": (GObject.SIGNAL_RUN_LAST, None, (str,)),
+ "new-project-loading": (GObject.SIGNAL_RUN_LAST, None, (object,)),
"new-project-created": (GObject.SIGNAL_RUN_LAST, None, (object,)),
"new-project-failed": (GObject.SIGNAL_RUN_LAST, None, (str, str)),
"new-project-loaded": (GObject.SIGNAL_RUN_LAST, None, (object,)),
@@ -307,7 +307,6 @@ class ProjectManager(GObject.Object, Loggable):
return False
self.__missing_uris = False
- self.emit("new-project-loading", uri)
is_validate_scenario = self._isValidateScenario(uri)
if not is_validate_scenario:
@@ -319,6 +318,7 @@ class ProjectManager(GObject.Object, Loggable):
# Load the project:
project = Project(self.app, uri=uri, scenario=scenario)
+ self.emit("new-project-loading", project)
project.connect_after("missing-uri", self._missingURICb)
project.connect("loaded", self._projectLoadedCb)
@@ -331,7 +331,7 @@ class ProjectManager(GObject.Object, Loggable):
return False
self.current_project = project
- self.emit("new-project-created", self.current_project)
+ self.emit("new-project-created", project)
self.current_project.connect("project-changed", self._projectChangedCb)
self.current_project.pipeline.connect("died", self._projectPipelineDiedCb)
@@ -595,8 +595,8 @@ class ProjectManager(GObject.Object, Loggable):
return False
self.__missing_uris = False
- self.emit("new-project-loading", None)
project = Project(self.app, name=DEFAULT_NAME)
+ self.emit("new-project-loading", project)
# setting default values for project metadata
project.author = pwd.getpwuid(os.getuid()).pw_gecos.split(",")[0]
diff --git a/tests/test_project.py b/tests/test_project.py
index d2be228..d447ab7 100644
--- a/tests/test_project.py
+++ b/tests/test_project.py
@@ -106,7 +106,7 @@ class TestProjectManager(TestCase):
# loading
name, args = self.signals[0]
- self.assertEqual(uri, args[0], self.signals)
+ self.assertEqual(uri, args[0].get_uri(), self.signals)
# failed
name, args = self.signals[1]
@@ -150,7 +150,6 @@ class TestProjectManager(TestCase):
mainloop.quit()
def missingUriCb(self, project, error, clip_asset, mainloop, result):
- print(project, error, clip_asset, mainloop, result)
result[0] = True
mainloop.quit()
@@ -240,13 +239,13 @@ class TestProjectManager(TestCase):
name, args = self.signals[0]
self.assertEqual("new-project-loading", name)
- uri = args[0]
- self.assertTrue(uri is None)
+ project = args[0]
+ self.assertTrue(project.get_uri() is None)
name, args = self.signals[1]
self.assertEqual("new-project-created", name)
project = args[0]
- self.assertEqual(uri, project.uri)
+ self.assertEqual(project.get_uri(), project.uri)
name, args = self.signals[2]
self.assertEqual("new-project-loaded", name)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]