Explorar o código

wxGUI: define GetSettingsPath()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46885 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa %!s(int64=14) %!d(string=hai) anos
pai
achega
f31f30a908

+ 2 - 2
gui/wxpython/gui_modules/gselect.py

@@ -1075,9 +1075,9 @@ class GdalSelect(wx.Panel):
             self.sourceMap['pro'] = idx
         
         if self.ogr:
-            self.settingsFile = os.path.join(os.path.expanduser("~"), '.grass7', 'wxOGR')
+            self.settingsFile = os.path.join(utils.GetSettingsPath(), 'wxOGR')
         else:
-            self.settingsFile = os.path.join(os.path.expanduser("~"), '.grass7', 'wxGDAL')
+            self.settingsFile = os.path.join(utils.GetSettingsPath(), 'wxGDAL')
         
         self._settings = self._loadSettings()
         self.settingsChoice = wx.Choice(parent = self, id = wx.ID_ANY)

+ 2 - 2
gui/wxpython/gui_modules/preferences.py

@@ -61,7 +61,7 @@ class Settings:
     """!Generic class where to store settings"""
     def __init__(self):
         # settings file
-        self.filePath = os.path.join(os.path.expanduser("~"), '.grass7', 'wx')
+        self.filePath = os.path.join(utils.GetSettingsPath(), 'wx')
         
         # key/value separator
         self.sep = ';'
@@ -766,7 +766,7 @@ class Settings:
         
         home = os.path.expanduser("~") # MS Windows fix ?
         
-        dirPath = os.path.join(home, '.grass7')
+        dirPath = utils.GetSettingsPath()
         if os.path.exists(dirPath) == False:
             try:
                 os.mkdir(dirPath)

+ 9 - 0
gui/wxpython/gui_modules/utils.py

@@ -752,3 +752,12 @@ def GetFormats():
             }
     
     return formats
+
+def GetSettingsPath():
+    """!Get full path to the settings directory
+    """
+    version = int(grass.version()['version'].split('.', 1)[0])
+    if sys.platform == 'win32':
+        return os.path.join(os.getenv('APPDATA'), '.grass%d' % version)
+    
+    return os.path.join(os.getenv('HOME'), '.grass%d' % version)