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() {
|
||||
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
|
||||
if ! d.Ready() { return }
|
||||
d.win.Show()
|
||||
}
|
||||
|
||||
func (d *LogSettings) Hide() {
|
||||
if ! d.Ready() {
|
||||
log.Warn("LogSettings.Hide() window is not Ready()")
|
||||
return
|
||||
if ! d.Ready() { return }
|
||||
d.win.Hide()
|
||||
}
|
||||
log.Warn("LogSettings.Hide() window")
|
||||
d.window.Hide()
|
||||
d.hidden = true
|
||||
|
||||
// alternates between showing and hiding the window
|
||||
func (d *LogSettings) Toggle() {
|
||||
if ! d.Ready() { return }
|
||||
d.win.Toggle()
|
||||
}
|
||||
|
||||
// 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 g *gui.Node
|
||||
|
||||
d.window = d.parent.NewWindow("Debug Flags")
|
||||
d.window.Custom = d.parent.StandardClose
|
||||
d.win = gadgets.NewBasicWindow(d.parent, "Debug Flags")
|
||||
|
||||
d.box = d.window.NewBox("hBox", true)
|
||||
g = d.box.NewGroup("Show").Pad()
|
||||
g = d.win.Box().NewGroup("Show").Pad()
|
||||
d.buttonG = g
|
||||
|
||||
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 () {
|
||||
flags := log.ShowFlags()
|
||||
|
|
|
@ -11,21 +11,19 @@ func New(p *gui.Node) *LogSettings {
|
|||
if myLogGui != nil {return myLogGui}
|
||||
myLogGui = new(LogSettings)
|
||||
myLogGui.parent = p
|
||||
myLogGui.groups = make(map[string]*flagGroup)
|
||||
myLogGui.ready = true
|
||||
myLogGui.hidden = true
|
||||
myLogGui.groups = make(map[string]*flagGroup)
|
||||
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
|
||||
func (d *LogSettings) Ready() bool {
|
||||
if d == nil {return false}
|
||||
if ! d.parent.Ready() {return false}
|
||||
if (d.win == nil) {
|
||||
d.draw()
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ package logsettings
|
|||
|
||||
import (
|
||||
"go.wit.com/gui/gui"
|
||||
// "go.wit.com/gui/gadgets"
|
||||
"go.wit.com/gui/gadgets"
|
||||
)
|
||||
|
||||
var myLogGui *LogSettings
|
||||
|
@ -15,8 +15,7 @@ type LogSettings struct {
|
|||
groups map[string]*flagGroup
|
||||
|
||||
parent *gui.Node // where to draw our window
|
||||
window *gui.Node // our window for displaying the log package settings
|
||||
box *gui.Node // the first box in the window
|
||||
win *gadgets.BasicWindow // our window for displaying the log package settings
|
||||
|
||||
buttonG *gui.Node // the group of buttons
|
||||
flagG *gui.Node // the group of all the flag checkbox widgets
|
||||
|
|
Loading…
Reference in New Issue