Merge pull request #37 from SamJakob/gui-fixes
Fix theming and confirm loss UI
This commit is contained in:
commit
2a698faef3
@ -152,6 +152,12 @@ class EditorStc(Editor):
|
|||||||
self.errorstyle = 5
|
self.errorstyle = 5
|
||||||
self.control.StyleSetSpec(self.errorstyle, "fore:#FFFF0000,back:#FF0000")
|
self.control.StyleSetSpec(self.errorstyle, "fore:#FFFF0000,back:#FF0000")
|
||||||
|
|
||||||
|
try:
|
||||||
|
if wx.SystemSettings.GetAppearance().IsDark():
|
||||||
|
self.control.StyleSetSpec(STC_STYLE_LINENUMBER, "fore:#FFFFFF")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def GetText(self):
|
def GetText(self):
|
||||||
return self.control.GetText()
|
return self.control.GetText()
|
||||||
|
|
||||||
|
@ -188,7 +188,10 @@ class MainWindow(wx.Frame):
|
|||||||
def SetTitle(self):
|
def SetTitle(self):
|
||||||
# MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to
|
# MainWindow.SetTitle overrides wx.Frame.SetTitle, so we have to
|
||||||
# call it using super:
|
# call it using super:
|
||||||
super(MainWindow, self).SetTitle('Scyther: %s'%self.filename)
|
if self.filename:
|
||||||
|
super(MainWindow, self).SetTitle('Scyther: %s'%self.filename)
|
||||||
|
else:
|
||||||
|
super(MainWindow, self).SetTitle('Scyther: Unsaved File...')
|
||||||
|
|
||||||
# Helper methods:
|
# Helper methods:
|
||||||
|
|
||||||
@ -214,8 +217,7 @@ class MainWindow(wx.Frame):
|
|||||||
return userProvidedFilename
|
return userProvidedFilename
|
||||||
|
|
||||||
# Are we dropping a changed file?
|
# Are we dropping a changed file?
|
||||||
|
def ConfirmLoss(self):
|
||||||
def ConfirmLoss(self,text=None):
|
|
||||||
"""
|
"""
|
||||||
Try to drop the current file. If it was changed, try to save
|
Try to drop the current file. If it was changed, try to save
|
||||||
(as)
|
(as)
|
||||||
@ -226,9 +228,11 @@ class MainWindow(wx.Frame):
|
|||||||
if self.editor.GetChanged():
|
if self.editor.GetChanged():
|
||||||
# File changed, we need to confirm this
|
# File changed, we need to confirm this
|
||||||
title = "Unsaved changes"
|
title = "Unsaved changes"
|
||||||
if text:
|
if self.filename:
|
||||||
title = "%s - " + title
|
title = ("%s - " + title) % (self.filename)
|
||||||
txt = "The protocol file '%s' has been modified.\n\n" % (self.filename)
|
txt = "The protocol file '%s' has been modified.\n\n" % (self.filename)
|
||||||
|
else:
|
||||||
|
txt = "You have unsaved changes.\n\n"
|
||||||
txt = txt + "Do you want to"
|
txt = txt + "Do you want to"
|
||||||
txt = txt + " save your changes (Yes)"
|
txt = txt + " save your changes (Yes)"
|
||||||
txt = txt + " or"
|
txt = txt + " or"
|
||||||
@ -263,16 +267,17 @@ class MainWindow(wx.Frame):
|
|||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def OnExit(self, event):
|
def OnExit(self, event):
|
||||||
if self.ConfirmLoss("Exit"):
|
if self.ConfirmLoss():
|
||||||
self.Close() # Close the main window.
|
self.Close() # Close the main window.
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def OnNew(self, event):
|
def OnNew(self, event):
|
||||||
if self.ConfirmLoss("Open"):
|
if self.ConfirmLoss():
|
||||||
self.editor.SetText('')
|
self.editor.SetText('')
|
||||||
self.filename = ''
|
self.filename = ''
|
||||||
self.editor.SetOpened()
|
self.editor.SetOpened()
|
||||||
|
self.SetTitle()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -287,7 +292,7 @@ class MainWindow(wx.Frame):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def OnOpen(self, event):
|
def OnOpen(self, event):
|
||||||
if self.ConfirmLoss("Open"):
|
if self.ConfirmLoss():
|
||||||
if self.askUserForFilename(style=wx.FD_OPEN,
|
if self.askUserForFilename(style=wx.FD_OPEN,
|
||||||
**self.defaultFileDialogOptions()):
|
**self.defaultFileDialogOptions()):
|
||||||
textfile = open(os.path.join(self.dirname, self.filename), 'r')
|
textfile = open(os.path.join(self.dirname, self.filename), 'r')
|
||||||
|
Loading…
Reference in New Issue
Block a user