Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wxGUI: startup screen removed #1400

Merged
merged 45 commits into from
Apr 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3919e22
wxGUI: startup screen code removed, instead the idea of demolocation …
Feb 23, 2021
3b1f5c1
wxGUI: minor edits
Feb 24, 2021
fa3adeb
flake8
Feb 24, 2021
726c016
black
Feb 24, 2021
bb45874
wxGUI: variable reason removed from gisrc, only last_mapset_path is n…
Mar 5, 2021
d95011b
black
Mar 5, 2021
5f94aa4
flake8
Mar 5, 2021
3959d55
Path to the default database is now configurable through RC file.
Mar 8, 2021
1d50ec9
black
Mar 8, 2021
276f4e4
wxGUI: first time user and nonstandard startup is now strictly separa…
Mar 14, 2021
42688a2
some smaller edits, simplifying, saving last used mapset when switche…
Mar 14, 2021
3079544
description edit
Mar 14, 2021
b41468f
delay is the class attribute now
Mar 25, 2021
b3add23
extra gap and black
Mar 25, 2021
01fbea4
non_standard_startup and first_time_user moved to check.py. New file …
Mar 29, 2021
bc655f2
new session file created, globalvars made as dictionary
Mar 30, 2021
1dc932e
wxGUI: infomanager shortened and reason_id is now string variable
Mar 30, 2021
26f1fae
writing to gisrcrc simplified and only one function is-first-time-use…
Mar 30, 2021
7b64859
black, flake
Mar 30, 2021
4a25e1b
deleting and removing temporary location when switched from tmp in no…
Mar 30, 2021
99a4404
hide infobar
Mar 30, 2021
bc4110b
flake, black
Mar 30, 2021
28cfdba
this function not used anymore
Mar 30, 2021
b1ef378
global variables not dict
Mar 31, 2021
74c6226
notes from Vashek for gui
Mar 31, 2021
dc10dad
notes from Vashek for grassdb and app
Mar 31, 2021
277c907
mainly renaming variables and some simplyfing
Apr 1, 2021
391c1d3
wxGUI: temporary location deleted only when not current
Apr 1, 2021
91aa700
temporary location deleted only when switched to another db (a user c…
Apr 1, 2021
44b7bca
flake
Apr 1, 2021
a85e731
is_backup_session --> is_fallback_session
Apr 1, 2021
8f7dc46
small edits in grass.py
Apr 6, 2021
76e32a1
small edits in checks.py
Apr 6, 2021
2cff0bc
wxGUI: edits in info messages
Apr 6, 2021
7e5bb36
black applied and keys() kept in gisenv
Apr 6, 2021
c46803c
The logics in grass.py was a bit simplified.
Apr 6, 2021
174ac9d
wxGUI: deleting tmp loc handled in switch_mapset_interactively, curre…
Apr 6, 2021
a8e7e11
wxGUI: is_fallback_session moved to switch_mapset_interactively
Apr 6, 2021
c320c9a
simplified
Apr 6, 2021
07702b0
minor edits
Apr 8, 2021
f79f263
Anna's edits
Apr 8, 2021
a80868c
wxGUI: buttons in infobars translatable
Apr 8, 2021
71cf651
comment for removing useless grassdb node added
Apr 12, 2021
e8c6807
grass.py: not create tmp loc when --text flag, locked_mapset function…
Apr 12, 2021
7592c4d
Call set_mapset in every branch (all paths should lead to the same se…
wenzeslaus Apr 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gui/wxpython/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SRCFILES := $(wildcard icons/*.py scripts/*.py xml/*) \
mapswipe/*.py modules/*.py nviz/*.py psmap/*.py rdigit/*.py \
rlisetup/*.py startup/*.py timeline/*.py vdigit/*.py \
vnet/*.py web_services/*.py wxplot/*.py iscatt/*.py tplot/*.py photo2image/*.py image2target/*.py) \
gis_set.py gis_set_error.py wxgui.py README
wxgui.py README

DSTFILES := $(patsubst %,$(DSTDIR)/%,$(SRCFILES)) \
$(patsubst %.py,$(DSTDIR)/%.pyc,$(filter %.py,$(SRCFILES)))
Expand Down
43 changes: 39 additions & 4 deletions gui/wxpython/datacatalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@
from datacatalog.infomanager import DataCatalogInfoManager
from gui_core.wrap import Menu
from gui_core.forms import GUI
from grass.script import gisenv

from grass.pydispatch.signal import Signal

from grass.grassdb.checks import is_current_mapset_in_demolocation
from grass.grassdb.manage import split_mapset_path
from grass.grassdb.checks import (get_reason_id_mapset_not_usable,
is_fallback_session,
is_first_time_user)


class DataCatalog(wx.Panel):
Expand All @@ -55,7 +59,9 @@ def __init__(self, parent, giface=None, id=wx.ID_ANY,
self.tree.showNotification.connect(self.showNotification)

# infobar for data catalog
delay = 2000
self.infoBar = InfoBar(self)
self.giface.currentMapsetChanged.connect(self.dismissInfobar)

# infobar manager for data catalog
self.infoManager = DataCatalogInfoManager(infobar=self.infoBar,
Expand All @@ -65,9 +71,22 @@ def __init__(self, parent, giface=None, id=wx.ID_ANY,
# some layout
self._layout()

# show data structure infobar for first-time user with proper layout
if is_current_mapset_in_demolocation():
wx.CallLater(2000, self.showDataStructureInfo)
# show infobar for first-time user if applicable
if is_first_time_user():
# show data structure infobar for first-time user
wx.CallLater(delay, self.showDataStructureInfo)

# show infobar if last used mapset is not usable
if is_fallback_session():
# get reason why last used mapset is not usable
last_mapset_path = gisenv()["LAST_MAPSET_PATH"]
self.reason_id = get_reason_id_mapset_not_usable(last_mapset_path)
if self.reason_id in ("non-existent", "invalid", "different-owner"):
# show non-standard situation info
wx.CallLater(delay, self.showFallbackSessionInfo)
elif self.reason_id == "locked":
# show info allowing to switch to locked mapset
wx.CallLater(delay, self.showLockedMapsetInfo)

def _layout(self):
"""Do layout"""
Expand All @@ -85,12 +104,22 @@ def _layout(self):
def showDataStructureInfo(self):
self.infoManager.ShowDataStructureInfo(self.OnCreateLocation)

def showLockedMapsetInfo(self):
self.infoManager.ShowLockedMapsetInfo(self.OnSwitchToLastUsedMapset)

def showFallbackSessionInfo(self):
self.infoManager.ShowFallbackSessionInfo(self.reason_id)

def showImportDataInfo(self):
self.infoManager.ShowImportDataInfo(self.OnImportOgrLayers, self.OnImportGdalLayers)

def LoadItems(self):
self.tree.ReloadTreeItems()

def dismissInfobar(self):
if self.infoBar.IsShown():
self.infoBar.Dismiss()

def OnReloadTree(self, event):
"""Reload whole tree"""
self.LoadItems()
Expand Down Expand Up @@ -135,6 +164,12 @@ def OnDownloadLocation(self, event):
db_node, loc_node, mapset_node = self.tree.GetCurrentDbLocationMapsetNode()
self.tree.DownloadLocation(db_node)

def OnSwitchToLastUsedMapset(self, event):
"""Switch to last used mapset"""
last_mapset_path = gisenv()["LAST_MAPSET_PATH"]
grassdb, location, mapset = split_mapset_path(last_mapset_path)
self.tree.SwitchMapset(grassdb, location, mapset)

def OnImportGdalLayers(self, event):
"""Convert multiple GDAL layers to GRASS raster map layers"""
from modules.import_export import GdalImportDialog
Expand Down
59 changes: 53 additions & 6 deletions gui/wxpython/datacatalog/infomanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import wx

from grass.script import gisenv
from grass.grassdb.checks import get_mapset_owner


class DataCatalogInfoManager:
Expand All @@ -31,8 +32,10 @@ def __init__(self, infobar, giface):

def ShowDataStructureInfo(self, onCreateLocationHandler):
"""Show info about the data hierarchy focused on the first-time user"""
buttons = [("Create new Location", onCreateLocationHandler),
("Learn More", self._onLearnMore)]
buttons = [
(_("Create new Location"), onCreateLocationHandler),
(_("Learn more"), self._onLearnMore),
]
message = _(
"GRASS GIS helps you organize your data using Locations (projects) "
"which contain Mapsets (subprojects). All data in one Location is "
Expand All @@ -41,22 +44,66 @@ def ShowDataStructureInfo(self, onCreateLocationHandler):
"which uses WGS 84 (EPSG:4326). Consider creating a new Location with a CRS "
"specific to your area. You can do it now or anytime later from "
"the toolbar above."
).format(loc=gisenv()['LOCATION_NAME'])
).format(loc=gisenv()["LOCATION_NAME"])
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION, buttons)

def ShowImportDataInfo(self, OnImportOgrLayersHandler, OnImportGdalLayersHandler):
"""Show info about the data import focused on the first-time user"""
buttons = [("Import vector data", OnImportOgrLayersHandler),
("Import raster data", OnImportGdalLayersHandler)]
buttons = [
(_("Import vector data"), OnImportOgrLayersHandler),
(_("Import raster data"), OnImportGdalLayersHandler),
]
message = _(
"You have successfully created a new Location {loc}. "
"Currently you are in its PERMANENT Mapset which is used for "
"storing your base maps to make them readily available in other "
"Mapsets. You can create new Mapsets for different tasks by right "
"clicking on the Location name.\n\n"
"To import data, go to the toolbar above or use the buttons below."
).format(loc=gisenv()['LOCATION_NAME'])
).format(loc=gisenv()["LOCATION_NAME"])
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION, buttons)

def ShowFallbackSessionInfo(self, reason_id):
"""Show info when last used mapset is not usable"""
string = self._text_from_reason_id(reason_id)
lindakarlovska marked this conversation as resolved.
Show resolved Hide resolved
message = _(
"{string} GRASS GIS has started in a temporary Location. "
"To continue, use Data Catalog below to switch to a different Location."
).format(
string=string,
)
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION)

def ShowLockedMapsetInfo(self, OnSwitchMapsetHandler):
"""Show info when last used mapset is locked"""
last_used_mapset_path = gisenv()["LAST_MAPSET_PATH"]
buttons = [(_("Switch to last used mapset"), OnSwitchMapsetHandler)]
message = _(
"Last used mapset in path '{mapsetpath}' is currently in use. "
"GRASS GIS has started in a temporary Location. "
"To continue, use Data Catalog below to switch to a different Location "
"or remove lock file and switch to the last used mapset."
).format(mapsetpath=last_used_mapset_path)
self.infoBar.ShowMessage(message, wx.ICON_INFORMATION, buttons)

def _text_from_reason_id(self, reason_id):
""" Get string for infobar message based on the reason."""
last_used_mapset_path = gisenv()["LAST_MAPSET_PATH"]
reason = None
if reason_id == "non-existent":
reason = _(
"Last used mapset in path '{mapsetpath}' does not exist."
).format(mapsetpath=last_used_mapset_path)
elif reason_id == "invalid":
reason = _("Last used mapset in path '{mapsetpath}' is invalid.").format(
mapsetpath=last_used_mapset_path
)
elif reason_id == "different-owner":
owner = get_mapset_owner(last_used_mapset_path)
reason = _(
"Last used mapset in path '{mapsetpath}' has different owner {owner}."
).format(owner=owner, mapsetpath=last_used_mapset_path)
return reason

def _onLearnMore(self, event):
self._giface.Help(entry="grass_database")
18 changes: 11 additions & 7 deletions gui/wxpython/datacatalog/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@
from grass.script import gisenv
from grass.grassdb.data import map_exists
from grass.grassdb.checks import (get_mapset_owner, is_mapset_locked,
is_different_mapset_owner,
is_current_mapset_in_demolocation)
is_different_mapset_owner, is_first_time_user)
from grass.exceptions import CalledModuleError


Expand Down Expand Up @@ -957,7 +956,7 @@ def CreateLocation(self, grassdb_node):
"""
Creates new location interactively and adds it to the tree and switch
to its new PERMANENT mapset.
If a user was in Demolocation, it shows data import infobar.
If a user is a first-time user, it shows data import infobar.
"""
grassdatabase, location, mapset = (
create_location_interactively(self, grassdb_node.data['name'])
Expand All @@ -968,14 +967,14 @@ def CreateLocation(self, grassdb_node):
element='location',
action='new')

# show data import infobar for first-time user with proper layout
if is_current_mapset_in_demolocation():
self.showImportDataInfo.emit()

# switch to PERMANENT mapset in newly created location
self.SwitchMapset(grassdatabase, location, mapset,
show_confirmation=True)

# show data import infobar for first-time user with proper layout
if is_first_time_user():
self.showImportDataInfo.emit()

def OnCreateLocation(self, event):
"""Create new location"""
self.CreateLocation(self.selected_grassdb[0])
Expand Down Expand Up @@ -1560,6 +1559,11 @@ def _updateAfterGrassdbChanged(self, action, element, grassdb, location, mapset=
location=location)
if node:
self._renameNode(node, newname)
elif element == 'grassdb':
if action == 'delete':
node = self.GetDbNode(grassdb=grassdb)
if node:
self.RemoveGrassDB(node)
elif element in ('raster', 'vector', 'raster_3d'):
# when watchdog is used, it watches current mapset,
# so we don't process any signals here,
Expand Down
Loading