initOnce()
This commit is contained in:
parent
db0986fa06
commit
827a258a86
19
plugin.go
19
plugin.go
|
@ -9,6 +9,8 @@ package tree
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/widget"
|
"go.wit.com/widget"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,6 +38,21 @@ func (n *Node) FindWidgetId(id int) *Node {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (me *TreeInfo) InitOK() {
|
||||||
|
me.ok = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// this hack is to wait for the application to send something
|
||||||
|
// before trying to do anything. todo: rethink this someday
|
||||||
|
func (me *TreeInfo) waitOK() {
|
||||||
|
for {
|
||||||
|
if me.ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Other goroutines must use this to access the GUI
|
// Other goroutines must use this to access the GUI
|
||||||
//
|
//
|
||||||
// You can not acess / process the GUI thread directly from
|
// You can not acess / process the GUI thread directly from
|
||||||
|
@ -47,6 +64,8 @@ func (me *TreeInfo) Callback(guiCallback chan widget.Action) {
|
||||||
me.callback = guiCallback
|
me.callback = guiCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is the function that receives things from the application
|
||||||
func (me *TreeInfo) PluginChannel() chan widget.Action {
|
func (me *TreeInfo) PluginChannel() chan widget.Action {
|
||||||
|
me.waitOK()
|
||||||
return me.pluginChan
|
return me.pluginChan
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ import (
|
||||||
var treeRoot *Node
|
var treeRoot *Node
|
||||||
|
|
||||||
type TreeInfo struct {
|
type TreeInfo struct {
|
||||||
|
ok bool // indicates the plugin actually initialized
|
||||||
PluginName string // used to identify the plugin
|
PluginName string // used to identify the plugin
|
||||||
config *ToolkitConfigs // protobuf of plugin settings
|
config *ToolkitConfigs // protobuf of plugin settings
|
||||||
callback chan widget.Action // mouse clicks or keyboard events back to the program
|
callback chan widget.Action // mouse clicks or keyboard events back to the program
|
||||||
|
|
Loading…
Reference in New Issue