Adding support for asking for saving while trying to close a modified project in any case
authorlaurent
Mon, 26 Oct 2009 11:20:16 +0100
changeset 429 1a5471e81a93
parent 428 ea09f33ce717
child 430 5981ad8547f5
child 432 ef7fc6fd1f6f
Adding support for asking for saving while trying to close a modified project in any case
Beremiz.py
i18n/Beremiz_fr_FR.po
i18n/messages.pot
locale/fr_FR/LC_MESSAGES/Beremiz.mo
--- a/Beremiz.py	Fri Oct 23 18:45:24 2009 +0200
+++ b/Beremiz.py	Mon Oct 26 11:20:16 2009 +0100
@@ -483,29 +483,29 @@
                 infos = self.PluginRoot.ShowError(self.Log,
                                                   (int(first_line), int(first_column)), 
                                                   (int(last_line), int(last_column)))
-		
+	
+    ## Function displaying an Error dialog in PLCOpenEditor.
+    #  @return False if closing cancelled.
+    def CheckSaveBeforeClosing(self, title=_("Close Project")):
+        if self.PluginRoot.ProjectTestModified():
+            dialog = wx.MessageDialog(self,
+                                      _("There are changes, do you want to save?"),
+                                      title,
+                                      wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
+            answer = dialog.ShowModal()
+            dialog.Destroy()
+            if answer == wx.ID_YES:
+                self.PluginRoot.SaveProject()
+            elif answer == wx.ID_CANCEL:
+                return False
+        return True
+    
     def OnCloseFrame(self, event):
-        if self.PluginRoot is not None:
-            if self.PluginRoot.ProjectTestModified():
-                dialog = wx.MessageDialog(self,
-                                          _("Save changes ?"),
-                                          _("Close Application"), 
-                                          wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
-                answer = dialog.ShowModal()
-                dialog.Destroy()
-                if answer == wx.ID_YES:
-                    self.PluginRoot.SaveProject()
-                    event.Skip()
-                elif answer == wx.ID_NO:
-                    event.Skip()
-                    return
-                else:
-                    event.Veto()
-                    return
-
-        self.KillLocalRuntime()
-        
-        event.Skip()
+        if self.PluginRoot is None or self.CheckSaveBeforeClosing(_("Close Application")):
+            self.KillLocalRuntime()
+            event.Skip()
+        else:
+            event.Veto()
     
     def OnMoveWindow(self, event):
         self.GetBestSize()
@@ -1300,6 +1300,9 @@
         self.DebugVariablePanel.SetDataProducer(None)
     
     def OnNewProjectMenu(self, event):
+        if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+            return
+        
         if not self.Config.HasEntry("lastopenedfolder"):
             defaultpath = os.path.expanduser("~")
         else:
@@ -1325,6 +1328,9 @@
             self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
     
     def OnOpenProjectMenu(self, event):
+        if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+            return
+        
         if not self.Config.HasEntry("lastopenedfolder"):
             defaultpath = os.path.expanduser("~")
         else:
@@ -1353,21 +1359,12 @@
         dialog.Destroy()
     
     def OnCloseProjectMenu(self, event):
-        if self.PluginRoot is not None:
-            if self.PluginRoot.ProjectTestModified():
-                dialog = wx.MessageDialog(self,
-                                          _("Save changes ?"),
-                                          _("Close Application"), 
-                                          wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
-                answer = dialog.ShowModal()
-                dialog.Destroy()
-                if answer == wx.ID_YES:
-                    self.PluginRoot.SaveProject()
-                elif answer == wx.ID_CANCEL:
-                    return
-            self.ResetView()
-            self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
-            self.RefreshAll()
+        if self.PluginRoot is not None and not self.CheckSaveBeforeClosing():
+            return
+        
+        self.ResetView()
+        self._Refresh(TITLE, TOOLBAR, FILEMENU, EDITMENU)
+        self.RefreshAll()
     
     def OnSaveProjectMenu(self, event):
         if self.PluginRoot is not None:
--- a/i18n/Beremiz_fr_FR.po	Fri Oct 23 18:45:24 2009 +0200
+++ b/i18n/Beremiz_fr_FR.po	Mon Oct 26 11:20:16 2009 +0100
@@ -7,15 +7,15 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-10-23 18:41+0200\n"
-"PO-Revision-Date: 2009-10-23 18:42+0100\n"
+"POT-Creation-Date: 2009-10-26 10:51+0100\n"
+"PO-Revision-Date: 2009-10-26 10:51+0100\n"
 "Last-Translator: \n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../Beremiz.py:1460
+#: ../Beremiz.py:1457
 #, python-format
 msgid ""
 "\n"
@@ -48,7 +48,7 @@
 msgid " generation failed !\n"
 msgstr ": la construction a échouée !\n"
 
-#: ../Beremiz.py:1351
+#: ../Beremiz.py:1357
 #, python-format
 msgid "\"%s\" folder is not a valid Beremiz project\n"
 msgstr "Le dossier \"%s\" ne contient pas de projet Beremiz valide\n"
@@ -57,13 +57,13 @@
 msgid "&Edit"
 msgstr "&Editer"
 
+#: ../Beremiz.py:1445
+#: ../Beremiz.py:1447
 #: ../Beremiz.py:1448
-#: ../Beremiz.py:1450
-#: ../Beremiz.py:1451
 msgid ",   "
 msgstr ",   "
 
-#: ../Beremiz.py:1446
+#: ../Beremiz.py:1443
 msgid ". "
 msgstr ". "
 
@@ -81,11 +81,11 @@
 msgid "About"
 msgstr "A propos"
 
-#: ../Beremiz.py:1395
+#: ../Beremiz.py:1392
 msgid "About Beremiz"
 msgstr "A propos de Beremiz"
 
-#: ../Beremiz.py:1418
+#: ../Beremiz.py:1415
 msgid "Add Plugin"
 msgstr "Ajouter un plugin"
 
@@ -205,8 +205,8 @@
 msgid "Choose a directory to save project"
 msgstr "Choisissez un dossier où enregistrer le projet"
 
-#: ../Beremiz.py:1308
-#: ../Beremiz.py:1333
+#: ../Beremiz.py:1311
+#: ../Beremiz.py:1339
 msgid "Choose a project"
 msgstr "Choisissez un projet"
 
@@ -234,12 +234,12 @@
 msgid "Cleaning the build directory\n"
 msgstr "Répertoire de compilation en cours de nettoyage\n"
 
-#: ../Beremiz.py:492
-#: ../Beremiz.py:1360
+#: ../Beremiz.py:504
 msgid "Close Application"
 msgstr "Fermer l'application"
 
 #: ../Beremiz.py:301
+#: ../Beremiz.py:489
 msgid "Close Project"
 msgstr "Fermer le projet"
 
@@ -393,8 +393,8 @@
 msgid "Enter the IP of the interface to bind"
 msgstr "Saisissez l'adresse IP de l'interface à lier"
 
-#: ../Beremiz.py:1474
-#: ../Beremiz.py:1484
+#: ../Beremiz.py:1471
+#: ../Beremiz.py:1481
 #: ../plugger.py:873
 #: ../Beremiz_service.py:268
 #: ../Beremiz_service.py:392
@@ -601,7 +601,7 @@
 msgid "Page Setup"
 msgstr "Mise en page..."
 
-#: ../Beremiz.py:1418
+#: ../Beremiz.py:1415
 msgid "Please enter a name for plugin:"
 msgstr "Saisissez un nom pour le plugin :"
 
@@ -659,7 +659,7 @@
 msgid "Raw IEC code"
 msgstr "Ajout code IEC"
 
-#: ../Beremiz.py:1428
+#: ../Beremiz.py:1425
 msgid "Really delete plugin ?"
 msgstr "Voulez-vous réellement supprimer le plugin ?"
 
@@ -675,7 +675,7 @@
 msgid "Refresh\tCTRL+R"
 msgstr "Actualiser\tCTRL+R"
 
-#: ../Beremiz.py:1428
+#: ../Beremiz.py:1425
 msgid "Remove plugin"
 msgstr "Enlever le plugin"
 
@@ -695,11 +695,6 @@
 msgid "Save as\tCTRL+SHIFT+S"
 msgstr "Enregistrer sous...\tCTRL+SHIFT+S"
 
-#: ../Beremiz.py:491
-#: ../Beremiz.py:1359
-msgid "Save changes ?"
-msgstr "Enregistrer les changements ?"
-
 #: ../discovery.py:81
 msgid "Services available:"
 msgstr "Services disponibles:"
@@ -766,6 +761,10 @@
 msgid "Stopping debug\n"
 msgstr "Arrêt du débogage en cours\n"
 
+#: ../Beremiz.py:492
+msgid "There are changes, do you want to save?"
+msgstr "Le projet a été modifié, voulez-vous l'enregistrer ?"
+
 #: ../Beremiz.py:374
 msgid "Topology"
 msgstr "Topologie"
@@ -875,16 +874,16 @@
 msgid "exited with status %s (pid %s)\n"
 msgstr "a quitté avec le status %s (pid %s)\n"
 
-#: ../Beremiz.py:1448
-#: ../Beremiz.py:1450
+#: ../Beremiz.py:1445
+#: ../Beremiz.py:1447
 msgid "file : "
 msgstr "fichier :"
 
-#: ../Beremiz.py:1451
+#: ../Beremiz.py:1448
 msgid "function : "
 msgstr "fonction :"
 
-#: ../Beremiz.py:1451
+#: ../Beremiz.py:1448
 msgid "line : "
 msgstr "ligne :"
 
@@ -979,6 +978,9 @@
 msgid "XenoConfig"
 msgstr "Config Xenomai"
 
+#~ msgid "Save changes ?"
+#~ msgstr "Enregistrer les changements ?"
+
 #, fuzzy
 #~ msgid "Conflict type for location \"%s\""
 #~ msgstr "Conflit entre types pour l'adresse \"%s\""
--- a/i18n/messages.pot	Fri Oct 23 18:45:24 2009 +0200
+++ b/i18n/messages.pot	Mon Oct 26 11:20:16 2009 +0100
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2009-10-23 18:41+0200\n"
+"POT-Creation-Date: 2009-10-26 10:51+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,7 +16,7 @@
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../Beremiz.py:1460
+#: ../Beremiz.py:1457
 #, python-format
 msgid ""
 "\n"
@@ -37,7 +37,7 @@
 msgid " generation failed !\n"
 msgstr ""
 
-#: ../Beremiz.py:1351
+#: ../Beremiz.py:1357
 #, python-format
 msgid "\"%s\" folder is not a valid Beremiz project\n"
 msgstr ""
@@ -46,11 +46,11 @@
 msgid "&Edit"
 msgstr ""
 
-#: ../Beremiz.py:1448 ../Beremiz.py:1450 ../Beremiz.py:1451
+#: ../Beremiz.py:1445 ../Beremiz.py:1447 ../Beremiz.py:1448
 msgid ",   "
 msgstr ""
 
-#: ../Beremiz.py:1446
+#: ../Beremiz.py:1443
 msgid ". "
 msgstr ""
 
@@ -68,11 +68,11 @@
 msgid "About"
 msgstr ""
 
-#: ../Beremiz.py:1395
+#: ../Beremiz.py:1392
 msgid "About Beremiz"
 msgstr ""
 
-#: ../Beremiz.py:1418
+#: ../Beremiz.py:1415
 msgid "Add Plugin"
 msgstr ""
 
@@ -191,7 +191,7 @@
 msgid "Choose a directory to save project"
 msgstr ""
 
-#: ../Beremiz.py:1308 ../Beremiz.py:1333
+#: ../Beremiz.py:1311 ../Beremiz.py:1339
 msgid "Choose a project"
 msgstr ""
 
@@ -219,11 +219,11 @@
 msgid "Cleaning the build directory\n"
 msgstr ""
 
-#: ../Beremiz.py:492 ../Beremiz.py:1360
+#: ../Beremiz.py:504
 msgid "Close Application"
 msgstr ""
 
-#: ../Beremiz.py:301
+#: ../Beremiz.py:301 ../Beremiz.py:489
 msgid "Close Project"
 msgstr ""
 
@@ -372,7 +372,7 @@
 msgid "Enter the IP of the interface to bind"
 msgstr ""
 
-#: ../Beremiz.py:1474 ../Beremiz.py:1484 ../plugger.py:873
+#: ../Beremiz.py:1471 ../Beremiz.py:1481 ../plugger.py:873
 #: ../Beremiz_service.py:268 ../Beremiz_service.py:392
 msgid "Error"
 msgstr ""
@@ -573,7 +573,7 @@
 msgid "Page Setup"
 msgstr ""
 
-#: ../Beremiz.py:1418
+#: ../Beremiz.py:1415
 msgid "Please enter a name for plugin:"
 msgstr ""
 
@@ -630,7 +630,7 @@
 msgid "Raw IEC code"
 msgstr ""
 
-#: ../Beremiz.py:1428
+#: ../Beremiz.py:1425
 msgid "Really delete plugin ?"
 msgstr ""
 
@@ -646,7 +646,7 @@
 msgid "Refresh\tCTRL+R"
 msgstr ""
 
-#: ../Beremiz.py:1428
+#: ../Beremiz.py:1425
 msgid "Remove plugin"
 msgstr ""
 
@@ -666,10 +666,6 @@
 msgid "Save as\tCTRL+SHIFT+S"
 msgstr ""
 
-#: ../Beremiz.py:491 ../Beremiz.py:1359
-msgid "Save changes ?"
-msgstr ""
-
 #: ../discovery.py:81
 msgid "Services available:"
 msgstr ""
@@ -735,6 +731,10 @@
 msgid "Stopping debug\n"
 msgstr ""
 
+#: ../Beremiz.py:492
+msgid "There are changes, do you want to save?"
+msgstr ""
+
 #: ../Beremiz.py:374
 msgid "Topology"
 msgstr ""
@@ -832,15 +832,15 @@
 msgid "exited with status %s (pid %s)\n"
 msgstr ""
 
-#: ../Beremiz.py:1448 ../Beremiz.py:1450
+#: ../Beremiz.py:1445 ../Beremiz.py:1447
 msgid "file : "
 msgstr ""
 
-#: ../Beremiz.py:1451
+#: ../Beremiz.py:1448
 msgid "function : "
 msgstr ""
 
-#: ../Beremiz.py:1451
+#: ../Beremiz.py:1448
 msgid "line : "
 msgstr ""
 
Binary file locale/fr_FR/LC_MESSAGES/Beremiz.mo has changed