aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/aerc.go
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-08-15 21:58:42 +0200
committerRobin Jarry <robin@jarry.cc>2022-09-19 21:25:18 +0200
commitee4f2ea49d82a27328f3a154e9f91dc91d69e990 (patch)
tree0aa798cef73cfc14bfdf83f37c760b355faabcf4 /widgets/aerc.go
parentb31bb1876bee90434496d852f55a820fa3a26ca5 (diff)
downloadaerc-ee4f2ea49d82a27328f3a154e9f91dc91d69e990.tar.gz
composer: restructure to implement account switching
Extract some functionality of the composer constructor into a account-specific setup function that can be used to implement account switching. 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.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/widgets/aerc.go b/widgets/aerc.go
index 7ba1ea4e..656b25de 100644
--- a/widgets/aerc.go
+++ b/widgets/aerc.go
@@ -375,6 +375,21 @@ func (aerc *Aerc) SelectedAccount() *AccountView {
return aerc.account(aerc.SelectedTabContent())
}
+func (aerc *Aerc) Account(name string) (*AccountView, error) {
+ if acct, ok := aerc.accounts[name]; ok {
+ return acct, nil
+ }
+ return nil, fmt.Errorf("account <%s> not found", name)
+}
+
+func (aerc *Aerc) AccountNames() []string {
+ results := make([]string, 0)
+ for name := range aerc.accounts {
+ results = append(results, name)
+ }
+ return results
+}
+
func (aerc *Aerc) account(d ui.Drawable) *AccountView {
switch tab := d.(type) {
case *AccountView: