Przeglądaj źródła

wxGUI/mapdisp: change location@mapset to location/mapset in title

The syntax location@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.


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@71301 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras 7 lat temu
rodzic
commit
8f9ab1f8e4

+ 9 - 6
gui/wxpython/lmgr/frame.py

@@ -1108,9 +1108,11 @@ class GMFrame(wx.Frame):
             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 @@ class GMFrame(wx.Frame):
             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):

+ 3 - 1
gui/wxpython/lmgr/layertree.py

@@ -202,7 +202,9 @@ class LayerTree(treemixin.DragAndDrop, CT.CustomTreeCtrl):
                                    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:

+ 12 - 10
gui/wxpython/mapdisp/frame.py

@@ -243,18 +243,20 @@ class MapFrame(SingleMapFrame):
     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"]}