[GRASS-SVN] r32126 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 16 02:12:07 EDT 2008


Author: martinl
Date: 2008-07-16 02:12:04 -0400 (Wed, 16 Jul 2008)
New Revision: 32126

Modified:
   grass/trunk/gui/wxpython/gui_modules/gdialogs.py
   grass/trunk/gui/wxpython/gui_modules/gselect.py
   grass/trunk/gui/wxpython/gui_modules/preferences.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: mapset path option removed from GUI preferences (see 'Mapset access' dialog), list of mapsets is build on the fly

Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2008-07-15 22:03:13 UTC (rev 32125)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py	2008-07-16 06:12:04 UTC (rev 32126)
@@ -576,7 +576,7 @@
 
         self.mapset = wx.ComboBox(parent=self, id=wx.ID_ANY,
                                   style=wx.CB_SIMPLE | wx.CB_READONLY,
-                                  choices=UserSettings.Get(group='general', key='mapsetPath', subkey='value', internal=True),
+                                  choices=utils.ListOfMapsets(),
                                   size=(250,-1))
         self.mapset.SetStringSelection(grassenv.GetGRASSVariable("MAPSET"))
         bodySizer.Add(item=self.mapset,

Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py	2008-07-15 22:03:13 UTC (rev 32125)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py	2008-07-16 06:12:04 UTC (rev 32126)
@@ -23,6 +23,7 @@
 
 import globalvar
 import gcmd
+import utils
 from preferences import globalSettings as UserSettings
 
 class Select(wx.combo.ComboCtrl):
@@ -135,7 +136,7 @@
         
         # list of mapsets in current location
         if mapsets is None:
-            mapsets = UserSettings.Get(group='general', key='mapsetPath', subkey='value', internal=True)
+            mapsets = utils.ListOfMapsets()
 
         # map element types to g.mlist types
         elementdict = {'cell':'rast',

Modified: grass/trunk/gui/wxpython/gui_modules/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-15 22:03:13 UTC (rev 32125)
+++ grass/trunk/gui/wxpython/gui_modules/preferences.py	2008-07-16 06:12:04 UTC (rev 32126)
@@ -55,10 +55,6 @@
             # general
             #
             'general': {
-                # current mapset search path
-                'mapsetPath'  : {
-                    'selection' : 0
-                    }, 
                 # use default window layout (layer manager, displays, ...)
                 'defWindowPos' : {
                     'enabled' : False,
@@ -422,9 +418,7 @@
             for key in self.userSettings[group].keys():
                 self.internalSettings[group][key] = {}
 
-        self.internalSettings['general']["mapsetPath"]['value'] = self.GetMapsetPath()
-        self.internalSettings['general']['mapsetPath']['choices'] = (_('Mapset search path'),
-                                                                     _('All available mapsets'))
+        # self.internalSettings['general']["mapsetPath"]['value'] = self.GetMapsetPath()
         self.internalSettings['general']['elementListExpand']['choices'] = (_("Collapse all except PERMANENT and current"),
                                                                             _("Collapse all except PERMANENT"),
                                                                             _("Collapse all"),
@@ -455,15 +449,6 @@
         self.internalSettings['nviz']['view']['height'] = {}
         self.internalSettings['nviz']['view']['height']['value'] = -1
         
-    def GetMapsetPath(self):
-        """Store mapset search path"""
-        all, access = utils.ListOfMapsets()
-
-        if self.Get(group='general', key='mapsetPath', subkey='selection') == 0:
-            return access
-        else:
-            return all
-    
     def ReadSettingsFile(self, settings=None):
         """Reads settings file (mapset, location, gisdbase)"""
         if settings is None:
@@ -776,31 +761,10 @@
         gridSizer.AddGrowableCol(0)
 
         #
-        # mapsets path
+        # expand element list
         #
         row = 0
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
-                                         label=_("Mapsets path:")),
-                       flag=wx.ALIGN_LEFT |
-                       wx.ALIGN_CENTER_VERTICAL,
-                       pos=(row, 0))
-        mapsetPath = wx.Choice(parent=panel, id=wx.ID_ANY, size=(200, -1),
-                                    choices=self.settings.Get(group='general', key='mapsetPath',
-                                                              subkey='choices', internal=True),
-                                    name="GetSelection")
-        mapsetPath.SetSelection(self.settings.Get(group='general', key='mapsetPath', subkey='selection'))
-        self.winId['general:mapsetPath:selection'] = mapsetPath.GetId()
-
-        gridSizer.Add(item=mapsetPath,
-                      flag=wx.ALIGN_RIGHT |
-                      wx.ALIGN_CENTER_VERTICAL,
-                      pos=(row, 1))
-        
-        #
-        # expand element list
-        #
-        row +=1
-        gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Element list:")),
                       flag=wx.ALIGN_LEFT |
                       wx.ALIGN_CENTER_VERTICAL,
@@ -1522,7 +1486,8 @@
         
         wx.Dialog.__init__(self, parent, id, title, pos, size, style)
 
-        self.all_mapsets, self.accessible_mapsets = utils.ListOfMapsets()
+        self.all_mapsets = utils.ListOfMapsets(all=True)
+        self.accessible_mapsets = utils.ListOfMapsets(all=False)
         self.curr_mapset = grassenv.GetGRASSVariable('MAPSET')
 
         # make a checklistbox from available mapsets and check those that are active
@@ -1541,13 +1506,8 @@
                   flag=wx.ALL | wx.EXPAND, border=5)
 
         # check all accessible mapsets
-        if globalSettings.Get(group='general', key='mapsetPath', subkey='selection') == 1:
-            for mset in self.all_mapsets:
-                self.mapsetlb.CheckItem(self.all_mapsets.index(mset), True)
-        else:
-            for mset in self.accessible_mapsets:
-                self.mapsetlb.CheckItem(self.all_mapsets.index(mset), True)
-                pass
+        for mset in self.accessible_mapsets:
+            self.mapsetlb.CheckItem(self.all_mapsets.index(mset), True)
 
         # dialog buttons
         line = wx.StaticLine(parent=self, id=wx.ID_ANY,

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2008-07-15 22:03:13 UTC (rev 32125)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2008-07-16 06:12:04 UTC (rev 32126)
@@ -128,46 +128,49 @@
         
     return catstr.strip(',')
 
-def ListOfMapsets():
+def ListOfMapsets(all=False):
     """Get list of available/accessible mapsets
 
-    @return ([available mapsets], [accessible mapsets]) 
+    @param all if True get list of all mapsets
+
+    @return list of mapsets
     """
-    all_mapsets = []
-    accessible_mapsets = []
+    mapsets = []
 
     ### FIXME
     # problem using Command here (see preferences.py)
     # cmd = gcmd.Command(['g.mapsets', '-l'])
-    cmd = subprocess.Popen(['g.mapsets' + globalvar.EXT_BIN, '-l'],
-                           stdout=subprocess.PIPE)
+    if all:
+        cmd = subprocess.Popen(['g.mapsets' + globalvar.EXT_BIN, '-l'],
+                               stdout=subprocess.PIPE)
     
-    try:
-        # for mset in cmd.ReadStdOutput()[0].split(' '):
-        for line in cmd.stdout.readlines():
-            for mset in line.strip('%s' % os.linesep).split(' '):
-                if len(mset) == 0:
-                    continue
-                all_mapsets.append(mset)
-    except:
-        raise gcmd.CmdError('Unable to get list of available mapsets.')
+        try:
+            # for mset in cmd.ReadStdOutput()[0].split(' '):
+            for line in cmd.stdout.readlines():
+                for mset in line.strip('%s' % os.linesep).split(' '):
+                    if len(mset) == 0:
+                        continue
+                    mapsets.append(mset)
+        except:
+            raise gcmd.CmdError(_('Unable to get list of available mapsets.'))
     
-    # cmd = gcmd.Command(['g.mapsets', '-p'])
-    cmd = subprocess.Popen(['g.mapsets' + globalvar.EXT_BIN, '-p'],
-                           stdout=subprocess.PIPE)
-    try:
-        # for mset in cmd.ReadStdOutput()[0].split(' '):
-        for line in cmd.stdout.readlines():
-            for mset in line.strip('%s' % os.linesep).split(' '):
-                if len(mset) == 0:
-                    continue
-                accessible_mapsets.append(mset)
-    except:
-        raise gcmd.CmdError('Unable to get list of accessible mapsets.')
+    else:
+        # cmd = gcmd.Command(['g.mapsets', '-p'])
+        cmd = subprocess.Popen(['g.mapsets' + globalvar.EXT_BIN, '-p'],
+                               stdout=subprocess.PIPE)
+        try:
+            # for mset in cmd.ReadStdOutput()[0].split(' '):
+            for line in cmd.stdout.readlines():
+                for mset in line.strip('%s' % os.linesep).split(' '):
+                    if len(mset) == 0:
+                        continue
+                    mapsets.append(mset)
+        except:
+            raise gcmd.CmdError(_('Unable to get list of accessible mapsets.'))
 
-    ListSortLower(all_mapsets)
+        ListSortLower(mapsets)
     
-    return (all_mapsets, accessible_mapsets)
+    return mapsets
 
 def ListSortLower(list):
     """Sort list items (not case-sensitive)"""

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-07-15 22:03:13 UTC (rev 32125)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-07-16 06:12:04 UTC (rev 32126)
@@ -362,7 +362,6 @@
             # run g.mapsets with string of accessible mapsets
             cmdlist = ['g.mapsets', 'mapset=%s' % ','.join(ms)]
             gcmd.Command(cmdlist)
-            UserSettings.Set(group='general', key='mapsetPath', subkey='value', value=ms, internal=True)
             
     def OnRDigit(self, event):
         """



More information about the grass-commit mailing list