Skip to content

Commit

Permalink
wxGUI/lmgr: add layer menu items for check/uncheck selected layers (O…
Browse files Browse the repository at this point in the history
  • Loading branch information
tmszi authored and ninsbl committed Feb 17, 2023
1 parent d28ce79 commit a3b0065
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions gui/wxpython/lmgr/layertree.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ def OnLayerContextMenu(self, event):
"export-pg",
"export-attr",
"pack",
"check",
"uncheck",
):
self.popupID[key] = NewId()

Expand All @@ -478,6 +480,30 @@ def OnLayerContextMenu(self, event):
self.popupMenu.Append(self.popupID["rename"], _("Rename"))
self.Bind(wx.EVT_MENU, self.OnRenameLayer, id=self.popupID["rename"])

if numSelected > 1:
item = wx.MenuItem(
self.popupMenu,
id=self.popupID["check"],
text=_("Check selected layers"),
)
self.popupMenu.AppendItem(item)
self.Bind(
wx.EVT_MENU,
self.OnCheckUncheckSelectedLayer,
id=self.popupID["check"],
)
item = wx.MenuItem(
self.popupMenu,
id=self.popupID["uncheck"],
text=_("Uncheck selected layers"),
)
self.popupMenu.AppendItem(item)
self.Bind(
wx.EVT_MENU,
self.OnCheckUncheckSelectedLayer,
id=self.popupID["uncheck"],
)

# when multiple maps are selected of different types
# we cannot zoom or change region
# because g.region can handle only the same type
Expand Down Expand Up @@ -1334,6 +1360,15 @@ def OnGrassDBChanged(
)
self.SetItemText(item, newlabel)

def OnCheckUncheckSelectedLayer(self, event):
"""Check/uncheck selected layer(s)"""
check = wx.CHK_CHECKED
if event.GetId() == self.popupID["uncheck"]:
check = wx.CHK_UNCHECKED
self.hitCheckbox = True
for layer in self.GetSelections():
self.CheckItem(layer, checked=check)

def AddLayer(
self,
ltype,
Expand Down

0 comments on commit a3b0065

Please sign in to comment.