[GRASS-SVN] r49754 - in grass/branches/develbranch_6/gui/wxpython:
gui_core lmgr
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 14 15:36:12 EST 2011
Author: martinl
Date: 2011-12-14 12:36:11 -0800 (Wed, 14 Dec 2011)
New Revision: 49754
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py
grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py
grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
Log:
wxGUI: change location/mapset - don't show current mapset
call `g.mapset` to switch location/mapset
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py 2011-12-14 18:12:01 UTC (rev 49753)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/dialogs.py 2011-12-14 20:36:11 UTC (rev 49754)
@@ -146,14 +146,14 @@
self.element1 = MapsetSelect(parent = self.panel, id = wx.ID_ANY,
size = globalvar.DIALOG_GSELECT_SIZE,
- setItems = False)
+ setItems = False, skipCurrent = True)
self.PostInit()
- self.__Layout()
+ self._layout()
self.SetMinSize(self.GetSize())
- def __Layout(self):
+ def _layout(self):
"""!Do layout"""
self.dataSizer.Add(self.element, proportion = 0,
flag = wx.EXPAND | wx.ALL, border = 1)
@@ -174,7 +174,7 @@
if location:
dbase = grass.gisenv()['GISDBASE']
- self.element1.SetItems(GetListOfMapsets(dbase, location, selectable = True))
+ self.element1.UpdateItems(dbase = dbase, location = location)
self.element1.SetSelection(0)
mapset = self.element1.GetStringSelection()
@@ -197,7 +197,7 @@
else:
self.SetTitle(self.GetTitle() + ' <%s>' % grass.gisenv()['LOCATION_NAME'])
- self.element = MapsetSelect(parent = self.panel, id = wx.ID_ANY,
+ self.element = MapsetSelect(parent = self.panel, id = wx.ID_ANY, skipCurrent = True,
size = globalvar.DIALOG_GSELECT_SIZE)
self.PostInit()
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py 2011-12-14 18:12:01 UTC (rev 49753)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/gselect.py 2011-12-14 20:36:11 UTC (rev 49754)
@@ -904,10 +904,11 @@
"""!Widget for selecting GRASS mapset"""
def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_COMBOBOX_SIZE,
gisdbase = None, location = None, setItems = True,
- searchPath = False, **kwargs):
+ searchPath = False, skipCurrent = False, **kwargs):
super(MapsetSelect, self).__init__(parent, id, size = size,
style = wx.CB_READONLY, **kwargs)
- self.searchPath = searchPath
+ self.searchPath = searchPath
+ self.skipCurrent = skipCurrent
self.SetName("MapsetSelect")
if not gisdbase:
@@ -939,13 +940,21 @@
def _getMapsets(self):
if self.searchPath:
- return RunCommand('g.mapsets',
- read = True,
- flags = 'p',
- fs = 'newline').splitlines()
+ mlist = RunCommand('g.mapsets',
+ read = True, flags = 'p',
+ fs = 'newline').splitlines()
+ else:
+ mlist = GetListOfMapsets(self.gisdbase, self.location,
+ selectable = False)
- return GetListOfMapsets(self.gisdbase, self.location, selectable = False)
-
+ gisenv = grass.gisenv()
+ if self.skipCurrent and \
+ gisenv['LOCATION_NAME'] == self.location and \
+ gisenv['MAPSET'] in mlist:
+ mlist.remove(gisenv['MAPSET'])
+
+ return mlist
+
class SubGroupSelect(wx.ComboBox):
"""!Widget for selecting subgroups"""
def __init__(self, parent, id = wx.ID_ANY, size = globalvar.DIALOG_GSELECT_SIZE,
Modified: grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py 2011-12-14 18:12:01 UTC (rev 49753)
+++ grass/branches/develbranch_6/gui/wxpython/lmgr/frame.py 2011-12-14 20:36:11 UTC (rev 49754)
@@ -585,26 +585,26 @@
dlg = LocationDialog(parent = self)
if dlg.ShowModal() == wx.ID_OK:
location, mapset = dlg.GetValues()
- if location and mapset:
- ret = RunCommand("g.gisenv",
- set = "LOCATION_NAME=%s" % location)
- ret += RunCommand("g.gisenv",
- set = "MAPSET=%s" % mapset)
- if ret > 0:
- wx.MessageBox(parent = self,
- message = _("Unable to switch to location <%(loc)s> mapset <%(mapset)s>.") % \
- { 'loc' : location, 'mapset' : mapset },
- caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
- else:
- # close workspace
- self.OnWorkspaceClose()
- self.OnWorkspaceNew()
- wx.MessageBox(parent = self,
- message = _("Current location is <%(loc)s>.\n"
- "Current mapset is <%(mapset)s>.") % \
- { 'loc' : location, 'mapset' : mapset },
- caption = _("Info"), style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
-
+ dlg.Destroy()
+
+ if not location or not mapset:
+ GError(parent = self,
+ message = _("No location/mapset provided. Operation canceled."))
+ return # this should not happen
+
+ if RunCommand('g.mapset', parent = self,
+ location = location,
+ mapset = mapset) != 0:
+ return # error reported
+
+ # close workspace
+ self.OnWorkspaceClose()
+ self.OnWorkspaceNew()
+ GMessage(parent = self,
+ message = _("Current location is <%(loc)s>.\n"
+ "Current mapset is <%(mapset)s>.") % \
+ { 'loc' : location, 'mapset' : mapset })
+
def OnCreateMapset(self, event):
"""!Create new mapset"""
dlg = wx.TextEntryDialog(parent = self,
@@ -632,16 +632,16 @@
if dlg.ShowModal() == wx.ID_OK:
mapset = dlg.GetMapset()
+ dlg.Destroy()
+
if not mapset:
GError(parent = self,
message = _("No mapset provided. Operation canceled."))
return
- ret = RunCommand('g.mapset',
- parent = self,
- mapset = mapset)
-
- if ret == 0:
+ if RunCommand('g.mapset',
+ parent = self,
+ mapset = mapset) == 0:
GMessage(parent = self,
message = _("Current mapset is <%s>.") % mapset)
More information about the grass-commit
mailing list