|
@@ -290,6 +290,10 @@ class GMFrame(wx.Frame):
|
|
|
aui.EVT_AUINOTEBOOK_PAGE_CHANGED,
|
|
|
lambda evt: self.mapnotebook.GetCurrentPage().onFocus.emit(),
|
|
|
)
|
|
|
+ self.mapnotebook.Bind(
|
|
|
+ aui.EVT_AUINOTEBOOK_PAGE_CLOSE,
|
|
|
+ self.OnMapNotebookClose,
|
|
|
+ )
|
|
|
|
|
|
def _createDataCatalog(self, parent):
|
|
|
"""Initialize Data Catalog widget"""
|
|
@@ -459,14 +463,25 @@ class GMFrame(wx.Frame):
|
|
|
page = self.currentPage
|
|
|
|
|
|
def CanCloseDisplay(askIfSaveWorkspace):
|
|
|
- """Callback to check if user wants to close display"""
|
|
|
- pgnum = self.notebookLayers.GetPageIndex(page)
|
|
|
- name = self.notebookLayers.GetPageText(pgnum)
|
|
|
+ """Callback to check if user wants to close display. Map
|
|
|
+ Display index can be different from index in Display tab.
|
|
|
+
|
|
|
+ :return dict/None pgnum_dict/None: dict "layers" key represent
|
|
|
+ map display notebook layers
|
|
|
+ tree page index and
|
|
|
+ "mapnotebook" key represent
|
|
|
+ map display notebook page
|
|
|
+ index (single window mode)
|
|
|
+ """
|
|
|
+ pgnum_dict = {}
|
|
|
+ pgnum_dict["layers"] = self.notebookLayers.GetPageIndex(page)
|
|
|
+ pgnum_dict["mapnotebook"] = self.mapnotebook.GetPageIndex(mapdisplay)
|
|
|
+ name = self.notebookLayers.GetPageText(pgnum_dict["layers"])
|
|
|
caption = _("Close Map Display {}").format(name)
|
|
|
if not askIfSaveWorkspace or (
|
|
|
askIfSaveWorkspace and self.workspace_manager.CanClosePage(caption)
|
|
|
):
|
|
|
- return pgnum
|
|
|
+ return pgnum_dict
|
|
|
return None
|
|
|
|
|
|
mapdisplay.canCloseDisplayCallback = CanCloseDisplay
|
|
@@ -915,13 +930,22 @@ class GMFrame(wx.Frame):
|
|
|
|
|
|
event.Skip()
|
|
|
|
|
|
- def _closePageNoEvent(self, page_index):
|
|
|
- """Close page and destroy map display without
|
|
|
- generating notebook page closing event"""
|
|
|
+ def _closePageNoEvent(self, pgnum_dict):
|
|
|
+ """Close page and destroy map display without generating notebook
|
|
|
+ page closing event.
|
|
|
+
|
|
|
+ :param dict pgnum_dict: dict "layers" key represent map display
|
|
|
+ notebook layers tree page index and
|
|
|
+ "mapnotebook" key represent map display
|
|
|
+ notebook page index (single window mode)
|
|
|
+ """
|
|
|
self.notebookLayers.Unbind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING)
|
|
|
- self.notebookLayers.DeletePage(page_index)
|
|
|
- self.notebookLayers.Bind(FN.EVT_FLATNOTEBOOK_PAGE_CLOSING, self.OnCBPageClosing)
|
|
|
- self.mapnotebook.DeletePage(page_index)
|
|
|
+ self.notebookLayers.DeletePage(pgnum_dict["layers"])
|
|
|
+ self.notebookLayers.Bind(
|
|
|
+ FN.EVT_FLATNOTEBOOK_PAGE_CLOSING,
|
|
|
+ self.OnCBPageClosing,
|
|
|
+ )
|
|
|
+ self.mapnotebook.DeletePage(pgnum_dict["mapnotebook"])
|
|
|
|
|
|
def RunSpecialCmd(self, command):
|
|
|
"""Run command from command line, check for GUI wrappers"""
|
|
@@ -2304,3 +2328,9 @@ class GMFrame(wx.Frame):
|
|
|
style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION | wx.CENTRE,
|
|
|
)
|
|
|
return dlg
|
|
|
+
|
|
|
+ def OnMapNotebookClose(self, event):
|
|
|
+ """Page of map notebook is being closed"""
|
|
|
+ display = self.GetMapDisplay(onlyCurrent=True)
|
|
|
+ display.OnCloseWindow(event=None, askIfSaveWorkspace=True)
|
|
|
+ event.Veto()
|