Jelajahi Sumber

wxGUI: ask user if to quit GRASS when closeing GUI from title bar

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@66982 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 9 tahun lalu
induk
melakukan
d93b7f2491
1 mengubah file dengan 25 tambahan dan 2 penghapusan
  1. 25 2
      gui/wxpython/lmgr/frame.py

+ 25 - 2
gui/wxpython/lmgr/frame.py

@@ -177,7 +177,7 @@ class GMFrame(wx.Frame):
             
         self._auimgr.GetPane('toolbarNviz').Hide()
         # bindings
-        self.Bind(wx.EVT_CLOSE,    self.OnCloseWindow)
+        self.Bind(wx.EVT_CLOSE,    self.OnCloseWindowOrExit)
         self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
 
         self._giface.mapCreated.connect(self.OnMapCreated)
@@ -2204,8 +2204,27 @@ class GMFrame(wx.Frame):
     def OnCloseWindow(self, event):
         """Cleanup when wxGUI is quitted"""
         self._closeWindow()
+
+    def OnCloseWindowOrExit(self, event):
+        """Cleanup when wxGUI is quitted
+
+        Ask user also to quit GRASS including terminal
+        """
+        dlg = wx.MessageDialog(self,
+                               message = _("Do you want to quit GRASS GIS?"),
+                               caption = _("Quit GRASS GIS"),
+                               style = wx.YES_NO | wx.YES_DEFAULT |
+                               wx.CANCEL | wx.ICON_QUESTION | wx.CENTRE)
+        ret = dlg.ShowModal()
+        dlg.Destroy()
+
+        if ret != wx.ID_CANCEL:
+            self._closeWindow()
+            if ret == wx.ID_YES:
+                self._quitGRASS()
         
     def _closeWindow(self):
+        """Close wxGUI"""
         # save command protocol if actived
         if self.goutput.btnCmdProtocol.GetValue():
             self.goutput.CmdProtocolSave()
@@ -2257,8 +2276,12 @@ class GMFrame(wx.Frame):
         self.Destroy()
         
     def OnCloseWindowExitGRASS(self, event):
-        """Close wxGUI and exit GRASS shell."""
+        """Close wxGUI and quit GRASS terminal"""
         self._closeWindow()
+        self._quitGRASS()
+
+    def _quitGRASS(self):
+        """Quit GRASS terminal"""
         try:
             shellPid = int(grass.gisenv()['PID'])
             print >> sys.stderr, grass.gisenv()