diff options
-rw-r--r-- | config/config.go | 8 | ||||
-rw-r--r-- | config/ui.go | 26 | ||||
-rw-r--r-- | widgets/aerc.go | 43 |
3 files changed, 50 insertions, 27 deletions
diff --git a/config/config.go b/config/config.go index 12da665b..2e45b0c8 100644 --- a/config/config.go +++ b/config/config.go @@ -183,3 +183,11 @@ func contains(list []string, v string) bool { } return false } + +// warning message related to configuration (deprecation, etc.) +type Warning struct { + Title string + Body string +} + +var Warnings []Warning diff --git a/config/ui.go b/config/ui.go index 752296a3..6c880293 100644 --- a/config/ui.go +++ b/config/ui.go @@ -321,24 +321,38 @@ func (config *UIConfig) parse(section *ini.Section) error { config.MessageViewThisDayTimeFormat = config.TimestampFormat } - if config.IndexFormat != "" { - log.Warnf("%s %s", - "The index-format setting has been replaced by index-columns.", - "index-format will be removed in aerc 0.17.") - } if key, err := section.GetKey("index-columns"); err == nil { columns, err := ParseColumnDefs(key, section) if err != nil { return err } config.IndexColumns = columns - config.IndexFormat = "" // to silence popup at startup } else if config.IndexFormat != "" { columns, err := convertIndexFormat(config.IndexFormat) if err != nil { return err } config.IndexColumns = columns + log.Warnf("%s %s", + "The index-format setting has been replaced by index-columns.", + "index-format will be removed in aerc 0.17.") + w := Warning{ + Title: "DEPRECATION WARNING: [" + section.Name() + "].index-format", + Body: fmt.Sprintf(` +The index-format setting is deprecated. It has been replaced by index-columns. + +Your configuration in this instance was automatically converted to: + +[%s] +%s +Your configuration file was not changed. To make this change permanent and to +dismiss this deprecation warning on launch, copy the above lines into aerc.conf +and remove index-format from it. See aerc-config(5) for more details. + +index-format will be removed in aerc 0.17. +`, section.Name(), ColumnDefsToIni(columns, "index-columns")), + } + Warnings = append(Warnings, w) } if key, err := section.GetKey("tab-title-account"); err == nil { val := key.Value() diff --git a/widgets/aerc.go b/widgets/aerc.go index f1e512f3..e8d65539 100644 --- a/widgets/aerc.go +++ b/widgets/aerc.go @@ -126,31 +126,32 @@ func NewAerc( } } - if config.Ui.IndexFormat != "" { - ini := config.ColumnDefsToIni( - config.Ui.IndexColumns, "index-columns") - title := "DEPRECATION WARNING" - text := ` -The index-format setting is deprecated. It has been replaced by index-columns. - -Your configuration in this instance was automatically converted to: - -[ui] -` + ini + ` -Your configuration file was not changed. To make this change permanent and to -dismiss this deprecation warning on launch, copy the above lines into aerc.conf -and remove index-format from it. See aerc-config(5) for more details. - -index-format will be removed in aerc 0.17. -` - aerc.AddDialog(NewSelectorDialog( - title, text, []string{"OK"}, 0, + aerc.showConfigWarnings() + + return aerc +} + +func (aerc *Aerc) showConfigWarnings() { + var dialogs []ui.DrawableInteractive + + callback := func(string, error) { + aerc.CloseDialog() + if len(dialogs) > 0 { + d := dialogs[0] + dialogs = dialogs[1:] + aerc.AddDialog(d) + } + } + + for _, w := range config.Warnings { + dialogs = append(dialogs, NewSelectorDialog( + w.Title, w.Body, []string{"OK"}, 0, aerc.SelectedAccountUiConfig(), - func(string, error) { aerc.CloseDialog() }, + callback, )) } - return aerc + callback("", nil) } func (aerc *Aerc) OnBeep(f func() error) { |