Skip to content

Commit

Permalink
Close channels automatically if user consents to closing a workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
ejeschke committed Oct 19, 2024
1 parent 8ad0a88 commit 3892a2e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
1 change: 1 addition & 0 deletions doc/WhatsNew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
======================
Expand Down
2 changes: 1 addition & 1 deletion ginga/gw/PluginManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 15 additions & 9 deletions ginga/rv/Control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]],
Expand All @@ -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)
Expand All @@ -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)))
Expand Down

0 comments on commit 3892a2e

Please sign in to comment.