summaryrefslogtreecommitdiff
path: root/nocui/main.go
blob: 363c8931e52bf185a77d15148db5ad208ba43948 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main

import (
	"sync"
	"go.wit.com/log"
	"go.wit.com/gui/widget"
)

var muAction sync.Mutex

func catchActionChannel() {
	log.Log(NOW, "catchActionChannel() START")
	for {
		log.Log(NOW, "catchActionChannel() for loop")
	    	select {
		case a := <-pluginChan:
			log.Log(NOW, "catchActionChannel() SELECT widget id =", a.WidgetId, a.Name)
			log.Log(NOW, "catchActionChannel() STUFF", a.WidgetId, a.ActionType, a.WidgetType)
			muAction.Lock()
			doAction(&a)
			muAction.Unlock()
			log.Log(NOW, "catchActionChannel() STUFF END", a.WidgetId, a.ActionType, a.WidgetType)
		}
	}
}

/*
// 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) {
	callback = guiCallback
}

func PluginChannel() chan widget.Action {
	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()")

	// andlabs = make(map[int]*andlabsT)
	pluginChan = make(chan widget.Action, 1)

	log.Log(NOW, "Init() start channel reciever")
	go catchActionChannel()
	go simpleStdin()
	log.Log(NOW, "Init() END")
}