summaryrefslogtreecommitdiff
path: root/toolkit/andlabs/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2023-04-12 13:00:29 -0500
committerJeff Carr <[email protected]>2023-04-12 13:00:29 -0500
commit047cde4c9d68ea4ff87006448137e836ec9eb140 (patch)
treece3332991cf5ebd7761e9021f66db787abd25536 /toolkit/andlabs/main.go
parent982097557b2625cf04378cd7e7771122382d6de9 (diff)
better toolkit init options
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'toolkit/andlabs/main.go')
-rw-r--r--toolkit/andlabs/main.go17
1 files changed, 15 insertions, 2 deletions
diff --git a/toolkit/andlabs/main.go b/toolkit/andlabs/main.go
index e6befd2..5a99421 100644
--- a/toolkit/andlabs/main.go
+++ b/toolkit/andlabs/main.go
@@ -1,6 +1,7 @@
package main
import (
+ "sync"
"embed"
"git.wit.org/wit/gui/toolkit"
@@ -16,14 +17,20 @@ var res embed.FS
var pluginChan chan toolkit.Action
var uiMainUndef bool = true
+var uiMain sync.Once
+var muAction sync.Mutex
func catchActionChannel() {
log(logNow, "catchActionChannel() START")
for {
log(logNow, "catchActionChannel() for loop")
+ uiMain.Do(func() {
+ go ui.Main(demoUI)
+ })
select {
case a := <-pluginChan:
log(logNow, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name)
+ /*
// go Action(a)
if (uiMainUndef) {
log(logError,"catchActionChannel() main() was not run yet")
@@ -34,7 +41,7 @@ func catchActionChannel() {
log(logError,"catchActionChannel() ui.Main() START")
log(logError,"catchActionChannel() ui.Main() START")
sleep(1)
- go ui.Main(demoUI)
+ // go ui.Main(demoUI)
// go ui.Main( func() {
// rawAction(a)
// })
@@ -46,6 +53,12 @@ func catchActionChannel() {
rawAction(a)
log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
}
+ */
+ log(logNow, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
+ muAction.Lock()
+ rawAction(a)
+ muAction.Unlock()
+ log(logNow, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
}
}
}
@@ -90,7 +103,7 @@ func Init() {
setDefaultBehavior(true)
andlabs = make(map[int]*andlabsT)
- pluginChan = make(chan toolkit.Action)
+ pluginChan = make(chan toolkit.Action, 1)
log(logNow, "Init() start channel reciever")
go catchActionChannel()