summary refs log tree commit diff stats
path: root/widgets/account.go
diff options
context:
space:
mode:
authorSrivathsan Murali <sri@vathsan.com>2020-01-23 13:56:48 +0100
committerDrew DeVault <sir@cmpwn.com>2020-01-24 10:50:21 -0500
commitb2fa5a16f52741a6f7f6e5f33561457d702dc31d (patch)
tree3c44cd8f100e0e8c156ad2bbe17ba46fb68a2e01 /widgets/account.go
parentaa967682bcdbeaa11b3e79d66b1d68b129dd4161 (diff)
downloadaerc-b2fa5a16f52741a6f7f6e5f33561457d702dc31d.tar.gz
Contextual UI Configuration
+ Adds parsing of contextual ui sections to aerc config.
+ Add GetUiConfig method for AercConfig that is used to get the
  specialized UI config.
+ Add UiConfig method to AccountView to get specialized UI Config.
+ Modifies Aerc codebase to use specialized UIConfig instead.
+ Adds documentation for Contextual UI Configuration
Diffstat (limited to 'widgets/account.go')
-rw-r--r--widgets/account.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/widgets/account.go b/widgets/account.go
index 404a9ea..66320a3 100644
--- a/widgets/account.go
+++ b/widgets/account.go
@@ -31,13 +31,24 @@ type AccountView struct {
 	worker  *types.Worker
 }
 
+func (acct *AccountView) UiConfig() config.UIConfig {
+	return acct.conf.GetUiConfig(map[int]string{
+		config.UI_CONTEXT_ACCOUNT: acct.AccountConfig().Name,
+		config.UI_CONTEXT_FOLDER:  acct.Directories().Selected(),
+	})
+}
+
 func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountConfig,
 	logger *log.Logger, host TabHost) *AccountView {
 
+	acctUiConf := conf.GetUiConfig(map[int]string{
+		config.UI_CONTEXT_ACCOUNT: acct.Name,
+	})
+
 	grid := ui.NewGrid().Rows([]ui.GridSpec{
 		{ui.SIZE_WEIGHT, 1},
 	}).Columns([]ui.GridSpec{
-		{ui.SIZE_EXACT, conf.Ui.SidebarWidth},
+		{ui.SIZE_EXACT, acctUiConf.SidebarWidth},
 		{ui.SIZE_WEIGHT, 1},
 	})
 
@@ -54,8 +65,8 @@ func NewAccountView(aerc *Aerc, conf *config.AercConfig, acct *config.AccountCon
 		}
 	}
 
-	dirlist := NewDirectoryList(acct, &conf.Ui, logger, worker)
-	if conf.Ui.SidebarWidth > 0 {
+	dirlist := NewDirectoryList(acct, &acctUiConf, logger, worker)
+	if acctUiConf.SidebarWidth > 0 {
 		grid.AddChild(ui.NewBordered(dirlist, ui.BORDER_RIGHT))
 	}
 
@@ -236,7 +247,7 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
 					acct.conf.Triggers.ExecNewEmail(acct.acct,
 						acct.conf, msg)
 				}, func() {
-					if acct.conf.Ui.NewMessageBell {
+					if acct.UiConfig().NewMessageBell {
 						acct.host.Beep()
 					}
 				})
@@ -272,10 +283,10 @@ func (acct *AccountView) onMessage(msg types.WorkerMessage) {
 }
 
 func (acct *AccountView) getSortCriteria() []*types.SortCriterion {
-	if len(acct.conf.Ui.Sort) == 0 {
+	if len(acct.UiConfig().Sort) == 0 {
 		return nil
 	}
-	criteria, err := sort.GetSortCriteria(acct.conf.Ui.Sort)
+	criteria, err := sort.GetSortCriteria(acct.UiConfig().Sort)
 	if err != nil {
 		acct.aerc.PushError(" ui.sort: " + err.Error())
 		return nil