From 69581fcacc87a3a6e0ec393b76433be7e94048de Mon Sep 17 00:00:00 2001 From: ccremers Date: Wed, 2 Aug 2006 22:44:10 +0000 Subject: [PATCH] - Turned preferences file into something that is cross-platform. --- gui/Preference.py | 22 ++++++++++++++++++---- gui/scyther-gui.py | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/gui/Preference.py b/gui/Preference.py index 974227e..3daf437 100644 --- a/gui/Preference.py +++ b/gui/Preference.py @@ -23,6 +23,7 @@ import wx import os.path +import sys from time import localtime,strftime #--------------------------------------------------------------------------- @@ -35,7 +36,7 @@ from time import localtime,strftime """ Locations of preferences. The last one is supposedly writable. """ prefname = "scythergui-config" -preflocs = ['/usr/local/lib/scyther','~/.scyther'] +preflocs = [] #--------------------------------------------------------------------------- @@ -62,7 +63,7 @@ class Preferences(dict): Test default locations """ for f in preflocs: - self.load(os.path.join(os.path.expanduser(f),prefname)) + self.load(os.path.join(f,prefname)) else: """ @@ -82,7 +83,7 @@ class Preferences(dict): def save(self): print "Saving preferences" - prefpath = os.path.expanduser(preflocs[-1]) + prefpath = preflocs[-1] if not os.access(prefpath,os.W_OK): os.makedirs(prefpath) savename = os.path.join(prefpath,prefname) @@ -104,7 +105,20 @@ def init(): """ Load the preferences from a file, if possible """ - global prefs + global prefs,preflocs + + sp = wx.StandardPaths.Get() + confdir = sp.GetConfigDir() + confdir += "/scyther" + print confdir + userconfdir = sp.GetUserConfigDir() + userconfdir += "/" + if sys.platform.startswith("lin"): + userconfdir += "." + userconfdir += "scyther" + print userconfdir + + preflocs = [confdir,userconfdir] prefs = Preferences() prefs.load("") diff --git a/gui/scyther-gui.py b/gui/scyther-gui.py index 2945667..3d6a8ff 100755 --- a/gui/scyther-gui.py +++ b/gui/scyther-gui.py @@ -45,6 +45,8 @@ class MySplashScreen(wx.SplashScreen): class ScytherApp(wx.App): def OnInit(self): + wx.GetApp().SetAppName("Scyther-gui") + """ Load preferences file """