summaryrefslogtreecommitdiff
path: root/vendor/github.com/getlantern/systray/systray_nonwindows.go
diff options
context:
space:
mode:
authorkali <kali@leap.se>2018-09-26 20:36:18 +0200
committerKali Kaneko (leap communications) <kali@leap.se>2018-09-26 20:43:51 +0200
commitb26241ce8ec2b992b4209677ea75df608964cdbf (patch)
tree237b93bf1173cd4207e960cad6ff0c3c2104a75f /vendor/github.com/getlantern/systray/systray_nonwindows.go
parentf1e820ba1664cc1d3f69e15d0356552fecaf6fcd (diff)
[pkg] vendor getlantern/systray
this is a workaround for riseup_vpn#28
Diffstat (limited to 'vendor/github.com/getlantern/systray/systray_nonwindows.go')
-rw-r--r--vendor/github.com/getlantern/systray/systray_nonwindows.go92
1 files changed, 92 insertions, 0 deletions
diff --git a/vendor/github.com/getlantern/systray/systray_nonwindows.go b/vendor/github.com/getlantern/systray/systray_nonwindows.go
new file mode 100644
index 0000000..0ed03b4
--- /dev/null
+++ b/vendor/github.com/getlantern/systray/systray_nonwindows.go
@@ -0,0 +1,92 @@
+// +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))
+}
+
+// SetTooltip 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
+ if item.disabled {
+ disabled = 1
+ }
+ var checked C.short
+ 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,
+ )
+}
+
+func addSeparator(id int32) {
+ C.add_separator(C.int(id))
+}
+
+func hideMenuItem(item *MenuItem) {
+ C.hide_menu_item(
+ C.int(item.id),
+ )
+}
+
+func showMenuItem(item *MenuItem) {
+ C.show_menu_item(
+ C.int(item.id),
+ )
+}
+
+//export systray_ready
+func systray_ready() {
+ systrayReady()
+}
+
+//export systray_on_exit
+func systray_on_exit() {
+ systrayExit()
+}
+
+//export systray_menu_item_selected
+func systray_menu_item_selected(cID C.int) {
+ systrayMenuItemSelected(int32(cID))
+}