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:
parent
ae13d52665
commit
79bc8216d6
@ -29,7 +29,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ func NewWidget() *Widget {
|
||||
/* -------------------- Exported Functions -------------------- */
|
||||
|
||||
func (widget *Widget) Refresh() {
|
||||
if widget.Enabled == false {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
|
39
wtf.go
39
wtf.go
@ -32,6 +32,14 @@ func refresher(stat *status.Widget, app *tview.Application) {
|
||||
}
|
||||
}
|
||||
|
||||
func addToApp(grid *tview.Grid, widget wtf.TextViewer) {
|
||||
if widget.Disabled() {
|
||||
return
|
||||
}
|
||||
|
||||
grid.AddItem(widget.TextView(), 0, 0, 2, 1, 0, 0, false)
|
||||
}
|
||||
|
||||
var result = wtf.CreateConfigDir()
|
||||
var Config = wtf.LoadConfigFile()
|
||||
|
||||
@ -85,16 +93,27 @@ func main() {
|
||||
grid.SetColumns(37, 37, 37, 37, 37) // How _wide_ the column is, in terminal columns
|
||||
grid.SetBorder(false)
|
||||
|
||||
grid.AddItem(bamboo.View, 0, 0, 2, 1, 0, 0, false)
|
||||
grid.AddItem(cal.View, 2, 1, 4, 1, 0, 0, false)
|
||||
grid.AddItem(git.View, 0, 2, 2, 3, 0, 0, false)
|
||||
grid.AddItem(github.View, 2, 2, 2, 3, 0, 0, false)
|
||||
grid.AddItem(newrelic.View, 4, 2, 1, 3, 0, 0, false)
|
||||
grid.AddItem(weather.View, 0, 1, 1, 1, 0, 0, false)
|
||||
grid.AddItem(sec.View, 5, 0, 1, 1, 0, 0, false)
|
||||
grid.AddItem(opsgenie.View, 2, 0, 2, 1, 0, 0, false)
|
||||
grid.AddItem(jira.View, 1, 1, 1, 1, 0, 0, false)
|
||||
grid.AddItem(stat.View, 5, 2, 3, 3, 0, 0, false)
|
||||
addToApp(grid, bamboo)
|
||||
addToApp(grid, cal)
|
||||
addToApp(grid, git)
|
||||
addToApp(grid, github)
|
||||
addToApp(grid, newrelic)
|
||||
addToApp(grid, weather)
|
||||
addToApp(grid, sec)
|
||||
addToApp(grid, opsgenie)
|
||||
addToApp(grid, jira)
|
||||
addToApp(grid, stat)
|
||||
|
||||
//grid.AddItem(bamboo.View, 0, 0, 2, 1, 0, 0, false)
|
||||
//grid.AddItem(cal.View, 2, 1, 4, 1, 0, 0, false)
|
||||
//grid.AddItem(git.View, 0, 2, 2, 3, 0, 0, false)
|
||||
//grid.AddItem(github.View, 2, 2, 2, 3, 0, 0, false)
|
||||
//grid.AddItem(newrelic.View, 4, 2, 1, 3, 0, 0, false)
|
||||
//grid.AddItem(weather.View, 0, 1, 1, 1, 0, 0, false)
|
||||
//grid.AddItem(sec.View, 5, 0, 1, 1, 0, 0, false)
|
||||
//grid.AddItem(opsgenie.View, 2, 0, 2, 1, 0, 0, false)
|
||||
//grid.AddItem(jira.View, 1, 1, 1, 1, 0, 0, false)
|
||||
//grid.AddItem(stat.View, 5, 2, 3, 3, 0, 0, false)
|
||||
|
||||
app := tview.NewApplication()
|
||||
|
||||
|
11
wtf/text_viewer.go
Normal file
11
wtf/text_viewer.go
Normal file
@ -0,0 +1,11 @@
|
||||
package wtf
|
||||
|
||||
import (
|
||||
"github.com/rivo/tview"
|
||||
)
|
||||
|
||||
type TextViewer interface {
|
||||
Disabled() bool
|
||||
Enabled() bool
|
||||
TextView() *tview.TextView
|
||||
}
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user