Skip to content

Commit

Permalink
Merge e5c61e8 into 8b50990
Browse files Browse the repository at this point in the history
  • Loading branch information
kdschlosser committed Jul 30, 2017
2 parents 8b50990 + e5c61e8 commit e904af1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
13 changes: 12 additions & 1 deletion eg/Classes/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ def OnQueryEndSessionVista(self, event):
self.shouldVeto = True
event.Veto(True)
ShutdownBlockReasonCreate(self.hwnd, "Unsaved data")
if eg.config.allowShutdown:
if eg.config.saveOnShutdown:
eg.document.Save()
self.shouldVeto = False
ShutdownBlockReasonDestroy(self.hwnd)
wx.CallAfter(self.OnEndSession, None)
return
res = eg.document.CheckFileNeedsSave()
if res == wx.ID_YES:
# file was saved, reset everything
Expand All @@ -187,7 +194,11 @@ def OnQueryEndSessionXp(self, event):
if not self.firstQuery:
return
self.firstQuery = False
if eg.document.CheckFileNeedsSave() == wx.ID_CANCEL:
if eg.config.allowShutdown:
if eg.config.saveOnShutdown:
eg.document.Save()
event.Veto()
elif eg.document.CheckFileNeedsSave() == wx.ID_CANCEL:
event.Veto()
wx.CallAfter(self.Reset)

Expand Down
2 changes: 2 additions & 0 deletions eg/Classes/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class Config(Section):
refreshEnv = False
showTrayIcon = True
useFixedFont = False
saveOnShutdown = False
allowShutdown = False

class plugins: #pylint: disable-msg=C0103
pass
Expand Down
23 changes: 23 additions & 0 deletions eg/Classes/OptionsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Text(eg.TranslatableStrings):
StartWithWindows = 'Autostart EventGhost for user "%s"' % os.environ["USERNAME"]
UseAutoloadFile = "Autoload file"
UseFixedFont = 'Use fixed-size font in the "Log" pane'
AllowShutdown = 'Do not stop a system shutdown/restart'
SaveOnShutdown = 'Save unsaved data on shutdown/restart'


class OptionsDialog(eg.TaskletDialog):
Expand Down Expand Up @@ -140,6 +142,23 @@ def OnMemoryLimitCheckBox(dummyEvent):
text.UseFixedFont
)

allowShutdownCtrl = page1.CheckBox(
config.allowShutdown,
text.AllowShutdown
)

saveOnShutdownCtrl = page1.CheckBox(
config.saveOnShutdown,
text.SaveOnShutdown
)

saveOnShutdownCtrl.Enable(config.allowShutdown)

def OnAllowShutdown(evt):
saveOnShutdownCtrl.Enable(evt.IsChecked())

allowShutdownCtrl.Bind(wx.EVT_CHECKBOX, OnAllowShutdown)

def OnFixedFontBox(evt):
self.UpdateFont(evt.IsChecked())
useFixedFontCtrl.Bind(wx.EVT_CHECKBOX, OnFixedFontBox)
Expand Down Expand Up @@ -181,6 +200,8 @@ def OnFixedFontBox(evt):
(refreshEnvCtrl, 0, flags),
(propResizeCtrl, 0, flags),
(useFixedFontCtrl, 0, flags),
(allowShutdownCtrl, 0, flags),
(saveOnShutdownCtrl, 0, flags)
)
)

Expand Down Expand Up @@ -219,6 +240,8 @@ def OnFixedFontBox(evt):
config.refreshEnv = refreshEnvCtrl.GetValue()
config.propResize = propResizeCtrl.GetValue()
config.useFixedFont = useFixedFontCtrl.GetValue()
config.allowShutdown = allowShutdownCtrl.GetValue()
config.saveOnShutdown = saveOnShutdownCtrl.GetValue()
config.language = languageList[languageChoice.GetSelection()]
config.Save()
self.SetResult()
Expand Down

0 comments on commit e904af1

Please sign in to comment.