Skip to content

Commit

Permalink
Merge branch 'release/1.4.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
infeo committed May 14, 2024
2 parents acc4b02 + 3c5b2d5 commit d3ce8e6
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 74 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
java-version: 22
cache: 'maven'
- name: Ensure to use tagged version
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -26,7 +26,7 @@ jobs:
name: artifacts
path: target/*.jar
- name: Create Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
java-version: 22
cache: 'maven'
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
runner-os: 'ubuntu-latest'
java-distribution: 'temurin'
java-version: 21
java-version: 22
secrets:
nvd-api-key: ${{ secrets.NVD_API_KEY }}
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
2 changes: 1 addition & 1 deletion .github/workflows/publish-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
java-version: 22
cache: 'maven'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-github.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 21
java-version: 22
cache: 'maven'
gpg-private-key: ${{ secrets.RELEASES_GPG_PRIVATE_KEY }} # Value of the GPG private key to import
gpg-passphrase: MAVEN_GPG_PASSPHRASE # env variable for GPG private key passphrase
Expand Down
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 13 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.cryptomator</groupId>
<artifactId>integrations-linux</artifactId>
<version>1.4.4</version>
<version>1.4.5</version>

<name>integrations-linux</name>
<description>Provides optional Linux services used by Cryptomator</description>
Expand Down Expand Up @@ -36,21 +36,21 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.jdk.version>21</project.jdk.version>
<project.jdk.version>22</project.jdk.version>

<!-- runtime dependencies -->

<api.version>1.3.0</api.version>
<secret-service.version>2.0.0-alpha</secret-service.version>
<api.version>1.3.1</api.version>
<secret-service.version>2.0.1-alpha</secret-service.version>
<kdewallet.version>1.4.0</kdewallet.version>
<appindicator.version>1.3.6</appindicator.version>
<slf4j.version>2.0.11</slf4j.version>
<slf4j.version>2.0.13</slf4j.version>
<appindicator.version>1.4.0</appindicator.version>

<!-- test dependencies -->
<junit.version>5.10.1</junit.version>
<junit.version>5.10.2</junit.version>

<!-- build plugin dependencies -->
<dependency-check.version>9.0.9</dependency-check.version>
<dependency-check.version>9.1.0</dependency-check.version>
<nexus-staging.version>1.6.8</nexus-staging.version>
</properties>

Expand Down Expand Up @@ -94,12 +94,9 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.12.1</version>
<version>3.13.0</version>
<configuration>
<release>${project.jdk.version}</release>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -131,7 +128,7 @@
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
Expand Down Expand Up @@ -194,7 +191,6 @@
<name>see</name>
</tag>
</tags>
<additionalOptions>--enable-preview</additionalOptions>
</configuration>
</plugin>
</plugins>
Expand All @@ -216,7 +212,7 @@
<skipTestScope>true</skipTestScope>
<detail>true</detail>
<suppressionFile>suppression.xml</suppressionFile>
<nvdApiKey>${env.NVD_API_KEY}</nvdApiKey>
<nvdApiKeyEnvironmentVariable>NVD_API_KEY</nvdApiKeyEnvironmentVariable>
</configuration>
<executions>
<execution>
Expand All @@ -237,7 +233,7 @@
<plugins>
<plugin>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<version>3.2.4</version>
<executions>
<execution>
<id>sign-artifacts</id>
Expand Down Expand Up @@ -298,7 +294,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.2</version>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

record ActionItemCallback (ActionItem actionItem) implements GCallback {
record ActionItemCallback (ActionItem actionItem) implements GCallback.Function {
private static final Logger LOG = LoggerFactory.getLogger(ActionItemCallback.class);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@
import org.cryptomator.integrations.tray.TrayMenuController;
import org.cryptomator.integrations.tray.TrayMenuException;
import org.cryptomator.integrations.tray.TrayMenuItem;
import org.cryptomator.linux.util.CheckUtil;
import org.purejava.appindicator.AppIndicator;
import org.purejava.appindicator.GCallback;
import org.purejava.appindicator.NativeLibUtilities;
import org.purejava.appindicator.GObject;
import org.purejava.appindicator.Gtk;

import java.lang.foreign.Arena;
import java.lang.foreign.MemorySegment;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;

import static org.purejava.appindicator.app_indicator_h.*;
import static org.purejava.appindicator.app_indicator_h.APP_INDICATOR_CATEGORY_APPLICATION_STATUS;
import static org.purejava.appindicator.app_indicator_h.APP_INDICATOR_STATUS_ACTIVE;

@Priority(1000)
@CheckAvailability
Expand All @@ -30,37 +33,36 @@ public class AppindicatorTrayMenuController implements TrayMenuController {

private static final Arena ARENA = Arena.global();
private MemorySegment indicator;
private MemorySegment menu = gtk_menu_new();
private MemorySegment menu;

@CheckAvailability
public static boolean isAvailable() {
return NativeLibUtilities.isLoadedNativeLib();
return AppIndicator.isLoaded();
}

@Override
public void showTrayIcon(Consumer<TrayIconLoader> iconLoader, Runnable runnable, String s) throws TrayMenuException {
menu = Gtk.newMenu();
TrayIconLoader.FreedesktopIconName callback = this::showTrayIconWithSVG;
iconLoader.accept(callback);
gtk_widget_show_all(menu);
app_indicator_set_status(indicator, APP_INDICATOR_STATUS_ACTIVE());
Gtk.widgetShowAll(menu);
AppIndicator.setStatus(indicator, APP_INDICATOR_STATUS_ACTIVE());
}

private void showTrayIconWithSVG(String s) {
try (var arena = Arena.ofConfined()) {
var svgSourcePath = System.getProperty(SVG_SOURCE_PROPERTY);
// flatpak
if (svgSourcePath == null) {
indicator = app_indicator_new(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
// AppImage and ppa
} else {
indicator = app_indicator_new_with_path(arena.allocateUtf8String(APP_INDICATOR_ID),
arena.allocateUtf8String(s),
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
// find tray icons theme in mounted AppImage / installed on system by ppa
arena.allocateUtf8String(svgSourcePath));
}
private void showTrayIconWithSVG(String iconName) {
var svgSourcePath = System.getProperty(SVG_SOURCE_PROPERTY);
// flatpak
if (svgSourcePath == null) {
indicator = AppIndicator.newIndicator(APP_INDICATOR_ID,
iconName,
APP_INDICATOR_CATEGORY_APPLICATION_STATUS());
// AppImage and ppa
} else {
indicator = AppIndicator.newIndicatorWithPath(APP_INDICATOR_ID,
iconName,
APP_INDICATOR_CATEGORY_APPLICATION_STATUS(),
// find tray icons theme in mounted AppImage / installed on system by ppa
svgSourcePath);
}
}

Expand All @@ -70,18 +72,18 @@ public void updateTrayIcon(Consumer<TrayIconLoader> iconLoader) {
iconLoader.accept(callback);
}

private void updateTrayIconWithSVG(String s) {
try (var arena = Arena.ofConfined()) {
app_indicator_set_icon(indicator, arena.allocateUtf8String(s));
}
private void updateTrayIconWithSVG(String iconName) {
CheckUtil.checkState(indicator != null, "Appindicator is not setup. Call showTrayIcon(...) first.");
AppIndicator.setIcon(indicator, iconName);
}

@Override
public void updateTrayMenu(List<TrayMenuItem> items) throws TrayMenuException {
menu = gtk_menu_new();
CheckUtil.checkState(indicator != null, "Appindicator is not setup. Call showTrayIcon(...) first.");
menu = Gtk.newMenu();
addChildren(menu, items);
gtk_widget_show_all(menu);
app_indicator_set_menu(indicator, menu);
Gtk.widgetShowAll(menu);
AppIndicator.setMenu(indicator, menu);
}

@Override
Expand All @@ -93,30 +95,26 @@ private void addChildren(MemorySegment menu, List<TrayMenuItem> items) {
for (var item : items) {
switch (item) {
case ActionItem a -> {
var gtkMenuItem = gtk_menu_item_new();
try (var arena = Arena.ofConfined()) {
gtk_menu_item_set_label(gtkMenuItem, arena.allocateUtf8String(a.title()));
g_signal_connect_object(gtkMenuItem,
arena.allocateUtf8String("activate"),
GCallback.allocate(new ActionItemCallback(a), ARENA),
menu,
0);
}
gtk_menu_shell_append(menu, gtkMenuItem);
var gtkMenuItem = Gtk.newMenuItem();
Gtk.menuItemSetLabel(gtkMenuItem, a.title());
GObject.signalConnectObject(gtkMenuItem,
"activate",
GCallback.allocate(new ActionItemCallback(a), ARENA),
menu,
0);
Gtk.menuShellAppend(menu, gtkMenuItem);
}
case SeparatorItem _ -> {
var gtkSeparator = gtk_menu_item_new();
gtk_menu_shell_append(menu, gtkSeparator);
var gtkSeparator = Gtk.newMenuItem();
Gtk.menuShellAppend(menu, gtkSeparator);
}
case SubMenuItem s -> {
var gtkMenuItem = gtk_menu_item_new();
var gtkSubmenu = gtk_menu_new();
try (var arena = Arena.ofConfined()) {
gtk_menu_item_set_label(gtkMenuItem, arena.allocateUtf8String(s.title()));
}
var gtkMenuItem = Gtk.newMenuItem();
var gtkSubmenu = Gtk.newMenu();
Gtk.menuItemSetLabel(gtkMenuItem, s.title());
addChildren(gtkSubmenu, s.items());
gtk_menu_item_set_submenu(gtkMenuItem, gtkSubmenu);
gtk_menu_shell_append(menu, gtkMenuItem);
Gtk.menuItemSetSubmenu(gtkMenuItem, gtkSubmenu);
Gtk.menuShellAppend(menu, gtkMenuItem);
}
}
}
Expand Down

0 comments on commit d3ce8e6

Please sign in to comment.