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

Don't display disabled widgets

This commit is contained in:
Chris Cummer
2018-04-07 14:36:13 -07:00
committed by Chris Cummer
parent ae13d52665
commit 79bc8216d6
13 changed files with 61 additions and 22 deletions

11
wtf/text_viewer.go Normal file
View File

@@ -0,0 +1,11 @@
package wtf
import (
"github.com/rivo/tview"
)
type TextViewer interface {
Disabled() bool
Enabled() bool
TextView() *tview.TextView
}

View File

@@ -18,7 +18,8 @@ type Position struct {
}
type TextWidget struct {
Enabled bool
enabled bool
Name string
Position Position
RefreshedAt time.Time
@@ -28,7 +29,7 @@ type TextWidget struct {
func NewTextWidget(name string, configKey string) TextWidget {
widget := TextWidget{
Enabled: Config.UBool(fmt.Sprintf("wtf.%s.enabled", configKey), false),
enabled: Config.UBool(fmt.Sprintf("wtf.%s.enabled", configKey), false),
Name: name,
RefreshInt: Config.UInt(fmt.Sprintf("wtf.%s.refreshInterval", configKey)),
}
@@ -38,6 +39,14 @@ func NewTextWidget(name string, configKey string) TextWidget {
/* -------------------- Exported Functions -------------------- */
func (widget *TextWidget) Disabled() bool {
return !widget.Enabled()
}
func (widget *TextWidget) Enabled() bool {
return widget.enabled
}
func (widget *TextWidget) RefreshInterval() int {
return widget.RefreshInt
}