[GRASS-SVN] r30886 - in grass/trunk/gui/wxpython: . gui_modules vdigit

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Apr 7 07:03:40 EDT 2008


Author: martinl
Date: 2008-04-07 07:03:40 -0400 (Mon, 07 Apr 2008)
New Revision: 30886

Modified:
   grass/trunk/gui/wxpython/gui_modules/digit.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/gui_modules/toolbars.py
   grass/trunk/gui/wxpython/vdigit/digit.cpp
   grass/trunk/gui/wxpython/vdigit/undo.cpp
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI (vdigit): "Save changes on exit" dialog added (can be disabled in vdigit settings)
(wxGUI) use wx.YES_NO style for wx.ICON_QUESTION


Modified: grass/trunk/gui/wxpython/gui_modules/digit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/digit.py	2008-04-07 10:12:53 UTC (rev 30885)
+++ grass/trunk/gui/wxpython/gui_modules/digit.py	2008-04-07 11:03:40 UTC (rev 30886)
@@ -1138,7 +1138,7 @@
     def Undo(self, level=-1):
         """Undo action
 
-        @param level levels to undo
+        @param level levels to undo (0 to revert all)
 
         @return id of current changeset
         """
@@ -1674,9 +1674,19 @@
         flexSizer.Add(units, proportion=0, flag=wx.ALIGN_RIGHT | wx.FIXED_MINSIZE | wx.ALIGN_CENTER_VERTICAL | wx.LEFT,
                       border=10)
         sizer.Add(item=flexSizer, proportion=0, flag=wx.EXPAND)
-        
         border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
 
+        #
+        # save-on-exit box
+        #
+        box   = wx.StaticBox (parent=panel, id=wx.ID_ANY, label=" %s " % _("Save changes"))
+        # save changes on exit?
+        sizer = wx.StaticBoxSizer(box, wx.VERTICAL)
+        self.save = wx.CheckBox(parent=panel, label=_("Save changes on exit automatically"))
+        self.save.SetValue(UserSettings.Get(group='vdigit', key='saveOnExit', subkey='enabled'))
+        sizer.Add(item=self.save, proportion=0, flag=wx.ALL | wx.EXPAND, border=1)
+        border.Add(item=sizer, proportion=0, flag=wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, border=5)
+
         panel.SetSizer(border)
         
         return panel
@@ -2018,6 +2028,9 @@
                                            value=self.FindWindowById(self.selectFeature[feature]).IsChecked())
         UserSettings.Set(group='vdigit', key="selectThresh", subkey='value', value=int(self.selectThreshValue.GetValue()))
 
+        # on-exit
+        UserSettings.Set(group='vdigit', key="saveOnExit", subkey='enabled', value=self.save.IsChecked())
+        
         # update driver settings
         self.parent.digit.driver.UpdateSettings()
 

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-04-07 10:12:53 UTC (rev 30885)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-04-07 11:03:40 UTC (rev 30886)
@@ -130,6 +130,8 @@
                 'selectFeatureCentroid' : { 'enabled' : True },
                 'selectFeatureBoundary' : { 'enabled' : True },
                 'selectThresh'          : { 'value' : 10, 'units' : 'screen pixels'},
+                # exit
+                'saveOnExit'            : { 'enabled' : False },
                 }
             }
 

Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py	2008-04-07 10:12:53 UTC (rev 30885)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py	2008-04-07 11:03:40 UTC (rev 30886)
@@ -28,6 +28,7 @@
 from digit import DigitSettingsDialog as DigitSettingsDialog
 from debug import Debug as Debug
 from icon import Icons as Icons
+from preferences import globalSettings as UserSettings
 
 gmpath = os.path.join(globalvar.ETCWXDIR, "icons")
 sys.path.append(gmpath)
@@ -752,15 +753,27 @@
             self.layerSelectedID = None
             Debug.msg (4, "DigitToolbar.StopEditing(): layer=%s" % \
                        (layerSelected.name))
-            self.combo.SetValue ('Select vector map')
+            self.combo.SetValue (_('Select vector map'))
 
+            # save changes (only for vdigit)
+            if UserSettings.Get(group='advanced', key='digitInterface', subkey='type') == 'vdigit':
+                if UserSettings.Get(group='vdigit', key='saveOnExit', subkey='enabled') is False:
+                    dlg = wx.MessageDialog(parent=self.parent, message=_("Do you want to save changes "
+                                                                         "to vector map <%s>?") % layerSelected.name,
+                                           caption=_("Save changes?"),
+                                           style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
+                    if dlg.ShowModal() == wx.ID_NO:
+                        # revert changes
+                        self.parent.digit.Undo(0)
+                    dlg.Destroy()
+
+            self.parent.digit.SetMapName(None) # -> close map
+
             # re-active layer 
             item = self.parent.tree.FindItemByData('maplayer', layerSelected)
             if item and self.parent.tree.IsItemChecked(item):
                 self.mapcontent.ChangeLayerActive(layerSelected, True)
 
-            self.parent.digit.SetMapName(None)
-
             # change cursor
             self.parent.MapWindow.SetCursor(self.parent.cursors["default"])
 

Modified: grass/trunk/gui/wxpython/vdigit/digit.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.cpp	2008-04-07 10:12:53 UTC (rev 30885)
+++ grass/trunk/gui/wxpython/vdigit/digit.cpp	2008-04-07 11:03:40 UTC (rev 30886)
@@ -31,7 +31,7 @@
     }
 
     changesetCurrent = -2; // initial value for undo/redo
-    changesetDead = -2;
+    changesetDead = -1;
 
     // avoid GUI crash
     // Vect_set_fatal_error(GV_FATAL_PRINT);

Modified: grass/trunk/gui/wxpython/vdigit/undo.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/undo.cpp	2008-04-07 10:12:53 UTC (rev 30885)
+++ grass/trunk/gui/wxpython/vdigit/undo.cpp	2008-04-07 11:03:40 UTC (rev 30886)
@@ -20,8 +20,10 @@
 #include "digit.h"
 
 /**
-   \brief Undo/Redo operations
+   \brief Undo/Redo changes in geometry
 
+   level=0 to revert all changes
+
    \param level level for undo/redo
 
    \return id of current chanset
@@ -44,7 +46,12 @@
 	changesetCurrent = 0;
     }
 
-    G_debug(2, "Digit.Undo(): changeset_last=%d changeset_dead=%d, changeset_current=%d, level=%d",
+    if (level == 0) {
+	/* 0 -> undo all */
+	level = changesetDead - changesetCurrent;
+    }
+
+    G_debug(0, "Digit.Undo(): changeset_last=%d changeset_dead=%d, changeset_current=%d, level=%d",
 	    changesetLast, changesetDead, changesetCurrent, level);
     
     if (level < 0) { /* undo */

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-04-07 10:12:53 UTC (rev 30885)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-04-07 11:03:40 UTC (rev 30886)
@@ -506,8 +506,8 @@
                                                     "Do you want to store current settings "
                                                     "to workspace file?"),
                                     caption=_("Save current settings?"),
-                                    style=wx.OK | wx.CANCEL | wx.ICON_QUESTION)
-             if dlg.ShowModal() == wx.ID_OK:
+                                    style=wxYES_NO | wxYES_DEFAULT | wx.ICON_QUESTION)
+             if dlg.ShowModal() == wx.ID_YES:
                  self.OnWorkspaceSaveAs()
              dlg.Destroy()
 



More information about the grass-commit mailing list