Skip to content

Commit

Permalink
wxGUI: New, simplified, unified window titles (#1216)
Browse files Browse the repository at this point in the history
The 'lmgr' window is considered the main one, so it is no longer
called (GRASS GIS) Layer Manager, but just GRASS GIS. This fits well with this
window being the main GRASS GIS component for many users, although it is not
technically completely precise.

The lmgr window title previously included only workspace name after its base title.
Now it includes workspace name (if applicable), followed by
mapset/location (previously in map display title) and that is followed by the base title,
separated by dashes. This follows common practice of document before application name,
or from most specific information to most general. This also brings the titles closer
to what a single window interface would use. It also may improve the situation reported by a beginner:
*Once I open the GRASS GIS console...it opens another application called Layer Manager*, reported in
[Trac Ticket 3474](https://trac.osgeo.org/grass/ticket/3474).

The version number of is no longer included in the title. This is again a common practice
and it makes making release screenshots easier. Bug reports need a more complete info anyway.
Users which have multiple installations are likely advanced anyway and can always check if needed.

Map display does not include mapset/location at the end as before,
nor GRASS GIS as prefix. Titles of tabs in the Display tab are fully synchronized
with the titles regardless of the title being the default or custom,
so the tabs now say Map Display, not just Display. This simplifies the code
significantly and clarifies the interface. (Small change to rename item
in menu is included for further clarification.)

Database manager which includes vector name in the title follows the same practice
as the main window lmgr, i.e., document before tool/app name.
The read-only info is included with more common spelling and standard case
(applied in the table tab title).

Dialogs started from main GUI don't show GRASS GIS as first part of the title.
This basic title is usually set as default in the frame.
The corresponding g.gui.* tools (if any) set their own title using
a tool - program name syntax and are considered to be somewhat standalone,
so they include GRASS GIS after a dash.

The GUI forms/dialogs for modules no longer include keywords in (square) brackets.
Module name is therefore more highlighted as the actual tool name.
Keywords are not meant to be used this way. (A useful title might be menu item
label, but that's not readily available.)

wxgui.py now sets the application name and vendor which improves how the program
is titled on some platforms. (Making no distinction between internal and display
name because there is no current use case for that.)

Use Histogram Tool instead of Histogramming Tool because Histogram tool is much more
common (74500 Google results) than Histogramming Tool (567). It is also shorter and easier to spell.
Leaving the word histogramming in statusbar where it is used as a verb.

The d.histogram based tool title now has the module name in square brackets
(preceded by two spaces) following the practice from menus and Modules tab.
  • Loading branch information
wenzeslaus committed Jan 11, 2021
1 parent 3eb01a6 commit 4743d53
Show file tree
Hide file tree
Showing 37 changed files with 126 additions and 103 deletions.
2 changes: 1 addition & 1 deletion gui/wxpython/animation/frame.py
Expand Up @@ -48,7 +48,7 @@

class AnimationFrame(wx.Frame):

def __init__(self, parent, giface, title=_("GRASS GIS Animation tool"),
def __init__(self, parent, giface, title=_("Animation Tool"),
rasters=None, timeseries=None):
wx.Frame.__init__(self, parent, title=title,
style=wx.DEFAULT_FRAME_STYLE, size=(800, 600))
Expand Down
6 changes: 5 additions & 1 deletion gui/wxpython/animation/g.gui.animation.py
Expand Up @@ -128,7 +128,11 @@ def main():

app = wx.App()

frame = AnimationFrame(parent=None, giface=StandaloneGrassInterface())
frame = AnimationFrame(
parent=None,
giface=StandaloneGrassInterface(),
title=_("Animation Tool - GRASS GIS"),
)
frame.CentreOnScreen()
frame.Show()
if len(layerList) >= 1:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/datacatalog/frame.py
Expand Up @@ -30,7 +30,7 @@ class DataCatalogFrame(wx.Frame):

def __init__(self, parent, giface=None):
wx.Frame.__init__(self, parent=parent,
title=_('GRASS GIS Data Catalog'))
title=_('Data Catalog'))
self.SetName("DataCatalog")
self.SetIcon(
wx.Icon(
Expand Down
6 changes: 5 additions & 1 deletion gui/wxpython/datacatalog/g.gui.datacatalog.py
Expand Up @@ -43,7 +43,11 @@ def main():

app = wx.App()

frame = DataCatalogFrame(parent=None, giface=StandaloneGrassInterface())
frame = DataCatalogFrame(
parent=None,
giface=StandaloneGrassInterface(),
title=_("Data Catalog - GRASS GIS"),
)
frame.CentreOnScreen()
frame.Show()
app.MainLoop()
Expand Down
4 changes: 2 additions & 2 deletions gui/wxpython/dbmgr/base.py
Expand Up @@ -1151,7 +1151,7 @@ def AddLayer(self, layer, pos=-1):

label = _("Table")
if not self.dbMgrData['editable']:
label += _(" (readonly)")
label += _(" (read-only)")

if pos == -1:
pos = self.GetPageCount()
Expand Down Expand Up @@ -2274,7 +2274,7 @@ def AddLayer(self, layer, pos=-1):
self.layerPage[layer]['tablePage'] = panel.GetId()
label = _("Table")
if not self.dbMgrData['editable']:
label += _(" (readonly)")
label += _(" (read-only)")

if pos == -1:
pos = self.GetPageCount()
Expand Down
9 changes: 6 additions & 3 deletions gui/wxpython/dbmgr/g.gui.dbmgr.py
Expand Up @@ -51,9 +51,12 @@ def main():
_("Loading attribute data for vector map <%s>...") %
mapName)
f = AttributeManager(
parent=None, id=wx.ID_ANY, title="%s - <%s>" %
(_("GRASS GIS Attribute Table Manager"), mapName), size=(
900, 600), vectorName=mapName)
parent=None,
id=wx.ID_ANY,
base_title=_("Attribute Table Manager - GRASS GIS"),
size=(900, 600),
vectorName=mapName,
)
f.Show()

app.MainLoop()
Expand Down
18 changes: 12 additions & 6 deletions gui/wxpython/dbmgr/manager.py
Expand Up @@ -48,13 +48,16 @@
class AttributeManager(wx.Frame, DbMgrBase):

def __init__(self, parent, id=wx.ID_ANY,
title=None, vectorName=None, item=None, log=None,
title=None,
base_title=None,
vectorName=None, item=None, log=None,
selection=None, **kwargs):
"""GRASS Attribute Table Manager window
:param parent: parent window
:param id: window id
:param title: window title or None for default title
:param title: full window title or None for default title
:param base_title: the document independent part of title or None for default
:param vectorName: name of vector map
:param item: item from Layer Tree
:param log: log window
Expand All @@ -76,11 +79,14 @@ def __init__(self, parent, id=wx.ID_ANY,

# title
if not title:
title = "%s" % _("GRASS GIS Attribute Table Manager - ")
if not base_title:
base_title = _("Attribute Table Manager")
document = self.dbMgrData['vectName']
if not self.dbMgrData['editable']:
title += _("READONLY - ")
title += "<%s>" % (self.dbMgrData['vectName'])

document = _("{document} (read-only)").format(document=document)
title = "{document} - {tool_name}".format(
document=document, tool_name=base_title
)
self.SetTitle(title)

# icon
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gcp/mapdisplay.py
Expand Up @@ -47,7 +47,7 @@ class MapFrame(SingleMapFrame):
"""

def __init__(self, parent, giface,
title=_("GRASS GIS Manage Ground Control Points"),
title=_("Manage Ground Control Points"),
toolbars=["gcpdisp"], Map=None, auimgr=None,
name='GCPMapWindow', **kwargs):
"""Main map display window with toolbars, statusbar and
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gmodeler/frame.py
Expand Up @@ -78,7 +78,7 @@
class ModelFrame(wx.Frame):

def __init__(self, parent, giface, id=wx.ID_ANY,
title=_("GRASS GIS Graphical Modeler"), **kwargs):
title=_("Graphical Modeler"), **kwargs):
"""Graphical modeler main window
:param parent: parent window
Expand Down
6 changes: 5 additions & 1 deletion gui/wxpython/gmodeler/g.gui.gmodeler.py
Expand Up @@ -49,7 +49,11 @@ def main():
from gmodeler.frame import ModelFrame

app = wx.App()
frame = ModelFrame(parent=None, giface=StandaloneGrassInterface())
frame = ModelFrame(
parent=None,
giface=StandaloneGrassInterface(),
title=_("Graphical Modeler - GRASS GIS"),
)
if options['file']:
frame.LoadModelFile(options['file'])
frame.Show()
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/dialogs.py
Expand Up @@ -1997,7 +1997,7 @@ def OnTemplate(self, event):
class SqlQueryFrame(wx.Frame):

def __init__(self, parent, id=wx.ID_ANY,
title=_("GRASS GIS SQL Query Utility"),
title=_("SQL Query Utility"),
*kwargs):
"""SQL Query Utility window
"""
Expand Down
11 changes: 4 additions & 7 deletions gui/wxpython/gui_core/forms.py
Expand Up @@ -469,6 +469,7 @@ class TaskFrame(wx.Frame):

def __init__(self, parent, giface, task_description, id=wx.ID_ANY,
get_dcmd=None, layer=None,
title=None,
style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL, **kwargs):
self.get_dcmd = get_dcmd
self.layer = layer
Expand All @@ -478,13 +479,9 @@ def __init__(self, parent, giface, task_description, id=wx.ID_ANY,

self.dialogClosing = Signal('TaskFrame.dialogClosing')

# module name + keywords
title = self.task.get_name()
try:
if self.task.keywords != ['']:
title += " [" + ', '.join(self.task.keywords) + "]"
except ValueError:
pass
# Module name as title by default
if not title:
title = self.task.get_name()

wx.Frame.__init__(self, parent=parent, id=id, title=title,
name="MainFrame", style=style, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/gui_core/pyedit.py
Expand Up @@ -688,7 +688,7 @@ class PyEditFrame(wx.Frame):
# pylint: disable=invalid-name

def __init__(self, parent, giface, id=wx.ID_ANY,
title=_("GRASS GIS Simple Python Editor"),
title=_("Simple Python Editor"),
**kwargs):
wx.Frame.__init__(self, parent=parent, id=id, title=title, **kwargs)
self.parent = parent
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/iclass/frame.py
Expand Up @@ -76,7 +76,7 @@ class IClassMapFrame(DoubleMapFrame):

def __init__(
self, parent=None, giface=None,
title=_("GRASS GIS Supervised Classification Tool"),
title=_("Supervised Classification Tool"),
toolbars=["iClassMisc", "iClassMap", "vdigit", "iClass"],
size=(875, 600),
name='IClassWindow', **kwargs):
Expand Down
6 changes: 5 additions & 1 deletion gui/wxpython/iclass/g.gui.iclass.py
Expand Up @@ -108,7 +108,11 @@ def main():

# show main frame
giface = StandaloneGrassInterface()
frame = IClassMapFrame(parent=None, giface=giface)
frame = IClassMapFrame(
parent=None,
giface=giface,
title=_("Supervised Classification Tool - GRASS GIS"),
)
if not flags['m']:
frame.CenterOnScreen()
if group_name:
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/iscatt/frame.py
Expand Up @@ -168,7 +168,7 @@ class IScattDialog(wx.Dialog):

def __init__(
self, parent, giface,
title=_("GRASS GIS Interactive Scatter Plot Tool"),
title=_("Interactive Scatter Plot Tool"),
id=wx.ID_ANY, style=wx.DEFAULT_FRAME_STYLE, **kwargs):
wx.Dialog.__init__(
self,
Expand Down
53 changes: 26 additions & 27 deletions gui/wxpython/lmgr/frame.py
Expand Up @@ -91,12 +91,7 @@ def __init__(
if title:
self.baseTitle = title
else:
try:
grassVersion = grass.version()['version']
except KeyError:
sys.stderr.write(_("Unable to get GRASS version\n"))
grassVersion = "?"
self.baseTitle = _("GRASS GIS %s Layer Manager") % grassVersion
self.baseTitle = _("GRASS GIS")

self.iconsize = (16, 16)

Expand Down Expand Up @@ -265,15 +260,27 @@ def show_menu_errors(messages):

def _setTitle(self):
"""Set frame title"""
gisenv = grass.gisenv()
location = gisenv["LOCATION_NAME"]
mapset = gisenv["MAPSET"]
if self.workspaceFile:
filename = os.path.splitext(os.path.basename(self.workspaceFile))[0]
self.SetTitle(
self.baseTitle +
" - " +
os.path.splitext(
os.path.basename(
self.workspaceFile))[0])
"{workspace} - {location}/{mapset} - {program}".format(
location=location,
mapset=mapset,
workspace=filename,
program=self.baseTitle
)
)
else:
self.SetTitle(self.baseTitle)
self.SetTitle(
"{location}/{mapset} - {program}".format(
location=location,
mapset=mapset,
program=self.baseTitle
)
)

def _createMenuBar(self):
"""Creates menu bar"""
Expand All @@ -290,7 +297,7 @@ def _createTabMenu(self):
Used to rename display.
"""
menu = Menu()
item = wx.MenuItem(menu, id=wx.ID_ANY, text=_("Rename Map Display"))
item = wx.MenuItem(menu, id=wx.ID_ANY, text=_("Rename current Map Display"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnRenameDisplay, item)

Expand Down Expand Up @@ -1102,12 +1109,7 @@ def OnMapsetChanged(self, dbase, location, mapset):
If location is None, mapset changed within location.
"""
if not location:
# 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.SetTitleWithName(str(dispId)) # TODO: signal ?
dispId += 1
self._setTitle()
else:
# close current workspace and create new one
self.OnWorkspaceClose()
Expand Down Expand Up @@ -1766,12 +1768,7 @@ def OnRenameDisplay(self, event):
self.notebookLayers.SetPageText(
page=self.currentPageNum, text=name)
mapdisplay = self.GetMapDisplay()
# 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)
mapdisplay.SetTitle(name)
dlg.Destroy()

def OnRasterRules(self, event):
Expand Down Expand Up @@ -2087,7 +2084,7 @@ def NewDisplay(self, name=None, show=True):
if name:
dispName = name
else:
dispName = "Display " + str(self.displayIndex + 1)
dispName = _("Map Display {number}").format(number=self.displayIndex + 1)
self.notebookLayers.AddPage(
page=self.pg_panel, text=dispName, select=True)
self.currentPage = self.notebookLayers.GetCurrentPage()
Expand All @@ -2100,7 +2097,9 @@ def NewDisplay(self, name=None, show=True):
style=wx.TR_HAS_BUTTONS | wx.TR_LINES_AT_ROOT | wx.TR_HIDE_ROOT | wx.
TR_DEFAULT_STYLE | wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE,
idx=self.displayIndex, lmgr=self, notebook=self.notebookLayers,
showMapDisplay=show)
showMapDisplay=show,
title=dispName,
)

# layout for controls
cb_boxsizer = wx.BoxSizer(wx.VERTICAL)
Expand Down
11 changes: 5 additions & 6 deletions gui/wxpython/lmgr/layertree.py
Expand Up @@ -121,7 +121,9 @@ def __init__(self, parent, giface,
id=wx.ID_ANY, style=wx.SUNKEN_BORDER,
ctstyle=CT.TR_HAS_BUTTONS | CT.TR_HAS_VARIABLE_ROW_HEIGHT |
CT.TR_HIDE_ROOT | CT.TR_ROW_LINES | CT.TR_FULL_ROW_HIGHLIGHT |
CT.TR_MULTIPLE, **kwargs):
CT.TR_MULTIPLE,
title=None,
**kwargs):

if 'style' in kwargs:
ctstyle |= kwargs['style']
Expand Down Expand Up @@ -198,11 +200,8 @@ def __init__(self, parent, giface,
style=wx.DEFAULT_FRAME_STYLE,
tree=self, notebook=self.notebook,
lmgr=self.lmgr, page=self.treepg,
Map=self.Map)

# here (with initial auto-generated names) we use just the
# number, not the whole name for simplicity
self.mapdisplay.SetTitleWithName(str(self.displayIndex + 1))
Map=self.Map,
title=title)

# show new display
if showMapDisplay is True:
Expand Down
21 changes: 1 addition & 20 deletions gui/wxpython/mapdisp/frame.py
Expand Up @@ -61,7 +61,7 @@ class MapFrame(SingleMapFrame):
child double buffered drawing window.
"""

def __init__(self, parent, giface, title=_("GRASS GIS - Map display"),
def __init__(self, parent, giface, title=_("Map Display"),
toolbars=["map"], statusbar=True,
tree=None, notebook=None, lmgr=None,
page=None, Map=None, auimgr=None, name='MapWindow', **kwargs):
Expand Down Expand Up @@ -249,25 +249,6 @@ def CreateStatusbar(self):
def GetMapWindow(self):
return self.MapWindow

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 Map Display: %(name)s - %(loc)s/%(mapset)s") % {
'name': name,
'loc': gisenv["LOCATION_NAME"],
'mapset': gisenv["MAPSET"]}

self.SetTitle(title)

def _addToolbarVDigit(self):
"""Add vector digitizer toolbar
"""
Expand Down
2 changes: 1 addition & 1 deletion gui/wxpython/mapswipe/frame.py
Expand Up @@ -38,7 +38,7 @@
class SwipeMapFrame(DoubleMapFrame):

def __init__(self, parent=None, giface=None,
title=_("GRASS GIS Map Swipe"), name="swipe", **kwargs):
title=_("Map Swipe"), name="swipe", **kwargs):
DoubleMapFrame.__init__(self, parent=parent, title=title, name=name,
firstMap=Map(), secondMap=Map(), **kwargs)
Debug.msg(1, "SwipeMapFrame.__init__()")
Expand Down

0 comments on commit 4743d53

Please sign in to comment.