[GRASS-SVN] r46468 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 31 05:46:35 EDT 2011


Author: martinl
Date: 2011-05-31 02:46:35 -0700 (Tue, 31 May 2011)
New Revision: 46468

Modified:
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
Log:
wxGUI: minor clean up of preferences.py


Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2011-05-31 09:43:07 UTC (rev 46467)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2011-05-31 09:46:35 UTC (rev 46468)
@@ -1001,12 +1001,14 @@
         settings = preferences.Settings()
         
         typeface = settings.Get(group='appearance', key='outputfont', subkey='type')   
-        if typeface == "": typeface = "Courier New"
-                           
+        if typeface == "":
+            typeface = "Courier New"
+        
         typesize = settings.Get(group='appearance', key='outputfont', subkey='size')
-        if typesize == None or typesize <= 0: typesize = 10
+        if typesize == None or typesize <= 0:
+            typesize = 10
         typesize = float(typesize)
-
+        
         self.StyleDefault     = 0
         self.StyleDefaultSpec = "face:%s,size:%d,fore:#000000,back:#FFFFFF" % (typeface, typesize)
         self.StyleCommand     = 1

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2011-05-31 09:43:07 UTC (rev 46467)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2011-05-31 09:46:35 UTC (rev 46468)
@@ -60,6 +60,9 @@
 class Settings:
     """!Generic class where to store settings"""
     def __init__(self):
+        # settings file
+        self.filePath = os.path.join(os.path.expanduser("~"), '.grass7', 'wx')
+        
         # key/value separator
         self.sep = ';'
         
@@ -670,17 +673,9 @@
         """!Reads settings file (mapset, location, gisdbase)"""
         if settings is None:
             settings = self.userSettings
-
-        # look for settings file
-        gisenv = grass.gisenv()
-        gisdbase = gisenv['GISDBASE']
-        location_name = gisenv['LOCATION_NAME']
-        mapset_name = gisenv['MAPSET']
         
-        filePath = os.path.join(os.path.expanduser("~"), '.grass7', 'wx') # MS Windows fix ?
+        self._readFile(self.filePath, settings)
         
-        self._readFile(filePath, settings)
-        
         # set environment variables
         os.environ["GRASS_FONT"] = self.Get(group = 'display',
                                             key = 'font', subkey = 'type')
@@ -749,11 +744,9 @@
             except:
                 wx.MessageBox(_('Cannot create directory for settings [home]/.grass7'),
                               _('Error saving preferences'))
-
-        filePath = os.path.join(home, '.grass7', 'wx')
         
         try:
-            file = open(filePath, "w")
+            file = open(self.filePath, "w")
             for group in settings.keys():
                 for key in settings[group].keys():
                     subkeys = settings[group][key].keys()
@@ -785,13 +778,11 @@
             raise gcmd.GException(e)
         except StandardError, e:
             raise gcmd.GException(_('Writing settings to file <%(file)s> failed.'
-                                    '\n\nDetails: %(detail)s') % { 'file' : filePath,
+                                    '\n\nDetails: %(detail)s') % { 'file' : self.filePath,
                                                                    'detail' : e })
         
         file.close()
         
-        return filePath
-
     def _parseValue(self, value, read = False):
         """!Parse value to be store in settings file"""
         if read: # -> read settings (cast values)
@@ -1035,8 +1026,8 @@
         Posts event EVT_SETTINGS_CHANGED.
         """
         if self._updateSettings():
-            file = self.settings.SaveToFile()
-            self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % file)
+            self.settings.SaveToFile()
+            self.parent.goutput.WriteLog(_('Settings saved to file \'%s\'.') % self.settings.filePath)
             event = wxSettingsChanged()
             wx.PostEvent(self, event)
             self.Close()



More information about the grass-commit mailing list