Skip to content

Commit

Permalink
minor tray menu API adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
overheadhunter committed Mar 8, 2022
1 parent 9272d89 commit e7a693a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package org.cryptomator.integrations.tray;

public record ActionItem(String title, Runnable action) implements TrayMenuItem {
public record ActionItem(String title, Runnable action, boolean enabled) implements TrayMenuItem {

public ActionItem(String title, Runnable action) {
this(title, action, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ static Optional<TrayMenuController> get() {
/**
* Displays an icon on the system tray.
*
* @param rawImageData What image to show
* @param imageData What image to show
* @param defaultAction Action to perform when interacting with the icon directly instead of its menu
* @param tooltip Text shown when hovering
* @throws IOException thrown when interacting with the given <code>rawImageData</code>
* @throws TrayMenuException thrown when adding the tray icon failed
*/
void showTrayIcon(InputStream rawImageData, Runnable defaultAction, String tooltip) throws IOException;
void showTrayIcon(byte[] imageData, Runnable defaultAction, String tooltip) throws TrayMenuException;

/**
* Show the given options in the tray menu.
* <p>
* This method may be called multiple times, e.g. when the vault list changes.
*
* @param items Menu items
* @throws TrayMenuException thrown when updating the tray menu failed
*/
void updateTrayMenu(List<TrayMenuItem> items);
void updateTrayMenu(List<TrayMenuItem> items) throws TrayMenuException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.cryptomator.integrations.tray;

public class TrayMenuException extends Exception {

public TrayMenuException(String message) {
super(message);
}

public TrayMenuException(String message, Throwable cause) {
super(message, cause);
}

}

0 comments on commit e7a693a

Please sign in to comment.