Add an option to not use systray

This commit is contained in:
Laurent Clouet
2016-04-28 19:37:05 +02:00
parent 783475b7fa
commit 718316cb38
2 changed files with 22 additions and 15 deletions

View File

@@ -59,6 +59,7 @@ public class GuiSwing extends JFrame implements Gui {
private Working activityWorking; private Working activityWorking;
private Settings activitySettings; private Settings activitySettings;
private TrayIcon trayIcon; private TrayIcon trayIcon;
private boolean useSysTray;
private int framesRendered; private int framesRendered;
@@ -67,9 +68,9 @@ public class GuiSwing extends JFrame implements Gui {
private ThreadClient threadClient; private ThreadClient threadClient;
public GuiSwing() { public GuiSwing(boolean useSysTray_) {
framesRendered = 0; framesRendered = 0;
useSysTray = useSysTray_;
waitingForAuthentication = true; waitingForAuthentication = true;
} }
@@ -82,6 +83,7 @@ public class GuiSwing extends JFrame implements Gui {
e1.printStackTrace(); e1.printStackTrace();
} }
if (useSysTray) {
try { try {
sysTray = SystemTray.getSystemTray(); sysTray = SystemTray.getSystemTray();
if (SystemTray.isSupported()) { if (SystemTray.isSupported()) {
@@ -97,6 +99,8 @@ public class GuiSwing extends JFrame implements Gui {
catch (UnsupportedOperationException e) { catch (UnsupportedOperationException e) {
sysTray = null; sysTray = null;
} }
}
URL iconUrl = getClass().getResource("/icon.png"); URL iconUrl = getClass().getResource("/icon.png");
if (iconUrl != null) { if (iconUrl != null) {

View File

@@ -88,6 +88,9 @@ public class Worker {
@Option(name = "--version", usage = "Display application version", required = false, handler = VersionParameterHandler.class) @Option(name = "--version", usage = "Display application version", required = false, handler = VersionParameterHandler.class)
private VersionParameterHandler versionHandler; private VersionParameterHandler versionHandler;
@Option(name = "--no-systray", usage = "Don't use systray", required = false)
private boolean no_systray = false;
public static void main(String[] args) { public static void main(String[] args) {
new Worker().doMain(args); new Worker().doMain(args);
} }
@@ -279,7 +282,7 @@ public class Worker {
System.out.println("You should set a DISPLAY or use a text ui (with -ui " + GuiTextOneLine.type + " or -ui " + GuiText.type + ")."); System.out.println("You should set a DISPLAY or use a text ui (with -ui " + GuiTextOneLine.type + " or -ui " + GuiText.type + ").");
System.exit(3); System.exit(3);
} }
gui = new GuiSwing(); gui = new GuiSwing(no_systray == false);
break; break;
} }
Client cli = new Client(gui, config, server); Client cli = new Client(gui, config, server);