[GRASS-SVN] r68409 - grass/trunk/gui/wxpython/gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun May 8 19:56:32 PDT 2016
Author: wenzeslaus
Date: 2016-05-08 19:56:32 -0700 (Sun, 08 May 2016)
New Revision: 68409
Modified:
grass/trunk/gui/wxpython/gui_core/pyedit.py
Log:
pyedit: ask to save only when needed (works only when mouse is used), ask when closing window (not only from menu)
Modified: grass/trunk/gui/wxpython/gui_core/pyedit.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/pyedit.py 2016-05-09 01:27:11 UTC (rev 68408)
+++ grass/trunk/gui/wxpython/gui_core/pyedit.py 2016-05-09 02:56:32 UTC (rev 68409)
@@ -397,6 +397,11 @@
"""Check if python script is empty"""
return len(self.body.GetText()) == 0
+ def IsContentValuable(self):
+ print "empty:", self.IsEmpty(), "modified:", self.IsModified()
+ print "valuable?", not self.IsEmpty() and self.IsModified()
+ return not self.IsEmpty() and self.IsModified()
+
def SetScriptTemplate(self, event):
if self.CanReplaceContent('template'):
self.body.SetText(script_template())
@@ -426,7 +431,9 @@
message = _("Replace the current content by the file content?")
else:
message = by_message
- if not self.IsEmpty() and self.IsModified():
+ print "CanReplaceContent:", self.IsEmpty(), self.IsModified()
+ print "CanNotReplaceContent?", not self.IsEmpty() and self.IsModified()
+ if self.IsContentValuable():
dlg = wx.MessageDialog(
parent=self.guiparent, message=message,
caption=_("Replace content"),
@@ -566,6 +573,7 @@
self.Fit()
self.SetAutoLayout(True)
self.Layout()
+ self.Bind(wx.EVT_CLOSE, self.OnClose)
# TODO: it would be nice if we can pass the controller to the menu
# might not be possible on the side of menu
@@ -577,8 +585,10 @@
self.controller.OnSave(*args, **kwargs)
def OnClose(self, *args, **kwargs):
- # saves without asking if we have an open file
- self.controller.OnSave(*args, **kwargs)
+ # this will be often true because PyStc is using EVT_KEY_DOWN
+ # to say if it was modified, not actual user change in text
+ if self.controller.IsContentValuable():
+ self.controller.OnSave(*args, **kwargs)
self.Destroy()
def OnRun(self, *args, **kwargs):
More information about the grass-commit
mailing list