diff options
Diffstat (limited to 'logsettings')
| -rw-r--r-- | logsettings/draw.go | 40 | ||||
| -rw-r--r-- | logsettings/settings.go | 10 | ||||
| -rw-r--r-- | logsettings/structs.go | 5 |
3 files changed, 19 insertions, 36 deletions
diff --git a/logsettings/draw.go b/logsettings/draw.go index 2bbed64..5321adc 100644 --- a/logsettings/draw.go +++ b/logsettings/draw.go @@ -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 - } - log.Warn("LogSettings.Hide() window") - d.window.Hide() - d.hidden = true + if ! d.Ready() { return } + d.win.Hide() +} + +// 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() diff --git a/logsettings/settings.go b/logsettings/settings.go index 4e95b7a..2bc252a 100644 --- a/logsettings/settings.go +++ b/logsettings/settings.go @@ -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 } diff --git a/logsettings/structs.go b/logsettings/structs.go index 35b24ca..0637ac4 100644 --- a/logsettings/structs.go +++ b/logsettings/structs.go @@ -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 |
