mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Merge pull request #669 from wtfutil/WTF-658-clocks-row-color
WTF-658 Clocks obeys global row color settings
This commit is contained in:
commit
7823d1d2e8
@ -11,15 +11,9 @@ func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat stri
|
|||||||
} else {
|
} else {
|
||||||
|
|
||||||
for idx, clock := range clocks {
|
for idx, clock := range clocks {
|
||||||
rowColor := widget.settings.colors.rows.odd
|
|
||||||
|
|
||||||
if idx%2 == 0 {
|
|
||||||
rowColor = widget.settings.colors.rows.even
|
|
||||||
}
|
|
||||||
|
|
||||||
str += fmt.Sprintf(
|
str += fmt.Sprintf(
|
||||||
" [%s]%-12s %-10s %7s[white]\n",
|
" [%s]%-12s %-10s %7s[white]\n",
|
||||||
rowColor,
|
widget.CommonSettings().RowColor(idx),
|
||||||
clock.Label,
|
clock.Label,
|
||||||
clock.Time(timeFormat),
|
clock.Time(timeFormat),
|
||||||
clock.Date(dateFormat),
|
clock.Date(dateFormat),
|
||||||
|
@ -11,15 +11,8 @@ const (
|
|||||||
defaultTitle = "Clocks"
|
defaultTitle = "Clocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
type colors struct {
|
// Settings defines the configuration properties for this module
|
||||||
rows struct {
|
|
||||||
even string
|
|
||||||
odd string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
colors
|
|
||||||
common *cfg.Common
|
common *cfg.Common
|
||||||
|
|
||||||
dateFormat string `help:"The format of the date string for all clocks." values:"Any valid Go date layout which is handled by Time.Format. Defaults to Jan 2."`
|
dateFormat string `help:"The format of the date string for all clocks." values:"Any valid Go date layout which is handled by Time.Format. Defaults to Jan 2."`
|
||||||
@ -28,6 +21,7 @@ type Settings struct {
|
|||||||
sort string `help:"Defines the display order of the clocks in the widget." values:"'alphabetical' or 'chronological'. 'alphabetical' will sort in acending order by key, 'chronological' will sort in ascending order by date/time."`
|
sort string `help:"Defines the display order of the clocks in the widget." values:"'alphabetical' or 'chronological'. 'alphabetical' will sort in acending order by key, 'chronological' will sort in ascending order by date/time."`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewSettingsFromYAML creates a new settings instance from a YAML config block
|
||||||
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
||||||
settings := Settings{
|
settings := Settings{
|
||||||
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
|
||||||
@ -38,8 +32,5 @@ func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *co
|
|||||||
sort: ymlConfig.UString("sort"),
|
sort: ymlConfig.UString("sort"),
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.colors.rows.even = ymlConfig.UString("colors.rows.even", "white")
|
|
||||||
settings.colors.rows.odd = ymlConfig.UString("colors.rows.odd", "blue")
|
|
||||||
|
|
||||||
return &settings
|
return &settings
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user