10
10
import org .cryptomator .integrations .tray .TrayMenuController ;
11
11
import org .cryptomator .integrations .tray .TrayMenuException ;
12
12
import org .cryptomator .integrations .tray .TrayMenuItem ;
13
+ import org .cryptomator .linux .util .CheckUtil ;
13
14
import org .purejava .appindicator .AppIndicator ;
14
15
import org .purejava .appindicator .GCallback ;
15
16
import org .purejava .appindicator .GObject ;
@@ -32,7 +33,7 @@ public class AppindicatorTrayMenuController implements TrayMenuController {
32
33
33
34
private static final Arena ARENA = Arena .global ();
34
35
private MemorySegment indicator ;
35
- private MemorySegment menu = Gtk . newMenu () ;
36
+ private MemorySegment menu ;
36
37
37
38
@ CheckAvailability
38
39
public static boolean isAvailable () {
@@ -41,6 +42,7 @@ public static boolean isAvailable() {
41
42
42
43
@ Override
43
44
public void showTrayIcon (Consumer <TrayIconLoader > iconLoader , Runnable runnable , String s ) throws TrayMenuException {
45
+ menu = Gtk .newMenu ();
44
46
TrayIconLoader .FreedesktopIconName callback = this ::showTrayIconWithSVG ;
45
47
iconLoader .accept (callback );
46
48
Gtk .widgetShowAll (menu );
@@ -71,11 +73,13 @@ public void updateTrayIcon(Consumer<TrayIconLoader> iconLoader) {
71
73
}
72
74
73
75
private void updateTrayIconWithSVG (String iconName ) {
76
+ CheckUtil .checkState (indicator != null , "Appindicator is not setup. Call showTrayIcon(...) first." );
74
77
AppIndicator .setIcon (indicator , iconName );
75
78
}
76
79
77
80
@ Override
78
81
public void updateTrayMenu (List <TrayMenuItem > items ) throws TrayMenuException {
82
+ CheckUtil .checkState (indicator != null , "Appindicator is not setup. Call showTrayIcon(...) first." );
79
83
menu = Gtk .newMenu ();
80
84
addChildren (menu , items );
81
85
Gtk .widgetShowAll (menu );
0 commit comments