Переглянути джерело

wxGUI: mapset path option removed from GUI preferences (see 'Mapset access' dialog), list of mapsets is build on the fly

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32126 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 роки тому
батько
коміт
1e0f53885c

+ 1 - 1
gui/wxpython/gui_modules/gdialogs.py

@@ -576,7 +576,7 @@ class LoadMapLayersDialog(wx.Dialog):
 
         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,

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

@@ -23,6 +23,7 @@ import wx.combo
 
 import globalvar
 import gcmd
+import utils
 from preferences import globalSettings as UserSettings
 
 class Select(wx.combo.ComboCtrl):
@@ -135,7 +136,7 @@ class TreeCtrlComboPopup(wx.combo.ComboPopup):
         
         # 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',

+ 6 - 46
gui/wxpython/gui_modules/preferences.py

@@ -55,10 +55,6 @@ class Settings:
             # general
             #
             'general': {
-                # current mapset search path
-                'mapsetPath'  : {
-                    'selection' : 0
-                    }, 
                 # use default window layout (layer manager, displays, ...)
                 'defWindowPos' : {
                     'enabled' : False,
@@ -422,9 +418,7 @@ class Settings:
             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 @@ class Settings:
         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,30 +761,9 @@ class PreferencesDialog(wx.Dialog):
         gridSizer.AddGrowableCol(0)
 
         #
-        # mapsets path
-        #
-        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
+        row = 0
         gridSizer.Add(item=wx.StaticText(parent=panel, id=wx.ID_ANY,
                                          label=_("Element list:")),
                       flag=wx.ALIGN_LEFT |
@@ -1522,7 +1486,8 @@ class MapsetAccess(wx.Dialog):
         
         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 @@ class MapsetAccess(wx.Dialog):
                   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,

+ 33 - 30
gui/wxpython/gui_modules/utils.py

@@ -128,46 +128,49 @@ def ListOfCatsToRange(cats):
         
     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.')
-
-    ListSortLower(all_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(mapsets)
     
-    return (all_mapsets, accessible_mapsets)
+    return mapsets
 
 def ListSortLower(list):
     """Sort list items (not case-sensitive)"""

+ 0 - 1
gui/wxpython/wxgui.py

@@ -362,7 +362,6 @@ class GMFrame(wx.Frame):
             # 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):
         """