summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugin.go19
-rw-r--r--structs.go1
2 files changed, 20 insertions, 0 deletions
diff --git a/plugin.go b/plugin.go
index 61ae47f..426e500 100644
--- a/plugin.go
+++ b/plugin.go
@@ -9,6 +9,8 @@ package tree
*/
import (
+ "time"
+
"go.wit.com/widget"
)
@@ -36,6 +38,21 @@ func (n *Node) FindWidgetId(id int) *Node {
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
//
// 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
}
+// this is the function that receives things from the application
func (me *TreeInfo) PluginChannel() chan widget.Action {
+ me.waitOK()
return me.pluginChan
}
diff --git a/structs.go b/structs.go
index c4792b7..6b7516d 100644
--- a/structs.go
+++ b/structs.go
@@ -17,6 +17,7 @@ import (
var treeRoot *Node
type TreeInfo struct {
+ ok bool // indicates the plugin actually initialized
PluginName string // used to identify the plugin
config *ToolkitConfigs // protobuf of plugin settings
callback chan widget.Action // mouse clicks or keyboard events back to the program