diff --git a/addNode.go b/addNode.go index 2db130c..5a17a25 100644 --- a/addNode.go +++ b/addNode.go @@ -23,9 +23,9 @@ func (me *TreeInfo) AddNode(a *widget.Action) *Node { } if me.treeRoot.FindWidgetId(a.WidgetId) != nil { - log.Warn("AddNode() WidgetId already exists", a.WidgetId) - log.Warn("probably this is a Show() / Hide() issue") - log.Warn("TODO: figure out what to do here") + log.Log(TREEWARN, "AddNode() WidgetId already exists", a.WidgetId) + log.Log(TREEWARN, "probably this is a Show() / Hide() issue") + log.Log(TREEWARN, "TODO: figure out what to do here") return me.treeRoot.FindWidgetId(a.WidgetId) } diff --git a/common.go b/common.go index 274877f..70a5d14 100644 --- a/common.go +++ b/common.go @@ -19,6 +19,10 @@ func (n *Node) Bool() bool { return false // widget.GetBool(n.State.Value) } +func (n *Node) CurrentS() string { + return n.State.CurrentS +} + func (n *Node) String() string { switch n.WidgetType { case widget.Button: diff --git a/debug.go b/debug.go index 1978d19..f14e94c 100644 --- a/debug.go +++ b/debug.go @@ -16,16 +16,16 @@ func (n *Node) ShowButtons() { } func (n *Node) DumpWidget(pad string) { - log.Warn("node:", pad, n.WidgetId, ",", n.WidgetType, ",", n.GetProgName()) + log.Log(TREEWARN, "node:", pad, n.WidgetId, ",", n.WidgetType, ",", n.GetProgName()) } var depth int = 0 func (n *Node) ListWidgets() { if n == nil { - log.Warn("ERRRORRRR: n == nil in ListWidgets()") - log.Warn("ERRRORRRR: n == nil in ListWidgets()") - log.Warn("ERRRORRRR: n == nil in ListWidgets()") + log.Log(TREEWARN, "ERRRORRRR: n == nil in ListWidgets()") + log.Log(TREEWARN, "ERRRORRRR: n == nil in ListWidgets()") + log.Log(TREEWARN, "ERRRORRRR: n == nil in ListWidgets()") return } diff --git a/event.go b/event.go index 294fc54..e5d0c1f 100644 --- a/event.go +++ b/event.go @@ -18,7 +18,7 @@ import ( func (me *TreeInfo) SendEnableDebugger() { if me.callback == nil { - log.Warn("SendEnableDebugger() callback == nil") + log.Log(TREEWARN, "SendEnableDebugger() callback == nil") return } var a widget.Action @@ -30,22 +30,22 @@ func (me *TreeInfo) SendEnableDebugger() { func (me *TreeInfo) SendToolkitLoad(s string) { if me.callback == nil { - log.Warn("SendToolkitLoad() callback == nil") + log.Log(TREEWARN, "SendToolkitLoad() callback == nil") return } var a widget.Action a.ActionType = widget.ToolkitLoad a.ProgName = me.PluginName a.Value = s - log.Warn("SendToolkitLoad() START: toolkit load", s) + log.Log(TREEWARN, "SendToolkitLoad() START: toolkit load", s) me.callback <- a - log.Warn("SendToolkitLoad() END: toolkit load", s) + log.Log(TREEWARN, "SendToolkitLoad() END: toolkit load", s) return } func (me *TreeInfo) SendToolkitPanic() { if me.callback == nil { - log.Warn("SendToolkitPanic() callback == nil") + log.Log(TREEWARN, "SendToolkitPanic() callback == nil") return } var a widget.Action @@ -59,7 +59,7 @@ func (me *TreeInfo) SendToolkitPanic() { func (me *TreeInfo) SendWindowCloseEvent(n *Node) { if me.callback == nil { - log.Warn("SendWindowClose() callback == nil", n.WidgetId) + log.Log(TREEWARN, "SendWindowClose() callback == nil", n.WidgetId) return } var a widget.Action @@ -88,7 +88,7 @@ func (me *TreeInfo) SendFromUser(n *Node) { // Other goroutines must use this to access the GUI func (me *TreeInfo) SendUserEvent(n *Node) { if me.callback == nil { - log.Warn("SendUserEvent() callback == nil", n.WidgetId) + log.Log(TREEWARN, "SendUserEvent() callback == nil", n.WidgetId) return } var a widget.Action diff --git a/init.go b/init.go index c70b265..e307262 100644 --- a/init.go +++ b/init.go @@ -21,9 +21,9 @@ func (me *TreeInfo) newAction(a widget.Action) { return } case widget.SetText: - log.Info("tree.SetText() a.State.CurrentS =", a.State.CurrentS) - log.Info("tree.SetText() a.State.DefaultS =", a.State.DefaultS) - log.Info("tree.SetText() a.State.NewString =", a.State.NewString) + log.Log(TREE, "tree.SetText() a.State.CurrentS =", a.State.CurrentS) + log.Log(TREE, "tree.SetText() a.State.DefaultS =", a.State.DefaultS) + log.Log(TREE, "tree.SetText() a.State.NewString =", a.State.NewString) switch n.WidgetType { case widget.Dropdown: me.SetText(n, a.State.NewString) @@ -44,7 +44,14 @@ func (me *TreeInfo) newAction(a widget.Action) { case widget.Combobox: me.AddText(n, a.State.NewString) default: - log.Warn("AddText() not supported on widget", n.WidgetType, n.String()) + log.Log(TREEWARN, "AddText() not supported on widget", n.WidgetType, n.String()) + } + case widget.Checked: + switch n.WidgetType { + case widget.Checkbox: + me.SetChecked(n, a.State.Checked) + default: + log.Log(TREEWARN, "SetChecked() not supported on widget", n.WidgetType, n.String()) } default: me.NodeAction(n, a.ActionType) @@ -54,7 +61,7 @@ func (me *TreeInfo) newAction(a widget.Action) { func (me *TreeInfo) catchActionChannel() { defer func() { if r := recover(); r != nil { - log.Warn(me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r) + log.Log(TREEWARN, me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r) me.SendToolkitPanic() panic(-1) } diff --git a/json.go b/json.go index 5a52334..095e159 100644 --- a/json.go +++ b/json.go @@ -51,7 +51,7 @@ func (n *Node) Json() []string { case widget.Window: tmp := fmt.Sprint("{ WidgetType :", n.WidgetType, "}") all = append(all, tmp) - log.Warn(tmp) + log.Log(TREEWARN, tmp) return all default: log.Log(TREE, "doUserEvent() type =", n.WidgetType) diff --git a/structs.go b/structs.go index e807e0d..f96158d 100644 --- a/structs.go +++ b/structs.go @@ -30,6 +30,7 @@ type TreeInfo struct { SetText func(*Node, string) SetTitle func(*Node, string) SetLabel func(*Node, string) + SetChecked func(*Node, bool) } type Node struct {