[GRASS-SVN] r31962 - in grass/trunk/gui/wxpython: gui_modules vdigit
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jul 2 08:34:02 EDT 2008
Author: martinl
Date: 2008-07-02 08:34:02 -0400 (Wed, 02 Jul 2008)
New Revision: 31962
Modified:
grass/trunk/gui/wxpython/gui_modules/toolbars.py
grass/trunk/gui/wxpython/gui_modules/vdigit.py
grass/trunk/gui/wxpython/vdigit/digit.h
grass/trunk/gui/wxpython/vdigit/undo.cpp
Log:
wxGUI/vdigit: don't ask to save changes when there have been none (trac #210)
Modified: grass/trunk/gui/wxpython/gui_modules/toolbars.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-07-02 10:13:08 UTC (rev 31961)
+++ grass/trunk/gui/wxpython/gui_modules/toolbars.py 2008-07-02 12:34:02 UTC (rev 31962)
@@ -856,14 +856,15 @@
# 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 "
- "in 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()
+ if self.parent.digit.GetUndoLevel() > 0:
+ dlg = wx.MessageDialog(parent=self.parent, message=_("Do you want to save changes "
+ "in 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
Modified: grass/trunk/gui/wxpython/gui_modules/vdigit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-07-02 10:13:08 UTC (rev 31961)
+++ grass/trunk/gui/wxpython/gui_modules/vdigit.py 2008-07-02 12:34:02 UTC (rev 31962)
@@ -758,7 +758,7 @@
def Undo(self, level=-1):
"""Undo not implemented here"""
- wx.MessageBox(parent=self.mapWindow, message=_("Undondo is not implemented in vedit component. "
+ wx.MessageBox(parent=self.mapWindow, message=_("Undo is not implemented in vedit component. "
"Use vdigit instead."),
caption=_("Message"), style=wx.ID_OK | wx.ICON_INFORMATION | wx.CENTRE)
@@ -1179,6 +1179,10 @@
if ret < 0: # disable undo tool
self.toolbar.EnableUndo(False)
+
+ def GetUndoLevel(self):
+ """Get undo level (number of active changesets)"""
+ return self.digit.GetUndoLevel()
def __getSnapThreshold(self):
"""Get snap mode and threshold value
Modified: grass/trunk/gui/wxpython/vdigit/digit.h
===================================================================
--- grass/trunk/gui/wxpython/vdigit/digit.h 2008-07-02 10:13:08 UTC (rev 31961)
+++ grass/trunk/gui/wxpython/vdigit/digit.h 2008-07-02 12:34:02 UTC (rev 31962)
@@ -80,6 +80,7 @@
std::vector<int> GetLayers();
int Undo(int);
+ int GetUndoLevel();
};
#endif /* __DIGIT_H__ */
Modified: grass/trunk/gui/wxpython/vdigit/undo.cpp
===================================================================
--- grass/trunk/gui/wxpython/vdigit/undo.cpp 2008-07-02 10:13:08 UTC (rev 31961)
+++ grass/trunk/gui/wxpython/vdigit/undo.cpp 2008-07-02 12:34:02 UTC (rev 31962)
@@ -235,3 +235,13 @@
return action.size();
}
+
+/**
+ \brief Get undo level (number of active changesets)
+
+ \return number
+*/
+int Digit::GetUndoLevel()
+{
+ return changesetCurrent - changesetDead;
+}
More information about the grass-commit
mailing list