[GRASS-SVN] r51797 - in grass/trunk/gui/wxpython: gui_core lmgr

svn_grass at osgeo.org svn_grass at osgeo.org
Sat May 26 11:10:49 EDT 2012


Author: martinl
Date: 2012-05-26 08:10:49 -0700 (Sat, 26 May 2012)
New Revision: 51797

Modified:
   grass/trunk/gui/wxpython/gui_core/goutput.py
   grass/trunk/gui/wxpython/lmgr/frame.py
Log:
wxGUI: save commands protocol when exiting wxGUI (if protocol is activated)


Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py	2012-05-26 14:55:37 UTC (rev 51796)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py	2012-05-26 15:10:49 UTC (rev 51797)
@@ -761,25 +761,31 @@
         """!Update progress message info"""
         self.progressbar.SetValue(event.value)
 
-    def OnCmdProtocol(self, event):
+    def CmdProtocolSave(self):
+        """Save commands protocol into the file"""
+        if not hasattr(self, 'cmdFileProtocol'):
+            return # it should not happen
+        
+        try:
+            output = open(self.cmdFileProtocol, "w")
+            cmds = self.cmdPrompt.GetCommands()
+            output.write('\n'.join(cmds))
+            if len(cmds) > 0:
+                output.write('\n')
+        except IOError, e:
+            GError(_("Unable to write file '%s'.\n\nDetails: %s") % (path, e))
+        finally:
+            output.close()
+            
+        self.parent.SetStatusText(_("Commands protocol saved into '%s'") % self.cmdFileProtocol)
+        del self.cmdFileProtocol
+        
+    def OnCmdProtocol(self, event = None):
         """!Save commands into file"""
-        if not self.btnCmdProtocol.GetValue():
+        if not event.IsChecked():
             # stop capturing commands, save list of commands to the
             # protocol file
-            if hasattr(self, 'cmdFileProtocol'):
-                try:
-                    output = open(self.cmdFileProtocol, "w")
-                    cmds = self.cmdPrompt.GetCommands()
-                    output.write('\n'.join(cmds))
-                    if len(cmds) > 0:
-                        output.write('\n')
-                except IOError, e:
-                    GError(_("Unable to write file '%s'.\n\nDetails: %s") % (path, e))
-                finally:
-                    output.close()
-            
-                self.parent.SetStatusText(_("Commands protocol saved into '%s'") % self.cmdFileProtocol)
-                del self.cmdFileProtocol
+            self.CmdProtocolSave()
         else:
             # start capturing commands
             self.cmdPrompt.ClearCommands()

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2012-05-26 14:55:37 UTC (rev 51796)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2012-05-26 15:10:49 UTC (rev 51797)
@@ -7,7 +7,7 @@
 Classes:
  - frame::GMFrame
 
-(C) 2006-2011 by the GRASS Development Team
+(C) 2006-2012 by the GRASS Development Team
 
 This program is free software under the GNU General Public License
 (>=v2). Read the file COPYING that comes with GRASS for details.
@@ -1674,11 +1674,16 @@
 
     def OnCloseWindow(self, event):
         """!Cleanup when wxGUI is quitted"""
+        # save command protocol if actived
+        if self.goutput.btnCmdProtocol.GetValue():
+            self.goutput.CmdProtocolSave()
+        
         if not self.curr_page:
             self._auimgr.UnInit()
             self.Destroy()
             return
         
+        # save changes in the workspace
         maptree = self.curr_page.maptree
         if self.workspaceChanged and \
                 UserSettings.Get(group = 'manager', key = 'askOnQuit', subkey = 'enabled'):



More information about the grass-commit mailing list