[GRASS-SVN] r30716 - grass/trunk/gui/wxpython

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Mar 24 16:51:48 EDT 2008


Author: martinl
Date: 2008-03-24 16:51:48 -0400 (Mon, 24 Mar 2008)
New Revision: 30716

Modified:
   grass/trunk/gui/wxpython/gis_set.py
Log:
wxGUI (welcome screen): mapset with no user permission non-selectable (TODO: different style for non-selectable items)

Modified: grass/trunk/gui/wxpython/gis_set.py
===================================================================
--- grass/trunk/gui/wxpython/gis_set.py	2008-03-24 20:47:33 UTC (rev 30715)
+++ grass/trunk/gui/wxpython/gis_set.py	2008-03-24 20:51:48 UTC (rev 30716)
@@ -55,6 +55,7 @@
         #
         self.listOfLocations = []
         self.listOfMapsets = []
+        self.listOfMapsetsEnabled = []
 
         wx.Frame.__init__(self, parent=parent, id=id, style=style)
 
@@ -534,18 +535,30 @@
 
     def UpdateMapsets(self, location):
         """Update list of mapsets"""
+        self.FormerSelection = wx.NOT_FOUND # for non-selectable item
+
         self.listOfMapsets = []
+        self.listOfMapsetsEnabled = []
 
         for mapset in glob.glob(os.path.join(self.gisdbase, location, "*")):
             if os.path.isdir(mapset) and os.path.basename(mapset) != 'PERMANENT':
                 self.listOfMapsets.append(os.path.basename(mapset))
         
         utils.ListSortLower(self.listOfMapsets)
-        self.listOfMapsets.insert(0,'PERMANENT')
+        self.listOfMapsets.insert(0, 'PERMANENT')
  
         self.lbmapsets.Clear()
-        self.lbmapsets.InsertItems(self.listOfMapsets,0)
+        self.lbmapsets.InsertItems(self.listOfMapsets, 0)
 
+        # disable mapset with no permission
+        for line in gcmd.Command(['g.mapset',
+                                  '-l',
+                                  'location=%s' % os.path.basename(location),
+                                  'gisdbase=%s' % self.gisdbase]).ReadStdOutput():
+            self.listOfMapsetsEnabled += line.split(' ')
+
+        # TODO: non-selectable items in different style
+
         return self.listOfMapsets
 
     def OnSelectLocation(self, event):
@@ -562,8 +575,11 @@
 
     def OnSelectMapset(self,event):
         """Mapset selected"""
-        # self.bstart.Enable(True)
-        event.Skip()
+        if event.GetString() not in self.listOfMapsetsEnabled:
+            self.lbmapsets.SetSelection(self.FormerSelection)
+        else:
+            self.FormerSelection = event.GetSelection()
+            event.Skip()
 
     def OnSetDatabase(self,event):
         """Database set"""



More information about the grass-commit mailing list