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

WTF-400 Spotify extracted to new config format

This commit is contained in:
Chris Cummer 2019-04-16 02:35:04 -07:00
parent 0403b75fe8
commit ae081e4b9f
3 changed files with 30 additions and 7 deletions

View File

@ -276,14 +276,15 @@ func makeWidget(app *tview.Application, pages *tview.Pages, widgetName string) w
case "security":
settings := security.NewSettingsFromYAML(wtf.Config)
widget = security.NewWidget(app, settings)
case "spotify":
settings := spotify.NewSettingsFromYAML(wtf.Config)
widget = spotify.NewWidget(app, pages, settings)
case "spotifyweb":
widget = spotifyweb.NewWidget(app, pages)
case "status":
widget = status.NewWidget(app)
case "system":
widget = system.NewWidget(app, date, version)
case "spotify":
widget = spotify.NewWidget(app, pages)
case "spotifyweb":
widget = spotifyweb.NewWidget(app, pages)
case "textfile":
widget = textfile.NewWidget(app, pages)
case "todo":

View File

@ -0,0 +1,18 @@
package spotify
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

@ -20,17 +20,21 @@ const HelpText = `
type Widget struct {
wtf.HelpfulWidget
wtf.TextWidget
spotigopher.SpotifyClient
settings *Settings
spotigopher.Info
spotigopher.SpotifyClient
}
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) *Widget {
spotifyClient := spotigopher.NewClient()
widget := Widget{
HelpfulWidget: wtf.NewHelpfulWidget(app, pages, HelpText),
TextWidget: wtf.NewTextWidget(app, "Spotify", "spotify", true),
SpotifyClient: spotifyClient,
Info: spotigopher.Info{},
SpotifyClient: spotifyClient,
settings: settings,
}
widget.HelpfulWidget.SetView(widget.View)
widget.TextWidget.RefreshInt = 5