diff options
Diffstat (limited to 'logsettings')
| -rw-r--r-- | logsettings/draw.go | 74 | ||||
| -rw-r--r-- | logsettings/settings.go | 45 | ||||
| -rw-r--r-- | logsettings/structs.go | 23 |
3 files changed, 142 insertions, 0 deletions
diff --git a/logsettings/draw.go b/logsettings/draw.go new file mode 100644 index 0000000..f125f1b --- /dev/null +++ b/logsettings/draw.go @@ -0,0 +1,74 @@ +package logsettings + +import ( + "go.wit.com/log" + "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" +) + +func (d *LogSettings) Show() { + if ! d.Ready() { + log.Warn("LogSettings.Show() window is not Ready()") + return + } + log.Warn("LogSettings.Show() window") + if d.hidden { + log.Warn("LogSettings.Show() window HERE window =", d.window) + if d.window == nil { + log.Warn("LogSettings.Show() create the window") + d.draw() + } + d.window.Show() + } + d.hidden = false +} + +func (d *LogSettings) Hide() { + if ! d.Ready() { + log.Warn("LogSettings.Show() window is not Ready()") + return + } + log.Warn("LogSettings.Hide() window") + if ! d.hidden { + d.window.Hide() + } + d.hidden = true +} + +// Let's you toggle on and off the various types of debugging output +// These checkboxes should be in the same order as the are printed +func (d *LogSettings) draw() { + if ! d.Ready() {return} + var newW, newB, g *gui.Node + + newW = d.parent.NewWindow("Debug Flags") + newW.Custom = d.parent.StandardClose + + newB = newW.NewBox("hBox", true) + g = newB.NewGroup("Show").Pad() + + g.NewButton("log.SetTmp()", func () { + log.SetTmp() + }) + + g.NewButton("log.SetAll(true)", func () { + log.SetAll(true) + }) + + g.NewButton("log.SetAll(false)", func () { + log.SetAll(false) + }) + + g.NewButton("Dump Flags", func () { + // ShowDebugValues() + log.ShowFlags() + }) + + g = newB.NewGroup("List") + g = g.NewGrid("flags grid", 5, 2) + flags := log.ShowFlags() + for _, f := range flags { + log.Log(true, "Get() ", "(" + f.Subsystem + ")", f.Name, "=", f.B, ":", f.Desc) + gadgets.NewLogFlag(g, f) + } +} diff --git a/logsettings/settings.go b/logsettings/settings.go new file mode 100644 index 0000000..417673d --- /dev/null +++ b/logsettings/settings.go @@ -0,0 +1,45 @@ +package logsettings + +import ( + "go.wit.com/log" + "go.wit.com/gui/gui" +) + +// This initializes the main object +// You can only have one of these +func New(p *gui.Node) *LogSettings { + if myLogGui != nil {return myLogGui} + myLogGui = new(LogSettings) + myLogGui.parent = p + myLogGui.ready = true + myLogGui.hidden = false + return myLogGui +} + +func (ls *LogSettings) Set(b bool) { + // log.Set(ls.name, b) + log.Warn("log.Set() FIXME: not working here anymore") + ls.checkbox.Set(b) +} + +// Returns true if the status is valid +func (d *LogSettings) Ready() bool { + if d == nil {return false} + if ! d.parent.Ready() {return false} + return d.ready +} + +func (d *LogSettings) Update() bool { + if ! d.Ready() {return false} + return true +} + +func (d *LogSettings) ShowFlags() { + log.ShowFlags() + return +} + +func (d *LogSettings) SetAll(b bool) { + log.SetAll(b) + return +} diff --git a/logsettings/structs.go b/logsettings/structs.go new file mode 100644 index 0000000..3df504b --- /dev/null +++ b/logsettings/structs.go @@ -0,0 +1,23 @@ +package logsettings + +import ( + "go.wit.com/gui/gui" + "go.wit.com/gui/gadgets" +) + +var myLogGui *LogSettings + +type LogSettings struct { + ready bool + hidden bool + err error + + parent *gui.Node // where to draw our window + window *gui.Node // our window for displaying the log package settings + + // Primary Directives + status *gadgets.OneLiner + summary *gadgets.OneLiner + + checkbox *gadgets.LogFlag +} |
