diff --git a/doc/WhatsNew.rst b/doc/WhatsNew.rst index 63a9e8fd7..8b532d169 100644 --- a/doc/WhatsNew.rst +++ b/doc/WhatsNew.rst @@ -27,6 +27,7 @@ Ver 5.2.0 (unreleased) - Deprecate Gtk.Table from GTK3 backend (switch to Gtk.Grid) - Added experimental support for GTK4 backend - Fixed an issue with toggling CheckBoxes in Qt6 +- Closing a workspace now doesn't require closing all windows first Ver 5.1.0 (2024-05-22) ====================== diff --git a/ginga/gw/PluginManager.py b/ginga/gw/PluginManager.py index 1994c380b..e8ff07c3d 100644 --- a/ginga/gw/PluginManager.py +++ b/ginga/gw/PluginManager.py @@ -314,7 +314,7 @@ def start_plugin_future(self, chname, opname, future, wd, ht = self.ds.get_ws_size(in_ws) vbox.extdata.size = (wd, ht) - vbox.resize(wd, ht) + #vbox.resize(wd, ht) if future is not None: p_info.obj.build_gui(vbox, future=future) diff --git a/ginga/rv/Control.py b/ginga/rv/Control.py index 40a900b48..a1daa2a0f 100644 --- a/ginga/rv/Control.py +++ b/ginga/rv/Control.py @@ -103,7 +103,8 @@ def __init__(self, logger, thread_pool, module_manager, preferences, # For callbacks for name in ('add-image', 'channel-change', 'remove-image', 'add-channel', 'delete-channel', 'field-info', - 'add-image-info', 'remove-image-info', 'viewer-select'): + 'add-image-info', 'remove-image-info', 'viewer-select', + 'delete-workspace'): self.enable_callback(name) # Initialize the timer factory @@ -2649,15 +2650,10 @@ def page_switch_cb(self, ws, child): def workspace_closed_cb(self, ws): self.logger.debug("workspace requests close") - num_children = ws.num_pages() - if num_children > 0: - self.show_error( - "Please close all windows in this workspace first!", - raisetab=True) - return # TODO: this will prompt the user if we should close the workspace - lbl = Widgets.Label("Really delete workspace '%s' ?" % (ws.name)) + lbl = Widgets.Label(f"Really delete workspace '{ws.name}' ?\n\n" + "This will close all open channels in that workspace.") dialog = Widgets.Dialog(title="Delete Workspace", flags=0, buttons=[['Cancel', 0], ['Ok', 1]], @@ -2675,6 +2671,16 @@ def delete_workspace_cb(self, w, rsp, ws): if rsp == 0: return + self.delete_workspace(ws) + return True + + def delete_workspace(self, ws): + # close all channels in workspace and their plugins + for channel in list(self.channel.values()): + if channel.workspace == ws.name: + self.delete_channel(channel.name) + + # close the workspace top_w = ws.extdata.get('top_w', None) if top_w is None: self.ds.remove_tab(ws.name) @@ -2685,7 +2691,7 @@ def delete_workspace_cb(self, w, rsp, ws): # inform desktop we are no longer tracking this self.ds.delete_ws(ws.name) - return True + self.make_gui_callback('delete-workspace', ws) def page_added_cb(self, ws, child): self.logger.debug("page added in %s: '%s'" % (ws.name, str(child)))