switch log to BasicWindow()
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
54b576b69d
commit
d69a41a295
|
@ -0,0 +1,64 @@
|
||||||
|
/*
|
||||||
|
A Standard Window
|
||||||
|
*/
|
||||||
|
package gadgets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
"go.wit.com/gui/gui"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BasicWindow struct {
|
||||||
|
hidden bool
|
||||||
|
name string
|
||||||
|
|
||||||
|
p *gui.Node // parent widget
|
||||||
|
win *gui.Node // window widget
|
||||||
|
box *gui.Node // box
|
||||||
|
|
||||||
|
Custom func()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *BasicWindow) Hide() {
|
||||||
|
w.win.Hide()
|
||||||
|
w.hidden = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *BasicWindow) Show() {
|
||||||
|
w.win.Show()
|
||||||
|
w.hidden = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *BasicWindow) Toggle() {
|
||||||
|
if w.hidden {
|
||||||
|
w.Show()
|
||||||
|
w.hidden = false
|
||||||
|
} else {
|
||||||
|
w.Hide()
|
||||||
|
w.hidden = true
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *BasicWindow) Box() *gui.Node {
|
||||||
|
return w.box
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBasicWindow(parent *gui.Node, name string) *BasicWindow {
|
||||||
|
var w *BasicWindow
|
||||||
|
w = &BasicWindow {
|
||||||
|
p: parent,
|
||||||
|
name: name,
|
||||||
|
}
|
||||||
|
|
||||||
|
// various timeout settings
|
||||||
|
w.win = w.p.NewWindow(name)
|
||||||
|
w.win.Custom = func() {
|
||||||
|
log.Println("BasicWindow.Custom() closed. TODO: handle this", w.name)
|
||||||
|
}
|
||||||
|
w.box = w.win.NewBox("hBox", true)
|
||||||
|
|
||||||
|
return w
|
||||||
|
}
|
|
@ -7,43 +7,29 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (d *LogSettings) Show() {
|
func (d *LogSettings) Show() {
|
||||||
if ! d.Ready() {
|
if ! d.Ready() { return }
|
||||||
log.Warn("LogSettings.Show() window is not Ready()")
|
d.win.Show()
|
||||||
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() {
|
func (d *LogSettings) Hide() {
|
||||||
if ! d.Ready() {
|
if ! d.Ready() { return }
|
||||||
log.Warn("LogSettings.Hide() window is not Ready()")
|
d.win.Hide()
|
||||||
return
|
}
|
||||||
}
|
|
||||||
log.Warn("LogSettings.Hide() window")
|
// alternates between showing and hiding the window
|
||||||
d.window.Hide()
|
func (d *LogSettings) Toggle() {
|
||||||
d.hidden = true
|
if ! d.Ready() { return }
|
||||||
|
d.win.Toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Let's you toggle on and off the various types of debugging output
|
// 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
|
// These checkboxes should be in the same order as the are printed
|
||||||
func (d *LogSettings) draw() {
|
func (d *LogSettings) draw() {
|
||||||
if ! d.Ready() {return}
|
|
||||||
var g *gui.Node
|
var g *gui.Node
|
||||||
|
|
||||||
d.window = d.parent.NewWindow("Debug Flags")
|
d.win = gadgets.NewBasicWindow(d.parent, "Debug Flags")
|
||||||
d.window.Custom = d.parent.StandardClose
|
|
||||||
|
|
||||||
d.box = d.window.NewBox("hBox", true)
|
g = d.win.Box().NewGroup("Show").Pad()
|
||||||
g = d.box.NewGroup("Show").Pad()
|
|
||||||
d.buttonG = g
|
d.buttonG = g
|
||||||
|
|
||||||
g.NewButton("Redirect STDOUT to /tmp/", func () {
|
g.NewButton("Redirect STDOUT to /tmp/", func () {
|
||||||
|
@ -85,7 +71,7 @@ func (d *LogSettings) draw() {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
d.flagG = d.box.NewGroup("Subsystem (aka package)")
|
d.flagG = d.win.Box().NewGroup("Subsystem (aka package)")
|
||||||
|
|
||||||
g.NewButton("Add all Flags", func () {
|
g.NewButton("Add all Flags", func () {
|
||||||
flags := log.ShowFlags()
|
flags := log.ShowFlags()
|
||||||
|
|
|
@ -11,21 +11,19 @@ func New(p *gui.Node) *LogSettings {
|
||||||
if myLogGui != nil {return myLogGui}
|
if myLogGui != nil {return myLogGui}
|
||||||
myLogGui = new(LogSettings)
|
myLogGui = new(LogSettings)
|
||||||
myLogGui.parent = p
|
myLogGui.parent = p
|
||||||
|
myLogGui.groups = make(map[string]*flagGroup)
|
||||||
myLogGui.ready = true
|
myLogGui.ready = true
|
||||||
myLogGui.hidden = true
|
myLogGui.hidden = true
|
||||||
myLogGui.groups = make(map[string]*flagGroup)
|
|
||||||
return myLogGui
|
return myLogGui
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls *LogSettings) Set(b bool) {
|
|
||||||
// log.Set(ls.name, b)
|
|
||||||
log.Warn("log.Set() FIXME: not working here anymore")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns true if the status is valid
|
// Returns true if the status is valid
|
||||||
func (d *LogSettings) Ready() bool {
|
func (d *LogSettings) Ready() bool {
|
||||||
if d == nil {return false}
|
if d == nil {return false}
|
||||||
if ! d.parent.Ready() {return false}
|
if ! d.parent.Ready() {return false}
|
||||||
|
if (d.win == nil) {
|
||||||
|
d.draw()
|
||||||
|
}
|
||||||
return d.ready
|
return d.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ package logsettings
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"go.wit.com/gui/gui"
|
"go.wit.com/gui/gui"
|
||||||
// "go.wit.com/gui/gadgets"
|
"go.wit.com/gui/gadgets"
|
||||||
)
|
)
|
||||||
|
|
||||||
var myLogGui *LogSettings
|
var myLogGui *LogSettings
|
||||||
|
@ -15,8 +15,7 @@ type LogSettings struct {
|
||||||
groups map[string]*flagGroup
|
groups map[string]*flagGroup
|
||||||
|
|
||||||
parent *gui.Node // where to draw our window
|
parent *gui.Node // where to draw our window
|
||||||
window *gui.Node // our window for displaying the log package settings
|
win *gadgets.BasicWindow // our window for displaying the log package settings
|
||||||
box *gui.Node // the first box in the window
|
|
||||||
|
|
||||||
buttonG *gui.Node // the group of buttons
|
buttonG *gui.Node // the group of buttons
|
||||||
flagG *gui.Node // the group of all the flag checkbox widgets
|
flagG *gui.Node // the group of all the flag checkbox widgets
|
||||||
|
|
Loading…
Reference in New Issue