aboutsummaryrefslogtreecommitdiffstats
path: root/systray_nonwindows.go
diff options
context:
space:
mode:
authorfffw2015-02-13 15:20:13 +0800
committerfffw2015-02-13 15:20:13 +0800
commitc00cfb38ee3aee8da409898fed17e80716095e89 (patch)
treee6997d1ab53bfb8e1dfeafec7e239f8cfbc35838 /systray_nonwindows.go
parent85d3e528d5a1d1ef8b60dcafc901c633343b4a37 (diff)
parent6a81309bde4a67b2d5d1cb57b2e89945ba63fde6 (diff)
downloadsystray-issue-2143-lib.tar.bz2
merge xcompileissue-2143-lib
Diffstat (limited to 'systray_nonwindows.go')
-rw-r--r--systray_nonwindows.go71
1 files changed, 71 insertions, 0 deletions
diff --git a/systray_nonwindows.go b/systray_nonwindows.go
new file mode 100644
index 0000000..f570b42
--- /dev/null
+++ b/systray_nonwindows.go
@@ -0,0 +1,71 @@
+// +build !windows
+
+package systray
+
+/*
+#cgo linux pkg-config: gtk+-3.0 appindicator3-0.1
+#cgo darwin CFLAGS: -DDARWIN -x objective-c -fobjc-arc
+#cgo darwin LDFLAGS: -framework Cocoa
+
+#include "systray.h"
+*/
+import "C"
+
+import (
+ "unsafe"
+)
+
+func nativeLoop() {
+ C.nativeLoop()
+}
+
+func quit() {
+ C.quit()
+}
+
+// SetIcon sets the systray icon.
+// iconBytes should be the content of .ico for windows and .ico/.jpg/.png
+// for other platforms.
+func SetIcon(iconBytes []byte) {
+ cstr := (*C.char)(unsafe.Pointer(&iconBytes[0]))
+ C.setIcon(cstr, (C.int)(len(iconBytes)))
+}
+
+// SetTitle sets the systray title, only available on Mac.
+func SetTitle(title string) {
+ C.setTitle(C.CString(title))
+}
+
+// SetTitle sets the systray tooltip to display on mouse hover of the tray icon,
+// only available on Mac and Windows.
+func SetTooltip(tooltip string) {
+ C.setTooltip(C.CString(tooltip))
+}
+
+func addOrUpdateMenuItem(item *MenuItem) {
+ var disabled C.short = 0
+ if item.disabled {
+ disabled = 1
+ }
+ var checked C.short = 0
+ if item.checked {
+ checked = 1
+ }
+ C.add_or_update_menu_item(
+ C.int(item.id),
+ C.CString(item.title),
+ C.CString(item.tooltip),
+ disabled,
+ checked,
+ )
+}
+
+//export systray_ready
+func systray_ready() {
+ systrayReady()
+}
+
+//export systray_menu_item_selected
+func systray_menu_item_selected(cId C.int) {
+ systrayMenuItemSelected(int32(cId))
+}