2024-01-04 12:23:36 -06:00
|
|
|
/*
|
2024-01-18 05:04:18 -06:00
|
|
|
A log.Flag
|
2024-01-04 12:23:36 -06:00
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
-----------------------------------------------
|
|
|
|
| | |
|
|
|
|
| [ X ] | INFO (controls log.Info() |
|
|
|
|
| | |
|
|
|
|
-----------------------------------------------
|
2024-01-04 12:23:36 -06:00
|
|
|
*/
|
|
|
|
package gadgets
|
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
import (
|
|
|
|
"go.wit.com/gui"
|
2024-01-04 12:23:36 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
type LogFlag struct {
|
2024-01-18 05:04:18 -06:00
|
|
|
p *gui.Node // parent widget
|
|
|
|
c *gui.Node // checkbox widget
|
|
|
|
lf *log.LogFlag
|
2024-01-04 12:23:36 -06:00
|
|
|
|
2024-01-18 05:04:18 -06:00
|
|
|
Name string
|
2024-01-04 14:41:37 -06:00
|
|
|
Subsystem string
|
2024-01-18 05:04:18 -06:00
|
|
|
Desc string
|
|
|
|
Default bool
|
|
|
|
b bool
|
2024-01-04 12:23:36 -06:00
|
|
|
|
|
|
|
Custom func()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *LogFlag) Get() bool {
|
2024-01-08 22:33:55 -06:00
|
|
|
return f.lf.Get()
|
2024-01-04 12:23:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *LogFlag) Set(b bool) {
|
2024-01-04 15:14:37 -06:00
|
|
|
log.Info("LogFlag.Set() =", b)
|
2024-01-08 22:33:55 -06:00
|
|
|
f.lf.Set(b)
|
2024-01-19 12:21:04 -06:00
|
|
|
f.c.SetChecked(b)
|
2024-01-04 15:14:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *LogFlag) SetDefault() {
|
|
|
|
log.Info("LogFlag.SetDefault() =", f.Default)
|
2024-01-08 22:33:55 -06:00
|
|
|
f.lf.SetDefault()
|
2024-01-19 12:21:04 -06:00
|
|
|
f.c.SetChecked(f.lf.Get())
|
2024-01-04 12:23:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewLogFlag(n *gui.Node, lf *log.LogFlag) *LogFlag {
|
2024-01-18 05:04:18 -06:00
|
|
|
f := LogFlag{
|
2024-01-04 12:23:36 -06:00
|
|
|
p: n,
|
|
|
|
}
|
2024-01-08 22:33:55 -06:00
|
|
|
f.Name = lf.GetName()
|
|
|
|
f.Subsystem = lf.GetSubsystem()
|
|
|
|
f.Desc = lf.GetDesc()
|
2024-01-04 12:23:36 -06:00
|
|
|
|
|
|
|
// various timeout settings
|
2024-01-04 14:41:37 -06:00
|
|
|
f.c = n.NewCheckbox(f.Name + ": " + f.Desc)
|
2024-01-04 12:23:36 -06:00
|
|
|
f.c.Custom = func() {
|
2024-01-17 21:46:50 -06:00
|
|
|
f.lf.Set(f.c.Bool())
|
2024-01-09 07:47:26 -06:00
|
|
|
log.Info("LogFlag.Custom() user changed value to =", f.lf.Get())
|
2024-01-04 12:23:36 -06:00
|
|
|
}
|
2024-01-19 12:21:04 -06:00
|
|
|
f.c.SetChecked(lf.Get())
|
2024-01-04 12:23:36 -06:00
|
|
|
|
|
|
|
return &f
|
|
|
|
}
|