diff --git a/common.go b/common.go index cdc560d..3a8874a 100644 --- a/common.go +++ b/common.go @@ -57,13 +57,13 @@ func (n *Node) Hidden() bool { } /* avoid this function name as confusing -func (n *Node) GetText() string { +func (n *Node) GetText() string { // BAD return widget.GetString(n.State.Value) } */ /* -func (n *Node) SetValue(a any) { +func (n *Node) SetValue(a any) { // BAD n.State.Value = a } */ diff --git a/debug.go b/debug.go index 86fa7ce..b89aa80 100644 --- a/debug.go +++ b/debug.go @@ -1,6 +1,8 @@ package tree import ( + "fmt" + "go.wit.com/log" "go.wit.com/widget" ) @@ -20,7 +22,24 @@ func (n *Node) ShowButtons() { } func (n *Node) DumpWidget(pad string) { - log.Log(TREEWARN, "node:", pad, n.WidgetId, ",", n.WidgetType, ",", n.GetProgName()) + s := n.GetProgName() + if s == "" { + s = n.CurrentS() + } + if s == "" { + s = n.String() + } + if s == "" { + s = n.ProgName() + } + if s == "" { + s = n.GetLabel() + } + if s == "" { + s = n.State.NewString + } + end := fmt.Sprintf("%d,%-9s .%s.", n.WidgetId, n.WidgetType, s) + log.Log(TREEWARN, "node:", pad, end) } var depth int = 0 diff --git a/init.go b/init.go index 3ea2372..f87bbb5 100644 --- a/init.go +++ b/init.go @@ -1,7 +1,10 @@ +// Although most code from WIT.COM Inc is under the GPL +// This code is more generic because it must be able +// to be used in any GUI plugin + package tree import ( - "errors" "os" "runtime/debug" "sync" @@ -80,8 +83,8 @@ func (me *TreeInfo) newAction(a widget.Action) { func (me *TreeInfo) catchActionChannel() { defer func() { if r := recover(); r != nil { - log.Log(TREEWARN, "YAHOOOO Recovered in tree.catchActionChannel()", r) - log.Log(TREEWARN, "YAHOOOO Recovered in tree.catchActionChannel() Plugin:", me.PluginName) + log.Log(TREEWARN, "YAHOOOO. Recovered in tree.catchActionChannel()", r) + log.Log(TREEWARN, "YAHOOOO. Recovered in tree.catchActionChannel() Plugin:", me.PluginName) me.SendToolkitPanic() debug.PrintStack() me.ToolkitClose() @@ -97,13 +100,7 @@ func (me *TreeInfo) catchActionChannel() { case a := <-me.pluginChan: log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName) muAction.Lock() - if me.newAction == nil { - log.Error(errors.New("toolkit newAction == nil"), a.WidgetId, a.ActionType, a.WidgetType) - } else { - // send this to the toolkit - me.newAction(a) - // me.ActionFromChannel(a) - } + me.newAction(a) muAction.Unlock() } } diff --git a/structs.go b/structs.go index 17c10bc..a3b9a63 100644 --- a/structs.go +++ b/structs.go @@ -10,6 +10,8 @@ import ( "go.wit.com/widget" ) +// TODO: use protocol buffers + // this is the root node of the binary tree // There is only one of these per application var treeRoot *Node