-
Notifications
You must be signed in to change notification settings - Fork 135
/
callbacks.go
46 lines (37 loc) · 957 Bytes
/
callbacks.go
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
package gallium
import (
"log"
"unsafe"
)
import "C"
// This file contains all Go functions that are exported to cgo. They
// are here because the presence of an export means that the C prelude
// gets copied into two locations.
//export cgo_onReady
func cgo_onReady(appId int) {
// do not actually call the user function from here because that would
// block the UI loop
apps.get(appId).ready <- struct{}{}
}
//export cgo_onMenuClicked
func cgo_onMenuClicked(data unsafe.Pointer) {
if menuMgr == nil {
log.Println("onMenuClicked called but menu manager was nil")
return
}
if data == nil {
log.Println("onMenuClicked called but data parameter was nil")
return
}
id := *(*int)(data)
item, found := menuMgr.items[id]
if !found {
log.Printf("onMenuClicked received non-existent ID %d", id)
return
}
if item.OnClick == nil {
log.Printf("onMenuClicked found %s but OnClick was nil", item.Title)
return
}
item.OnClick()
}