debian/andlabs/main.go

71 lines
1.7 KiB
Go
Raw Normal View History

2024-01-01 16:11:54 -06:00
package main
import (
"sync"
"runtime/debug"
"go.wit.com/log"
"go.wit.com/gui/widget"
"go.wit.com/gui/toolkits/tree"
2024-01-01 16:11:54 -06:00
"go.wit.com/dev/andlabs/ui"
2024-01-01 16:11:54 -06:00
// the _ means we only need this for the init()
_ "go.wit.com/dev/andlabs/ui/winmanifest"
2024-01-01 16:11:54 -06:00
)
var uiMainUndef bool = true
var uiMain sync.Once
var muAction sync.Mutex
func queueMain(currentA widget.Action) {
defer func() {
if r := recover(); r != nil {
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() {
rawAction(&currentA)
})
}
func guiMain() {
defer func() {
if r := recover(); r != nil {
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() {
demoUI()
})
}
func Init() {
log.Warn("Init() TODO: move init() to here")
}
2024-01-01 16:11:54 -06:00
// 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")
log.Log(INFO, "Init()")
2024-01-01 16:11:54 -06:00
// Can you pass values to a plugin init() ? Otherwise, there is no way to safely print
// log.Log(INFO, "init() Setting defaultBehavior = true")
2024-01-01 16:11:54 -06:00
setDefaultBehavior(true)
me.myTree = tree.New()
me.myTree.PluginName = "andlabs"
me.myTree.ActionFromChannel = queueMain
2024-01-01 16:11:54 -06:00
// 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()
2024-01-01 16:11:54 -06:00
}