54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package tree
|
|
|
|
import (
|
|
"errors"
|
|
"sync"
|
|
|
|
"go.wit.com/log"
|
|
"go.wit.com/widget"
|
|
)
|
|
|
|
var muAction sync.Mutex
|
|
|
|
func (me *TreeInfo) catchActionChannel() {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
log.Warn(me.PluginName, "tree YAHOOOO Recovered in simpleStdin()", r)
|
|
me.SendToolkitPanic()
|
|
panic(-1)
|
|
}
|
|
}()
|
|
log.Log(TREE, "catchActionChannel() START")
|
|
for {
|
|
log.Log(TREE, "catchActionChannel() for loop")
|
|
select {
|
|
case a := <-me.pluginChan:
|
|
log.Verbose("catchActionChannel() on ", a.WidgetId, a.WidgetType, a.ProgName)
|
|
muAction.Lock()
|
|
if me.ActionFromChannel == nil {
|
|
log.Error(errors.New("toolkit ActionFromChannel == nil"), a.WidgetId, a.ActionType, a.WidgetType)
|
|
} else {
|
|
// send this to the toolkit
|
|
me.ActionFromChannel(a)
|
|
}
|
|
muAction.Unlock()
|
|
}
|
|
}
|
|
}
|
|
|
|
func New() *TreeInfo {
|
|
me := new(TreeInfo)
|
|
me.pluginChan = make(chan widget.Action, 1)
|
|
|
|
/*
|
|
full := "go.wit.com/gui"
|
|
short := "gui"
|
|
TREE = log.NewFlag("TREE", true, full, short, "treeRoot info")
|
|
*/
|
|
|
|
log.Log(TREE, "Init() start channel reciever")
|
|
go me.catchActionChannel()
|
|
log.Log(TREE, "Init() END")
|
|
return me
|
|
}
|