debian/nocui/main.go

56 lines
1.4 KiB
Go
Raw Normal View History

2024-01-01 16:11:54 -06:00
package main
import (
"sync"
"go.wit.com/log"
"go.wit.com/gui/widget"
2024-01-01 16:11:54 -06:00
)
var muAction sync.Mutex
func catchActionChannel() {
log.Log(NOW, "catchActionChannel() START")
2024-01-01 16:11:54 -06:00
for {
log.Log(NOW, "catchActionChannel() for loop")
2024-01-01 16:11:54 -06:00
select {
case a := <-pluginChan:
log.Log(NOW, "catchActionChannel() SELECT widget id =", a.WidgetId, a.ProgName)
log.Log(NOW, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
2024-01-01 16:11:54 -06:00
muAction.Lock()
doAction(&a)
muAction.Unlock()
log.Log(NOW, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
2024-01-01 16:11:54 -06:00
}
}
}
/*
// Other goroutines must use this to access the GUI
//
// You can not acess / process the GUI thread directly from
// other goroutines. This is due to the nature of how
// Linux, MacOS and Windows work (they all work differently. suprise. surprise.)
//
// this sets the channel to send user events back from the plugin
func Callback(guiCallback chan widget.Action) {
2024-01-01 16:11:54 -06:00
callback = guiCallback
}
func PluginChannel() chan widget.Action {
2024-01-01 16:11:54 -06:00
return pluginChan
}
*/
// This is important. This sets the defaults for the gui. Without this, there isn't correct padding, etc
func init() {
log.Log(INFO, "Init()")
2024-01-01 16:11:54 -06:00
// andlabs = make(map[int]*andlabsT)
pluginChan = make(chan widget.Action, 1)
2024-01-01 16:11:54 -06:00
log.Log(NOW, "Init() start channel reciever")
2024-01-01 16:11:54 -06:00
go catchActionChannel()
go simpleStdin()
log.Log(NOW, "Init() END")
2024-01-01 16:11:54 -06:00
}