diff options
author | Koni Marti <koni.marti@gmail.com> | 2022-04-17 01:03:49 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-04-17 12:18:22 +0200 |
commit | 6edfbfa8ce3760b7d0ee91bb6be768b296a50574 (patch) | |
tree | f612c7fa831ecbb30e6c4719cf4b8b5cd9844a39 /widgets/aerc.go | |
parent | 1ecee8efa5319cc9628deca04c354b2ebf87d89c (diff) | |
download | aerc-6edfbfa8ce3760b7d0ee91bb6be768b296a50574.tar.gz |
aerc: use contextual ui styleset for tabs/compose
Use contextual ui styleset for tabs and compose widgets. If no account
is selected, use default styleset as fallback.
Fixes: https://todo.sr.ht/~rjarry/aerc/3
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets/aerc.go')
-rw-r--r-- | widgets/aerc.go | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go index 94e67542..717547dc 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -87,10 +87,11 @@ func NewAerc(conf *config.AercConfig, logger *log.Logger, for i, acct := range conf.Accounts { view, err := NewAccountView(aerc, conf, &conf.Accounts[i], logger, aerc, deferLoop) if err != nil { - tabs.Add(errorScreen(err.Error(), conf.Ui), acct.Name) + tabs.Add(errorScreen(err.Error(), conf.Ui), acct.Name, nil) } else { aerc.accounts[acct.Name] = view - tabs.Add(view, acct.Name) + conf := view.UiConfig() + tabs.Add(view, acct.Name, &conf) } } @@ -303,7 +304,11 @@ func (aerc *Aerc) Logger() *log.Logger { } func (aerc *Aerc) SelectedAccount() *AccountView { - switch tab := aerc.SelectedTab().(type) { + return aerc.account(aerc.SelectedTab()) +} + +func (aerc *Aerc) account(d ui.Drawable) *AccountView { + switch tab := d.(type) { case *AccountView: return tab case *MessageViewer: @@ -335,7 +340,12 @@ func (aerc *Aerc) NumTabs() int { } func (aerc *Aerc) NewTab(clickable ui.Drawable, name string) *ui.Tab { - tab := aerc.tabs.Add(clickable, name) + var uiConf *config.UIConfig = nil + if acct := aerc.account(clickable); acct != nil { + conf := acct.UiConfig() + uiConf = &conf + } + tab := aerc.tabs.Add(clickable, name, uiConf) aerc.tabs.Select(len(aerc.tabs.Tabs) - 1) aerc.UpdateStatus() return tab |