summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--draw.go48
-rw-r--r--settings.go22
-rw-r--r--structs.go18
3 files changed, 53 insertions, 35 deletions
diff --git a/draw.go b/draw.go
index 9574934..a2ab2fc 100644
--- a/draw.go
+++ b/draw.go
@@ -1,9 +1,9 @@
package logsettings
-import (
- "go.wit.com/log"
+import (
"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
@@ -12,18 +12,24 @@ import (
// this is a test commit to tag this as v0.10
func (d *LogSettings) Show() {
- if ! d.Ready() { return }
+ if !d.Ready() {
+ return
+ }
d.win.Show()
}
func (d *LogSettings) Hide() {
- if ! d.Ready() { return }
+ if !d.Ready() {
+ return
+ }
d.win.Hide()
}
// alternates between showing and hiding the window
func (d *LogSettings) Toggle() {
- if ! d.Ready() { return }
+ if !d.Ready() {
+ return
+ }
d.win.Toggle()
}
@@ -37,11 +43,11 @@ func (d *LogSettings) draw() {
g = g.NewBox("bw vbox", false)
d.buttonG = g
- g.NewButton("Redirect STDOUT to /tmp/", func () {
+ g.NewButton("Redirect STDOUT to /tmp/", func() {
log.SetTmp()
})
- g.NewButton("restore defaults", func () {
+ g.NewButton("restore defaults", func() {
for _, wg := range myLogGui.groups {
for _, f := range wg.flags {
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 _, f := range wg.flags {
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 _, f := range wg.flags {
f.Set(false)
@@ -65,7 +71,7 @@ func (d *LogSettings) draw() {
}
})
- g.NewButton("Dump Flags", func () {
+ g.NewButton("Dump Flags", func() {
// ShowDebugValues()
log.ShowFlags()
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.flagG.NewBox("bw vbox", false)
- g.NewButton("Add all Flags", func () {
+ g.NewButton("Add all Flags", func() {
flags := log.ShowFlags()
for _, f := range flags {
addFlag(d.flagG, f)
}
})
- g.NewButton("Close", func () {
+ g.NewButton("Close", func() {
d.Hide()
})
@@ -98,8 +104,12 @@ func (d *LogSettings) draw() {
func addFlag(p *gui.Node, newf *log.LogFlag) {
var flagWidgets *flagGroup
- if newf == nil { return }
- if p == nil { return }
+ if newf == nil {
+ return
+ }
+ if p == nil {
+ return
+ }
subsys := newf.GetSubsystem()
name := newf.GetName()
@@ -127,11 +137,11 @@ func addFlag(p *gui.Node, newf *log.LogFlag) {
}
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
- group *gui.Node
- grid *gui.Node
+ parent *gui.Node // where to draw our group
+ group *gui.Node
+ grid *gui.Node
// the widget for each flag
flags []*gadgets.LogFlag
diff --git a/settings.go b/settings.go
index 2bc252a..776bd28 100644
--- a/settings.go
+++ b/settings.go
@@ -1,14 +1,16 @@
package logsettings
-import (
- "go.wit.com/log"
+import (
"go.wit.com/gui/gui"
+ "go.wit.com/log"
)
// This initializes the main object
// You can only have one of these
func New(p *gui.Node) *LogSettings {
- if myLogGui != nil {return myLogGui}
+ if myLogGui != nil {
+ return myLogGui
+ }
myLogGui = new(LogSettings)
myLogGui.parent = p
myLogGui.groups = make(map[string]*flagGroup)
@@ -19,16 +21,22 @@ func New(p *gui.Node) *LogSettings {
// 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) {
+ if d == nil {
+ return false
+ }
+ if !d.parent.Ready() {
+ return false
+ }
+ if d.win == nil {
d.draw()
}
return d.ready
}
func (d *LogSettings) Update() bool {
- if ! d.Ready() {return false}
+ if !d.Ready() {
+ return false
+ }
return true
}
diff --git a/structs.go b/structs.go
index 0637ac4..c06124f 100644
--- a/structs.go
+++ b/structs.go
@@ -1,22 +1,22 @@
package logsettings
-import (
+import (
"go.wit.com/gui/gui"
- "go.wit.com/gui/gadgets"
+ "go.wit.com/lib/gadgets"
)
var myLogGui *LogSettings
type LogSettings struct {
- ready bool
- hidden bool
- err error
+ ready bool
+ hidden bool
+ err error
groups map[string]*flagGroup
- parent *gui.Node // where to draw our window
- win *gadgets.BasicWindow // our window for displaying the log package settings
+ parent *gui.Node // where to draw our 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
+ buttonG *gui.Node // the group of buttons
+ flagG *gui.Node // the group of all the flag checkbox widgets
}