[GRASS-SVN] r71301 - in grass/trunk/gui/wxpython: lmgr mapdisp

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Jul 22 07:57:01 PDT 2017


Author: wenzeslaus
Date: 2017-07-22 07:57:01 -0700 (Sat, 22 Jul 2017)
New Revision: 71301

Modified:
   grass/trunk/gui/wxpython/lmgr/frame.py
   grass/trunk/gui/wxpython/lmgr/layertree.py
   grass/trunk/gui/wxpython/mapdisp/frame.py
Log:
wxGUI/mapdisp: change location at mapset to location/mapset in title

The syntax location at mapset uses @ which has different meaning in GRASS.
Location: at the beginning was not applicable anymore (was OK when there
was no mapset in the title.
Version removed from the title to make it shorter and consistent with other
windows such as Animation or Histogram Tool. Version is in Layer Manager
window title.
API standardized and its usage clarified (but still not ideal).
API used consitently so 'on map display rename' mapset is included as well
and title code is not duplicated.


Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2017-07-22 13:42:12 UTC (rev 71300)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2017-07-22 14:57:01 UTC (rev 71301)
@@ -1108,9 +1108,11 @@
             GMessage(parent=self,
                      message=_("Current mapset is <%s>.") % mapset)
 
+            # TODO: this does not use the actual names if they were
+            # renamed (it just uses the numbers)
             dispId = 1
             for display in self.GetMapDisplay(onlyCurrent=False):
-                display.SetTitleNumber(dispId)  # TODO: signal ?
+                display.SetTitleWithName(dispId)  # TODO: signal ?
                 dispId += 1
 
     def OnChangeCWD(self, event=None, cmd=None):
@@ -1719,11 +1721,12 @@
             self.notebookLayers.SetPageText(
                 page=self.currentPageNum, text=name)
             mapdisplay = self.GetMapDisplay()
-            mapdisplay.SetTitle(
-                _("GRASS GIS {version} Map Display: {name} - Location: {loc}").format(
-                    version=grass.version()['version'],
-                    name=name,
-                    loc=grass.gisenv()["LOCATION_NAME"]))
+            # There is a slight inconsistency: When creating the display
+            # we use just the number, but when user renames it,
+            # we use the full name. Both cases make sense and each
+            # separately gives expected result, so we keep this
+            # behavior.
+            mapdisplay.SetTitleWithName(name)
         dlg.Destroy()
 
     def OnRasterRules(self, event):

Modified: grass/trunk/gui/wxpython/lmgr/layertree.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/layertree.py	2017-07-22 13:42:12 UTC (rev 71300)
+++ grass/trunk/gui/wxpython/lmgr/layertree.py	2017-07-22 14:57:01 UTC (rev 71301)
@@ -202,7 +202,9 @@
                                    lmgr=self.lmgr, page=self.treepg,
                                    Map=self.Map)
 
-        self.mapdisplay.SetTitleNumber(self.displayIndex + 1)
+        # here (with initial auto-generated names) we use just the
+        # number, not the whole name for simplicity
+        self.mapdisplay.SetTitleWithName(self.displayIndex + 1)
 
         # show new display
         if showMapDisplay is True:

Modified: grass/trunk/gui/wxpython/mapdisp/frame.py
===================================================================
--- grass/trunk/gui/wxpython/mapdisp/frame.py	2017-07-22 13:42:12 UTC (rev 71300)
+++ grass/trunk/gui/wxpython/mapdisp/frame.py	2017-07-22 14:57:01 UTC (rev 71301)
@@ -243,18 +243,20 @@
     def GetMapWindow(self):
         return self.MapWindow
 
-    def SetTitleNumber(self, displayId=1):
-        """Set map display title"""
-        try:
-            grassVersion = grass.version()['version']
-        except KeyError:
-            sys.stderr.write(_("Unable to get GRASS version\n"))
-            grassVersion = "?"
+    def SetTitleWithName(self, name):
+        """Set map display title its name
 
+        This function should be used when there are multiple map
+        displays.
+
+        Sets also other dynamically determined parts of the title
+        specific for GRASS GIS map display,
+        while the standard (inherited) ``SetTitle()`` function sets the
+        raw title and doesn't add or modify anything.
+        """
         gisenv = grass.gisenv()
-        title = _("GRASS GIS %(version)s Map Display: %(id)s - Location: %(loc)s@%(mapset)s") % {
-            'version': grassVersion,
-            'id': str(displayId),
+        title = _("GRASS GIS Map Display: %(name)s - %(loc)s/%(mapset)s") % {
+            'name': str(name),
             'loc': gisenv["LOCATION_NAME"],
             'mapset': gisenv["MAPSET"]}
 



More information about the grass-commit mailing list