[GRASS-SVN] r35500 - in grass/branches/releasebranch_6_4/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 20 13:54:50 EST 2009


Author: martinl
Date: 2009-01-20 13:54:50 -0500 (Tue, 20 Jan 2009)
New Revision: 35500

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py
   grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
Log:
wxGUI: fix trac #452 and #453
      (merge from trunk, r35498)


Modified: grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py	2009-01-20 18:53:31 UTC (rev 35499)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/preferences.py	2009-01-20 18:54:50 UTC (rev 35500)
@@ -79,6 +79,10 @@
                 'askOnRemoveLayer' : {
                     'enabled' : True
                     },
+                # ask when quiting wxGUI or closing display
+                'askOnQuit' : {
+                    'enabled' : True
+                    },
                 },
             #
             # display
@@ -931,6 +935,16 @@
         gridSizer.Add(item=askOnRemoveLayer,
                       pos=(row, 0), span=(1, 2))
 
+        row += 1
+        askOnQuit = wx.CheckBox(parent=panel, id=wx.ID_ANY,
+                                label=_("Ask when quiting wxGUI or closing display"),
+                                name='IsChecked')
+        askOnQuit.SetValue(self.settings.Get(group='manager', key='askOnQuit', subkey='enabled'))
+        self.winId['manager:askOnQuit:enabled'] = askOnQuit.GetId()
+
+        gridSizer.Add(item=askOnQuit,
+                      pos=(row, 0), span=(1, 2))
+        
         sizer.Add(item=gridSizer, proportion=1, flag=wx.ALL | wx.EXPAND, border=5)
         border.Add(item=sizer, proportion=0, flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, border=3)
 

Modified: grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py	2009-01-20 18:53:31 UTC (rev 35499)
+++ grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py	2009-01-20 18:54:50 UTC (rev 35500)
@@ -408,9 +408,38 @@
         Page of notebook closed
         Also close associated map display
         """
-
+        if UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'):
+            maptree = self.curr_page.maptree
+            
+            if self.workspaceFile:
+                message = _("Do you want to save changes in the workspace?")
+            else:
+                message = _("Do you want to store current settings "
+                            "to workspace file?")
+            
+            # ask user to save current settings
+            if maptree.GetCount() > 0:
+                dlg = wx.MessageDialog(self,
+                                       message=_("Do you want to close display %d?\n\n%s") % \
+                                           (self.curr_pagenum + 1, message),
+                                       caption=_("Close display"),
+                                       style=wx.YES_NO | wx.YES_DEFAULT |
+                                       wx.CANCEL | wx.ICON_QUESTION | wx.CENTRE)
+                ret = dlg.ShowModal()
+                if ret == wx.ID_YES:
+                    if not self.workspaceFile:
+                        self.OnWorkspaceSaveAs()
+                    else:
+                        self.SaveToWorkspaceFile(self.workspaceFile)
+                elif ret == wx.ID_CANCEL:
+                    event.Veto()
+                    dlg.Destroy()
+                    return
+                dlg.Destroy()
+        
         self.gm_cb.GetPage(event.GetSelection()).maptree.Map.Clean()
         self.gm_cb.GetPage(event.GetSelection()).maptree.Close(True)
+        
         event.Skip()
 
     def OnRunCmd(self, event):
@@ -1464,13 +1493,44 @@
         
     def OnCloseWindow(self, event):
         """Cleanup when wxgui.py is quit"""
+        if UserSettings.Get(group='manager', key='askOnQuit', subkey='enabled'):
+            maptree = self.curr_page.maptree
+            
+            if self.workspaceFile:
+                message = _("Do you want to save changes in the workspace?")
+            else:
+                message = _("Do you want to store current settings "
+                            "to workspace file?")
+            
+            # ask user to save current settings
+            if maptree.GetCount() > 0:
+                dlg = wx.MessageDialog(self,
+                                       message=message,
+                                       caption=_("Quit GRASS GUI"),
+                                       style=wx.YES_NO | wx.YES_DEFAULT |
+                                       wx.CANCEL | wx.ICON_QUESTION | wx.CENTRE)
+                ret = dlg.ShowModal()
+                if ret == wx.ID_YES:
+                    if not self.workspaceFile:
+                        self.OnWorkspaceSaveAs()
+                    else:
+                        self.SaveToWorkspaceFile(self.workspaceFile)
+                elif ret == wx.ID_CANCEL:
+                    event.Veto()
+                    dlg.Destroy()
+                    return
+                dlg.Destroy()
+        
+        # don't ask any more...
+        UserSettings.Set(group = 'manager', key = 'askOnQuit', subkey = 'enabled',
+                         value = False)
         for page in range(self.gm_cb.GetPageCount()):
-            self.gm_cb.GetPage(page).maptree.mapdisplay.OnCloseWindow(event)
+            self.gm_cb.GetPage(0).maptree.mapdisplay.OnCloseWindow(event)
         self.gm_cb.DeleteAllPages()
         # self.DestroyChildren()
         self._auimgr.UnInit()
         self.Destroy()
-
+        
     def MsgNoLayerSelected(self):
         """Show dialog message 'No layer selected'"""
         wx.MessageBox(parent=self,



More information about the grass-commit mailing list