forked from xilp/systray
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtray.go
executable file
·48 lines (40 loc) · 1.03 KB
/
tray.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
package systray
import "runtime"
type Systray struct {
// platform-specific implementation
systrayer
}
// systrayer interface represents the public
// and private interface needed for a platform
// specific systray implementation
type systrayer interface {
Show(file, hint string) error
Stop() error
SetIcon(file string) error
SetTooltip(tooltip string) error
SetVisible(visible bool) error
Run() error
OnClick(fun func())
ClearSystrayMenuItems()
AddSystrayMenuItems(items []CallbackInfo)
// destroy gives implementation a chance to
// clean up resources
destroy()
}
func New(iconPath string, clientPath string) *Systray {
// Wrap the platform-specific implementation in a
// public concrete type
st := &Systray{_NewSystray(iconPath, clientPath)}
// Track the cleanup of the public Systray instance,
// so that we can decref the wrapped private instance
runtime.SetFinalizer(st, func(ptr *Systray) {
ptr.destroy()
})
return st
}
type CallbackInfo struct {
ItemName string
Callback func()
Disabled bool
Checked bool
}