[pitivi] project: Allow blanking projects without prompting for unsaved changes
- From: Jean-François Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] project: Allow blanking projects without prompting for unsaved changes
- Date: Fri, 6 Sep 2013 00:14:51 +0000 (UTC)
commit 00072f8e003bc19e651b2df37036c382cb9b37fd
Author: Jean-François Fortin Tam <nekohayo gmail com>
Date: Thu Sep 5 00:32:22 2013 -0400
project: Allow blanking projects without prompting for unsaved changes
This prevents "unsaved changes" prompts from occurring in nonsensical situations
(ex: after a failed project load where the project file was invalid or partial).
pitivi/application.py | 4 ++--
pitivi/mainwindow.py | 2 +-
pitivi/project.py | 20 ++++++++++++++------
3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/pitivi/application.py b/pitivi/application.py
index 0507152..1ba4829 100644
--- a/pitivi/application.py
+++ b/pitivi/application.py
@@ -330,7 +330,7 @@ class ProjectCreatorGuiPitivi(GuiPitivi):
GuiPitivi.__init__(self, debug)
# load the passed filenames, optionally adding them to the timeline
# (useful during development)
- self.projectManager.newBlankProject(False)
+ self.projectManager.newBlankProject(emission=False)
uris = [quote_uri(os.path.abspath(media_filename))
for media_filename in media_filenames]
lib = self.current_project.medialibrary
@@ -389,7 +389,7 @@ class StartupWizardGuiPitivi(GuiPitivi):
def __init__(self, debug=False):
GuiPitivi.__init__(self, debug)
- self.projectManager.newBlankProject(False)
+ self.projectManager.newBlankProject(emission=False)
def _createGui(self):
# Prevent the main window to go fullscreen because at least
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index 13198d4..0cf7dd3 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -1124,7 +1124,7 @@ class PitiviMainWindow(Gtk.Window, Loggable):
# The chooser will be destroyed further below, so let's hide it now.
dialog.hide()
# Reset projectManager and disconnect all the signals:
- self.app.projectManager.newBlankProject()
+ self.app.projectManager.newBlankProject(ignore_unsaved_changes=True)
# Force the project load to fail:
# This will show an error using _projectManagerNewProjectFailedCb
# You have to do this *after* successfully creating a blank project,
diff --git a/pitivi/project.py b/pitivi/project.py
index d98e827..a13555c 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -178,7 +178,7 @@ class ProjectManager(Signallable, Loggable):
'If you were trying to add a media file to your project, '
'use the "Import" button instead.'))
# Reset projectManager and disconnect all the signals:
- self.newBlankProject()
+ self.newBlankProject(ignore_unsaved_changes=True)
return False
def _restoreFromBackupDialog(self, time_diff):
@@ -386,11 +386,19 @@ class ProjectManager(Signallable, Loggable):
return True
- def newBlankProject(self, emission=True):
- """ start up a new blank project """
- # This will prompt users about unsaved changes (if any):
- if self.current_project is not None and not self.closeRunningProject():
- return False # The user has not made a decision, don't do anything
+ def newBlankProject(self, emission=True, ignore_unsaved_changes=False):
+ """
+ Start up a new blank project.
+
+ The ignore_unsaved_changes parameter is used in special cases to force
+ the creation of a new project without prompting the user about unsaved
+ changes. This is an "extreme" way to reset Pitivi's state.
+ """
+ if self.current_project is not None:
+ # This will prompt users about unsaved changes (if any):
+ if not ignore_unsaved_changes and not self.closeRunningProject():
+ # The user has not made a decision, don't do anything
+ return False
if emission:
self.emit("new-project-loading", None)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]