Skip to content

Commit

Permalink
wxGUI: Copy mapset path from Data Catalog with right click (#2865)
Browse files Browse the repository at this point in the history
  • Loading branch information
firedragonironfist committed Mar 20, 2023
1 parent b617f45 commit c2c09ed
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions gui/wxpython/datacatalog/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2128,6 +2128,22 @@ def OnReloadMapset(self, event):
self.RefreshNode(node, recursive=True)
self.ExpandNode(node, recursive=False)

def OnCopyMapsetPath(self, event):
"""Copy path to mapset"""
if wx.TheClipboard.Open():
do = wx.TextDataObject()
text = []
for i in range(len(self.selected_mapset)):
path = os.path.join(
self.selected_grassdb[i].data["name"],
self.selected_location[i].data["name"],
self.selected_mapset[i].data["name"],
)
text.append(path)
do.SetText(",".join(text))
wx.TheClipboard.SetData(do)
wx.TheClipboard.Close()

def OnReloadLocation(self, event):
"""Reload all mapsets in selected location"""
node = self.selected_location[0]
Expand Down Expand Up @@ -2300,6 +2316,10 @@ def _popupMenuMapset(self):
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnReloadMapset, item)

item = wx.MenuItem(menu, wx.ID_ANY, _("&Copy path to mapset"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnCopyMapsetPath, item)

self.PopupMenu(menu)
menu.Destroy()

Expand Down Expand Up @@ -2400,6 +2420,10 @@ def _popupMenuMultipleMapsets(self):
if self._restricted:
item.Enable(False)

item = wx.MenuItem(menu, wx.ID_ANY, _("&Copy paths to mapsets"))
menu.AppendItem(item)
self.Bind(wx.EVT_MENU, self.OnCopyMapsetPath, item)

self.PopupMenu(menu)
menu.Destroy()

Expand Down

0 comments on commit c2c09ed

Please sign in to comment.