Skip to content

Commit

Permalink
Some more change requests
Browse files Browse the repository at this point in the history
Discussion: #18
  • Loading branch information
purejava committed May 9, 2023
1 parent 33f9a46 commit 78a3e42
Showing 1 changed file with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.cryptomator.integrations.tray.TrayMenuItem;
import org.purejava.appindicator.GCallback;
import org.purejava.appindicator.MemoryAllocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
Expand All @@ -27,7 +25,7 @@
@OperatingSystem(OperatingSystem.Value.LINUX)
public class AppindicatorTrayMenuController implements TrayMenuController {

private static final Logger LOG = LoggerFactory.getLogger(AppindicatorTrayMenuController.class);
private static final String APP_INDICATOR_ID = "org.cryptomator.Cryptomator";

private static final SegmentScope SCOPE = SegmentScope.global();
private MemorySegment indicator;
Expand All @@ -43,13 +41,12 @@ public void showTrayIcon(Consumer<TrayIconLoader> iconLoader, Runnable runnable,
TrayIconLoader.FreedesktopIconName callback = this::showTrayIconWithSVG;
iconLoader.accept(callback);
gtk_widget_show_all(menu);
app_indicator_set_menu(indicator, menu);
app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE());
}

private void showTrayIconWithSVG(String s) {
try (var arena = Arena.openConfined()) {
indicator = app_indicator_new(arena.allocateUtf8String("org.cryptomator.Cryptomator"),
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
}
Expand Down Expand Up @@ -110,7 +107,6 @@ private void addChildren(MemorySegment menu, List<TrayMenuItem> items) {
gtk_menu_shell_append(menu, gtkMenuItem);
}
}
gtk_widget_show_all(menu);
}
}
}

0 comments on commit 78a3e42

Please sign in to comment.