瀏覽代碼

wxGUI: save commands protocol when exiting wxGUI (if protocol is activated)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51797 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 年之前
父節點
當前提交
8c93490b68
共有 2 個文件被更改,包括 28 次插入17 次删除
  1. 22 16
      gui/wxpython/gui_core/goutput.py
  2. 6 1
      gui/wxpython/lmgr/frame.py

+ 22 - 16
gui/wxpython/gui_core/goutput.py

@@ -761,25 +761,31 @@ class GMConsole(wx.SplitterWindow):
         """!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()

+ 6 - 1
gui/wxpython/lmgr/frame.py

@@ -7,7 +7,7 @@ control for display management and access to command console.
 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 @@ class GMFrame(wx.Frame):
 
     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'):