summaryrefslogtreecommitdiff
path: root/andlabs/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-17 21:31:49 -0600
committerJeff Carr <[email protected]>2024-01-17 21:31:49 -0600
commit841e6252c95244f0ee7faf2c01d33f69a8ab483a (patch)
treeef400228622b87611168db2227269ba7fd56625d /andlabs/main.go
parentba95c13799740b5f55541fc5e8ab9f1d34f7e421 (diff)
common tree package for toolkitsv0.12.4
This update provides *lots* of toolkit updates. This will allow the next step of debugging the gocui toolkit to make it work again. There are new common routines for handling the plugin channel communication Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'andlabs/main.go')
-rw-r--r--andlabs/main.go49
1 files changed, 21 insertions, 28 deletions
diff --git a/andlabs/main.go b/andlabs/main.go
index 5a6d383..b1e0e47 100644
--- a/andlabs/main.go
+++ b/andlabs/main.go
@@ -2,8 +2,11 @@ package main
import (
"sync"
+ "runtime/debug"
+
"go.wit.com/log"
"go.wit.com/gui/widget"
+ "go.wit.com/gui/toolkits/tree"
"go.wit.com/dev/andlabs/ui"
// the _ means we only need this for the init()
@@ -17,7 +20,11 @@ var muAction sync.Mutex
func queueMain(currentA widget.Action) {
defer func() {
if r := recover(); r != nil {
- log.Warn("YAHOOOO Recovered in main application:", r)
+ log.Warn("YAHOOOO Recovered in queueMain() application:", r)
+ log.Println("Recovered from panic:", r)
+ log.Println("Stack trace:")
+ debug.PrintStack()
+ me.myTree.DoToolkitPanic()
}
}()
ui.QueueMain( func() {
@@ -25,29 +32,14 @@ func queueMain(currentA widget.Action) {
})
}
-func catchActionChannel() {
- log.Log(INFO, "catchActionChannel() START")
- for {
- log.Log(INFO, "catchActionChannel() for loop")
- select {
- case a := <-pluginChan:
- log.Log(INFO, "catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName)
- log.Log(INFO, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
- muAction.Lock()
- // TODO ui.QueueMain(f)
- // TODO ui.QueueMain( func() {rawAction(a)} )
- // rawAction(a)
- queueMain(a)
- muAction.Unlock()
- log.Log(INFO, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
- }
- }
-}
-
func guiMain() {
defer func() {
if r := recover(); r != nil {
- log.Warn("YAHOOOO Recovered in main application:", r)
+ log.Warn("YAHOOOO Recovered in guiMain application:", r)
+ log.Println("Recovered from panic:", r)
+ log.Println("Stack trace:")
+ debug.PrintStack()
+ me.myTree.DoToolkitPanic()
}
}()
ui.Main(func() {
@@ -55,6 +47,10 @@ func guiMain() {
})
}
+func Init() {
+ log.Warn("Init() TODO: move init() to here")
+}
+
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
func init() {
log.Log(INFO, "Init() START")
@@ -63,15 +59,12 @@ func init() {
// log.Log(INFO, "init() Setting defaultBehavior = true")
setDefaultBehavior(true)
+ me.myTree = tree.New()
+ me.myTree.PluginName = "andlabs"
+ me.myTree.ActionFromChannel = queueMain
+
// TODO: this is messed up. run ui.Main() from the first add? Initialize it with an empty thing first?
// fake out the OS toolkit by making a fake window. This is probably needed for macos & windows
// actually, this probably breaks the macos build
go guiMain()
-
- // andlabs = make(map[int]*andlabsT)
- pluginChan = make(chan widget.Action, 1)
-
- log.Log(INFO, "Init() start channel reciever")
- go catchActionChannel()
- log.Log(INFO, "Init() END")
}