[GRASS-SVN] r48529 - in grass/branches/develbranch_6/gui/wxpython: . xml

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 28 06:36:12 EDT 2011


Author: martinl
Date: 2011-09-28 03:36:12 -0700 (Wed, 28 Sep 2011)
New Revision: 48529

Modified:
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
   grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
Log:
wxGUI: handler for creating new mapset
       (merge r48528 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-09-28 10:34:16 UTC (rev 48528)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2011-09-28 10:36:12 UTC (rev 48529)
@@ -599,21 +599,45 @@
                                       { 'loc' : location, 'mapset' : mapset },
                                   caption = _("Info"), style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
                     
+    def OnCreateMapset(self, event):
+        """!Create new mapset"""
+        dlg = wx.TextEntryDialog(parent = self,
+                                 message = _('Enter name for new mapset:'),
+                                 caption = _('Create new mapset'))
+        
+        if dlg.ShowModal() ==  wx.ID_OK:
+            mapset = dlg.GetValue()
+            if not mapset:
+                gcmd.GError(parent = self,
+                            message = _("No mapset provided. Operation canceled."))
+                return
+            
+            ret = gcmd.RunCommand('g.mapset',
+                                  parent = self,
+                                  flags = 'c',
+                                  mapset = mapset)
+            if ret == 0:
+                gcmd.GMessage(parent = self,
+                              message = _("Current mapset is <%s>.") % mapset)
+            
     def OnChangeMapset(self, event):
         """Change current mapset"""
         dlg = gdialogs.MapsetDialog(parent = self)
+        
         if dlg.ShowModal() == wx.ID_OK:
             mapset = dlg.GetMapset()
-            if mapset:
-                if gcmd.RunCommand("g.gisenv",
-                                   set = "MAPSET=%s" % mapset) != 0:
-                    wx.MessageBox(parent = self,
-                                  message = _("Unable to switch to mapset <%s>.") % mapset,
-                                  caption = _("Error"), style = wx.OK | wx.ICON_ERROR | wx.CENTRE)
-                else:
-                    wx.MessageBox(parent = self,
-                                  message = _("Current mapset is <%s>.") % mapset,
-                                  caption = _("Info"), style = wx.OK | wx.ICON_INFORMATION | wx.CENTRE)
+            if not mapset:
+                gcmd.GError(parent = self,
+                            message = _("No mapset provided. Operation canceled."))
+                return
+            
+            ret = gcmd.RunCommand('g.mapset',
+                                  parent = self,
+                                  mapset = mapset)
+            
+            if ret == 0:
+                gcmd.GMessage(parent = self,
+                              message = _("Current mapset is <%s>.") % mapset)
         
     def OnNewVector(self, event):
         """!Create new vector map layer"""

Modified: grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2011-09-28 10:34:16 UTC (rev 48528)
+++ grass/branches/develbranch_6/gui/wxpython/xml/menudata.xml	2011-09-28 10:36:12 UTC (rev 48529)
@@ -759,11 +759,13 @@
 	    <menuitem>
 	      <label>Change location and mapset</label>
 	      <help>Change current location and mapset.</help>
+	      <keywords>general,location,current</keywords>
               <handler>OnChangeLocation</handler>
 	    </menuitem>
 	    <menuitem>
 	      <label>Change mapset</label>
 	      <help>Change current mapset.</help>
+	      <keywords>general,mapset,current</keywords>
               <handler>OnChangeMapset</handler>
 	    </menuitem>
 	    <separator />
@@ -792,9 +794,15 @@
 	    <menuitem>
 	      <label>Create new location</label>
 	      <help>Launches location wizard to create new GRASS location.</help>
-	      <keywords>location, wizard</keywords>
+	      <keywords>general,location,wizard</keywords>
               <handler>OnLocationWizard</handler>
 	    </menuitem>
+	    <menuitem>
+	      <label>Create new mapset</label>
+	      <help>Creates new mapset in the current location, changes current mapset.</help>
+	      <keywords>general,mapset,create</keywords>
+              <handler>OnCreateMapset</handler>
+	    </menuitem>
 	    <separator />
 	    <menuitem>
 	      <label>Version</label>



More information about the grass-commit mailing list