diff options
author | Robin Jarry <robin@jarry.cc> | 2023-03-15 20:38:37 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-01 01:01:07 +0200 |
commit | 088d63ce934c34e113a5b3154dfcf91b49132067 (patch) | |
tree | a743b7f5f563d7382ebde83cac5ba498b3f6b1e7 /widgets/aerc.go | |
parent | aec90650f63ff0195599dae817016db137964bcb (diff) | |
download | aerc-088d63ce934c34e113a5b3154dfcf91b49132067.tar.gz |
tabs: make sure to close tab content
Rework how tabs are closed. Change the aerc.RemoveTab and
aerc.ReplaceTab functions to accept a new boolean argument. If true,
make sure to close the tab content.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r-- | widgets/aerc.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index 70083860..352bcadd 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -117,13 +117,8 @@ func NewAerc( return case *AccountWizard: return - case *Composer: - aerc.RemoveTab(content) - content.Close() - case *Terminal: - content.Close(nil) - case *MessageViewer: - aerc.RemoveTab(content) + default: + aerc.RemoveTab(content, true) } } @@ -485,13 +480,19 @@ func (aerc *Aerc) NewTab(clickable ui.Drawable, name string) *ui.Tab { return tab } -func (aerc *Aerc) RemoveTab(tab ui.Drawable) { +func (aerc *Aerc) RemoveTab(tab ui.Drawable, closeContent bool) { aerc.tabs.Remove(tab) aerc.UpdateStatus() + if content, ok := tab.(ui.Closeable); ok && closeContent { + content.Close() + } } -func (aerc *Aerc) ReplaceTab(tabSrc ui.Drawable, tabTarget ui.Drawable, name string) { +func (aerc *Aerc) ReplaceTab(tabSrc ui.Drawable, tabTarget ui.Drawable, name string, closeSrc bool) { aerc.tabs.Replace(tabSrc, tabTarget, name) + if content, ok := tabSrc.(ui.Closeable); ok && closeSrc { + content.Close() + } } func (aerc *Aerc) MoveTab(i int, relative bool) { |