@@ -26,25 +26,95 @@ import (
2626 "unsafe"
2727)
2828
29+ func registerSystray () {
30+ C .registerSystray ()
31+ }
2932
33+ func nativeLoop () {
34+ C .nativeLoop ()
35+ }
3036
37+ func quit () {
38+ C .quit ()
39+ }
3140
41+ func SetIcon (iconBytes []byte ) {
42+ cstr := (* C .char )(unsafe .Pointer (& iconBytes [0 ]))
43+ C .setIcon (cstr , (C .int )(len (iconBytes )), false )
44+ }
3245
33- func SetTemplateIcon (templateIconBytes []byte , regularIconBytes []byte ) {
34- cstr := (* C .char )(unsafe .Pointer (& templateIconBytes [0 ]))
35- C .setIcon (cstr , (C .int )(len (templateIconBytes )), true )
46+ func SetTitle (title string ) {
47+ C .setTitle (C .CString (title ))
3648}
3749
50+ func SetTooltip (tooltip string ) {
51+ C .setTooltip (C .CString (tooltip ))
52+ }
3853
54+ func addOrUpdateMenuItem (item * MenuItem ) {
55+ var disabled C.short
56+ if item .disabled {
57+ disabled = 1
58+ }
59+ var checked C.short
60+ if item .checked {
61+ checked = 1
62+ }
63+ var isCheckable C.short
64+ if item .isCheckable {
65+ isCheckable = 1
66+ }
67+ var parentID uint32 = 0
68+ if item .parent != nil {
69+ parentID = item .parent .id
70+ }
71+ C .add_or_update_menu_item (
72+ C .int (item .id ),
73+ C .int (parentID ),
74+ C .CString (item .title ),
75+ C .CString (item .tooltip ),
76+ disabled ,
77+ checked ,
78+ isCheckable ,
79+ )
80+ }
3981
40- func (item * MenuItem ) SetIcon (iconBytes []byte ) {
41- cstr := (* C .char )(unsafe .Pointer (& iconBytes [0 ]))
42- C .setMenuItemIcon (cstr , (C .int )(len (iconBytes )), C .int (item .id ), false )
82+ func addSeparator (id uint32 ) {
83+ C .add_separator (C .int (id ))
4384}
4485
86+ func hideMenuItem (item * MenuItem ) {
87+ C .hide_menu_item (C .int (item .id ))
88+ }
4589
90+ func showMenuItem (item * MenuItem ) {
91+ C .show_menu_item (C .int (item .id ))
92+ }
4693
94+ //export systray_ready
95+ func systray_ready () {
96+ systrayReady ()
97+ }
98+
99+ //export systray_on_exit
100+ func systray_on_exit () {
101+ systrayExit ()
102+ }
103+
104+ //export systray_menu_item_selected
105+ func systray_menu_item_selected (cID C.int ) {
106+ systrayMenuItemSelected (uint32 (cID ))
107+ }
108+
109+ func SetTemplateIcon (templateIconBytes []byte , regularIconBytes []byte ) {
110+ cstr := (* C .char )(unsafe .Pointer (& templateIconBytes [0 ]))
111+ C .setIcon (cstr , (C .int )(len (templateIconBytes )), true )
112+ }
47113
114+ func (item * MenuItem ) SetIcon (iconBytes []byte ) {
115+ cstr := (* C .char )(unsafe .Pointer (& iconBytes [0 ]))
116+ C .setMenuItemIcon (cstr , (C .int )(len (iconBytes )), C .int (item .id ), false )
117+ }
48118
49119func (item * MenuItem ) SetTemplateIcon (templateIconBytes []byte , regularIconBytes []byte ) {
50120 cstr := (* C .char )(unsafe .Pointer (& templateIconBytes [0 ]))
0 commit comments