Commit 02a933d4 authored by Alexandru Băluț's avatar Alexandru Băluț

project: Change load method to return the project

parent aa5a2745
......@@ -219,7 +219,7 @@ class Pitivi(Gtk.Application, Loggable):
self.warning(
"Can open only one project file at a time. Ignoring the rest!")
project_file = giofiles[0]
self.project_manager.loadProject(quote_uri(project_file.get_uri()))
self.project_manager.load_project(quote_uri(project_file.get_uri()))
return True
def shutdown(self):
......
......@@ -312,7 +312,7 @@ class GreeterPerspective(Perspective):
uri = uris[0]
extension = os.path.splitext(uri)[1][1:]
if extension in self.__project_filter:
self.app.project_manager.loadProject(uri)
self.app.project_manager.load_project(uri)
def __new_project_cb(self, unused_action, unused_param):
self.app.project_manager.new_blank_project()
......@@ -323,7 +323,7 @@ class GreeterPerspective(Perspective):
uri = dialog.get_uri()
dialog.destroy()
if response == Gtk.ResponseType.OK:
self.app.project_manager.loadProject(uri)
self.app.project_manager.load_project(uri)
def __app_version_info_received_cb(self, app, unused_version_information):
"""Handles new version info."""
......@@ -360,7 +360,7 @@ class GreeterPerspective(Perspective):
if row.select_button.get_visible():
row.select_button.set_active(not row.select_button.get_active())
else:
self.app.project_manager.loadProject(row.uri)
self.app.project_manager.load_project(row.uri)
def __projects_button_press_cb(self, listbox, event):
if event.button == 3:
......
......@@ -232,7 +232,7 @@ class ProjectManager(GObject.Object, Loggable):
self.app.shutdown()
def loadProject(self, uri):
def load_project(self, uri):
"""Loads the specified URI as a project.
If a backup file exists, asks if it should be loaded instead, and if so,
......@@ -261,7 +261,7 @@ class ProjectManager(GObject.Object, Loggable):
_('This might be due to a bug or an unsupported project file format. '
'If you were trying to add a media file to your project, '
'use the "Import" button instead.'))
return False
return None
self.current_project = project
self.emit("new-project-created", project)
......@@ -271,7 +271,7 @@ class ProjectManager(GObject.Object, Loggable):
if is_validate_scenario:
self.current_project.setupValidateScenario()
return True
return project
def _restoreFromBackupDialog(self, time_diff):
"""Asks if we need to load the autosaved project backup.
......@@ -551,7 +551,7 @@ class ProjectManager(GObject.Object, Loggable):
uri = self.current_project.uri
self.current_project.setModificationState(False)
self.closeRunningProject()
self.loadProject(uri)
self.load_project(uri)
def _projectChangedCb(self, project):
# _backup_lock is a timer, when a change in the project is done it is
......
......@@ -99,7 +99,7 @@ class TestEditorPerspective(common.TestCase):
with common.cloned_sample():
asset_uri = common.get_sample_uri("missing.png")
with common.created_project_file(asset_uri) as uri:
app.project_manager.loadProject(uri)
app.project_manager.load_project(uri)
mainloop.run()
......
......@@ -63,7 +63,7 @@ class BaseTestMediaLibrary(common.TestCase):
self.medialibrary = medialibrary.MediaLibraryWidget(self.app)
if project_uri:
self.app.project_manager.loadProject(project_uri)
self.app.project_manager.load_project(project_uri)
else:
self.app.project_manager.new_blank_project()
......
......@@ -72,12 +72,9 @@ class TestProjectManager(common.TestCase):
self.signals = self.listener.signals
def testLoadProjectFailedUnknownFormat(self):
"""
Check that new-project-failed is emitted when we don't have a suitable
formatter.
"""
"""Checks new-project-failed is emitted for unsuitable formatters."""
uri = "file:///Untitled.meh"
self.manager.loadProject(uri)
self.manager.load_project(uri)
# loading
name, args = self.signals[0]
......@@ -115,7 +112,7 @@ class TestProjectManager(common.TestCase):
with common.cloned_sample():
asset_uri = common.get_sample_uri("missing.png")
with common.created_project_file(asset_uri) as uri:
self.assertTrue(self.manager.loadProject(uri))
self.assertIsNotNone(self.manager.load_project(uri))
mainloop.run()
self.assertTrue(result[0], "missing-uri has not been emitted")
......@@ -130,10 +127,10 @@ class TestProjectManager(common.TestCase):
with common.cloned_sample("flat_colour1_640x480.png"):
asset_uri = common.get_sample_uri("flat_colour1_640x480.png")
with common.created_project_file(asset_uri=asset_uri) as uri:
self.assertTrue(self.manager.loadProject(uri))
project = self.manager.load_project(uri)
self.assertIsNotNone(project)
mainloop.run()
project = self.manager.current_project
self.assertFalse(project.at_least_one_asset_missing)
self.assertTrue(project.loaded)
self.assertFalse(project.hasUnsavedModifications())
......@@ -380,7 +377,7 @@ class TestProjectLoading(common.TestCase):
project_manager.connect("closing-project", closing_project_cb)
proxy_manager.connect_after("proxy-ready", proxy_ready_cb)
app.project_manager.loadProject(proj_uri)
app.project_manager.load_project(proj_uri)
return mainloop, app, medialib, proxy_uri
def test_load_project_with_missing_proxy(self):
......@@ -480,7 +477,7 @@ class TestProjectLoading(common.TestCase):
project_manager.connect("missing-uri", missing_uri_cb)
project_manager.connect("new-project-loaded", new_project_loaded_cb)
project_manager.loadProject(proj_uri)
project_manager.load_project(proj_uri)
with common.cloned_sample("1sec_simpsons_trailer.mp4"):
mainloop.run()
self.assertEqual(medialib._progressbar.get_fraction(), 1.0)
......@@ -523,7 +520,7 @@ class TestProjectLoading(common.TestCase):
project_manager.connect("missing-uri", missing_uri_cb)
project_manager.connect("new-project-loaded", new_project_loaded_cb)
project_manager.loadProject(proj_uri)
project_manager.load_project(proj_uri)
mainloop.run()
self.assertEqual(len(missing_uris), 1,
"missing_uri_cb should be called only once, got %s." % missing_uris)
......
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