-
Notifications
You must be signed in to change notification settings - Fork 1
/
systray.go
58 lines (53 loc) · 1.3 KB
/
systray.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
47
48
49
50
51
52
53
54
55
56
57
58
package main
import (
_ "embed"
ui "github.com/malivvan/webkitgtk"
)
//go:embed icon.png
var icon []byte
func main() {
app := ui.New(ui.AppOptions{
ID: "com.github.malivvan.webkitgtk.examples.systray",
Name: "WebKitGTK Systray Example",
Hold: true,
})
menu := app.Menu(icon)
menu.Add("open").OnClick(func(checked bool) {
app.Open(ui.WindowOptions{
Title: "tray",
Width: 160,
Height: 60,
HTML: `<doctype html>
<html>
<body>
Tray Example
</body>
</html>`,
})
})
submenu := menu.AddSubmenu("submenu")
radio1 := submenu.AddRadio("radio 1", true).SetIcon(icon).OnClick(func(checked bool) {
println("radio 1", checked)
})
radio2 := submenu.AddRadio("radio 2", false).SetIcon(icon).OnClick(func(checked bool) {
println("radio 2", checked)
})
menu.AddSeparator()
menu.AddCheckbox("enable submenu items", true).SetIcon(icon).OnClick(func(checked bool) {
println("enable submenu items", checked)
radio1.SetDisabled(!checked)
radio2.SetDisabled(!checked)
})
menu.AddCheckbox("show submenu", true).SetIcon(icon).OnClick(func(checked bool) {
println("show submenu", checked)
submenu.Item().SetHidden(!checked)
})
menu.AddSeparator()
menu.Add("quit").OnClick(func(checked bool) {
println("quit")
app.Quit()
})
if err := app.Run(); err != nil {
panic(err)
}
}