fix paths

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 01:34:00 -06:00
parent b0ddd6af21
commit f3da30a919
3 changed files with 53 additions and 35 deletions

48
draw.go
View File

@ -1,9 +1,9 @@
package logsettings package logsettings
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/log"
) )
// TODO: make sure this works without needing to be shown // TODO: make sure this works without needing to be shown
@ -12,18 +12,24 @@ import (
// this is a test commit to tag this as v0.10 // this is a test commit to tag this as v0.10
func (d *LogSettings) Show() { func (d *LogSettings) Show() {
if ! d.Ready() { return } if !d.Ready() {
return
}
d.win.Show() d.win.Show()
} }
func (d *LogSettings) Hide() { func (d *LogSettings) Hide() {
if ! d.Ready() { return } if !d.Ready() {
return
}
d.win.Hide() d.win.Hide()
} }
// alternates between showing and hiding the window // alternates between showing and hiding the window
func (d *LogSettings) Toggle() { func (d *LogSettings) Toggle() {
if ! d.Ready() { return } if !d.Ready() {
return
}
d.win.Toggle() d.win.Toggle()
} }
@ -37,11 +43,11 @@ func (d *LogSettings) draw() {
g = g.NewBox("bw vbox", false) g = g.NewBox("bw vbox", false)
d.buttonG = g d.buttonG = g
g.NewButton("Redirect STDOUT to /tmp/", func () { g.NewButton("Redirect STDOUT to /tmp/", func() {
log.SetTmp() log.SetTmp()
}) })
g.NewButton("restore defaults", func () { g.NewButton("restore defaults", func() {
for _, wg := range myLogGui.groups { for _, wg := range myLogGui.groups {
for _, f := range wg.flags { for _, f := range wg.flags {
f.SetDefault() f.SetDefault()
@ -49,7 +55,7 @@ func (d *LogSettings) draw() {
} }
}) })
g.NewButton("all on", func () { g.NewButton("all on", func() {
for _, wg := range myLogGui.groups { for _, wg := range myLogGui.groups {
for _, f := range wg.flags { for _, f := range wg.flags {
f.Set(true) f.Set(true)
@ -57,7 +63,7 @@ func (d *LogSettings) draw() {
} }
}) })
g.NewButton("all off", func () { g.NewButton("all off", func() {
for _, wg := range myLogGui.groups { for _, wg := range myLogGui.groups {
for _, f := range wg.flags { for _, f := range wg.flags {
f.Set(false) f.Set(false)
@ -65,7 +71,7 @@ func (d *LogSettings) draw() {
} }
}) })
g.NewButton("Dump Flags", func () { g.NewButton("Dump Flags", func() {
// ShowDebugValues() // ShowDebugValues()
log.ShowFlags() log.ShowFlags()
for s, wg := range myLogGui.groups { for s, wg := range myLogGui.groups {
@ -79,14 +85,14 @@ func (d *LogSettings) draw() {
d.flagG = d.win.Box().NewGroup("Subsystem (aka package)") d.flagG = d.win.Box().NewGroup("Subsystem (aka package)")
d.flagG = d.flagG.NewBox("bw vbox", false) d.flagG = d.flagG.NewBox("bw vbox", false)
g.NewButton("Add all Flags", func () { g.NewButton("Add all Flags", func() {
flags := log.ShowFlags() flags := log.ShowFlags()
for _, f := range flags { for _, f := range flags {
addFlag(d.flagG, f) addFlag(d.flagG, f)
} }
}) })
g.NewButton("Close", func () { g.NewButton("Close", func() {
d.Hide() d.Hide()
}) })
@ -98,8 +104,12 @@ func (d *LogSettings) draw() {
func addFlag(p *gui.Node, newf *log.LogFlag) { func addFlag(p *gui.Node, newf *log.LogFlag) {
var flagWidgets *flagGroup var flagWidgets *flagGroup
if newf == nil { return } if newf == nil {
if p == nil { return } return
}
if p == nil {
return
}
subsys := newf.GetSubsystem() subsys := newf.GetSubsystem()
name := newf.GetName() name := newf.GetName()
@ -127,11 +137,11 @@ func addFlag(p *gui.Node, newf *log.LogFlag) {
} }
type flagGroup struct { type flagGroup struct {
name string // should be set to the flag.Subsystem name string // should be set to the flag.Subsystem
parent *gui.Node // where to draw our group parent *gui.Node // where to draw our group
group *gui.Node group *gui.Node
grid *gui.Node grid *gui.Node
// the widget for each flag // the widget for each flag
flags []*gadgets.LogFlag flags []*gadgets.LogFlag

View File

@ -1,14 +1,16 @@
package logsettings package logsettings
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/log"
) )
// This initializes the main object // This initializes the main object
// You can only have one of these // You can only have one of these
func New(p *gui.Node) *LogSettings { 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.groups = make(map[string]*flagGroup)
@ -19,16 +21,22 @@ func New(p *gui.Node) *LogSettings {
// 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 {
if ! d.parent.Ready() {return false} return false
if (d.win == nil) { }
if !d.parent.Ready() {
return false
}
if d.win == nil {
d.draw() d.draw()
} }
return d.ready return d.ready
} }
func (d *LogSettings) Update() bool { func (d *LogSettings) Update() bool {
if ! d.Ready() {return false} if !d.Ready() {
return false
}
return true return true
} }

View File

@ -1,22 +1,22 @@
package logsettings package logsettings
import ( import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
) )
var myLogGui *LogSettings var myLogGui *LogSettings
type LogSettings struct { type LogSettings struct {
ready bool ready bool
hidden bool hidden bool
err error err error
groups map[string]*flagGroup groups map[string]*flagGroup
parent *gui.Node // where to draw our window parent *gui.Node // where to draw our window
win *gadgets.BasicWindow // our window for displaying the log package settings win *gadgets.BasicWindow // our window for displaying the log package settings
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
} }