[pitivi] Show a dialog if a project is being closed and there are unsaved changes.



commit 3b9a5330597daa7db5cafe356808e396981d1deb
Author: Alessandro Decina <alessandro d gmail com>
Date:   Fri Jun 12 16:33:01 2009 +0200

    Show a dialog if a project is being closed and there are unsaved changes.

 pitivi/projectmanager.py     |    4 ----
 pitivi/ui/mainwindow.py      |    1 +
 tests/test_projectmanager.py |   18 +++++++++---------
 3 files changed, 10 insertions(+), 13 deletions(-)
---
diff --git a/pitivi/projectmanager.py b/pitivi/projectmanager.py
index af568ae..b9673c7 100644
--- a/pitivi/projectmanager.py
+++ b/pitivi/projectmanager.py
@@ -116,10 +116,6 @@ class ProjectManager(Signallable, Loggable):
         if self.current is None:
             return True
 
-        if self.current.hasUnsavedModifications():
-            if not self.saveProject(self.current):
-                return False
-
         if self.emit("closing-project", self.current) == False:
             return False
 
diff --git a/pitivi/ui/mainwindow.py b/pitivi/ui/mainwindow.py
index d3b0d56..e0256f6 100644
--- a/pitivi/ui/mainwindow.py
+++ b/pitivi/ui/mainwindow.py
@@ -779,6 +779,7 @@ class PitiviMainWindow(gtk.Window, Loggable):
         dirty = action_log.dirty()
         save_action = self.actiongroup.get_action("SaveProject")
         save_action.set_sensitive(dirty)
+        self.app.current.setModificationState(dirty)
 
         redo_action = self.actiongroup.get_action("Redo")
         can_redo = bool(action_log.redo_stacks)
diff --git a/tests/test_projectmanager.py b/tests/test_projectmanager.py
index 865180c..bc044aa 100644
--- a/tests/test_projectmanager.py
+++ b/tests/test_projectmanager.py
@@ -219,12 +219,6 @@ class TestProjectManager(TestCase):
         self.failUnless(self.manager.closeRunningProject())
         self.failIf(self.signals)
 
-    def testCloseRunningProjectCantSaveModifications(self):
-        self.manager.current = MockProject()
-        self.manager.current.save = lambda: False
-        self.failIf(self.manager.closeRunningProject())
-        self.failIf(self.signals)
-
     def testCloseRunningProjectRefuseFromSignal(self):
         def closing(manager, project):
             return False
@@ -260,11 +254,17 @@ class TestProjectManager(TestCase):
         self.failUnlessEqual(self.manager.current, None)
 
     def testNewBlankProjectCantCloseCurrent(self):
-        current = self.manager.current = MockProject()
-        current.save = lambda: False
+        def closing(manager, project):
+            return False
 
+        self.manager.current = MockProject()
+        self.manager.current.has_mods = False
+        self.manager.current.uri = "file:///ciao"
+        self.manager.connect("closing-project", closing)
         self.failIf(self.manager.newBlankProject())
-        self.failIf(self.signals)
+        self.failUnlessEqual(len(self.signals), 1)
+        signal, args = self.signals[0]
+        self.failUnlessEqual(signal, "closing-project")
 
     def testNewBlankProject(self):
         self.failUnless(self.manager.newBlankProject())



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]