1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

WTF-400 Unknown extracted to new config format

This commit is contained in:
Chris Cummer 2019-04-16 21:43:46 -07:00
parent 4b3f957c61
commit 6f98ecccf7
3 changed files with 25 additions and 3 deletions

View File

@ -316,7 +316,8 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w
settings := zendesk.NewSettingsFromYAML(wtf.Config)
widget = zendesk.NewWidget(app, settings)
default:
widget = unknown.NewWidget(app, widgetName)
settings := unknown.NewSettingsFromYAML(wtf.Config)
widget = unknown.NewWidget(app, widgetName, settings)
}
return widget

View File

@ -0,0 +1,18 @@
package unknown
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
type Settings struct {
common *cfg.Common
}
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
settings := Settings{
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
}
return &settings
}

View File

@ -9,11 +9,15 @@ import (
type Widget struct {
wtf.TextWidget
settings *Settings
}
func NewWidget(app *tview.Application, name string) *Widget {
func NewWidget(app *tview.Application, name string, settings *Settings) *Widget {
widget := Widget{
TextWidget: wtf.NewTextWidget(app, name, name, false),
settings: settings,
}
return &widget
@ -22,7 +26,6 @@ func NewWidget(app *tview.Application, name string) *Widget {
/* -------------------- Exported Functions -------------------- */
func (widget *Widget) Refresh() {
widget.View.SetTitle(widget.ContextualTitle(fmt.Sprintf("%s", widget.Name())))
widget.View.Clear()