diff --git a/src/dorkbox/systemTray/SystemTray.java b/src/dorkbox/systemTray/SystemTray.java index 9746e6e..22a937a 100644 --- a/src/dorkbox/systemTray/SystemTray.java +++ b/src/dorkbox/systemTray/SystemTray.java @@ -44,6 +44,7 @@ import dorkbox.systemTray.util.JavaFX; import dorkbox.systemTray.util.Swt; import dorkbox.systemTray.util.WindowsSystemTraySwing; import dorkbox.util.CacheUtil; +import dorkbox.util.IO; import dorkbox.util.OS; import dorkbox.util.Property; import dorkbox.util.process.ShellProcessBuilder; @@ -58,7 +59,7 @@ class SystemTray { public static final Logger logger = LoggerFactory.getLogger(SystemTray.class); public static final int TYPE_AUTO_DETECT = 0; - public static final int TYPE_GTKSTATUSICON = 1; + public static final int TYPE_GTK_STATUSICON = 1; public static final int TYPE_APP_INDICATOR = 2; public static final int TYPE_SWING = 3; @@ -98,11 +99,11 @@ class SystemTray { @Property /** Forces the system tray to always choose GTK2 (even when GTK3 might be available). */ - public static boolean FORCE_GTK2 = true; + public static boolean FORCE_GTK2 = false; @Property /** Forces the system tray detection to be Automatic (0), GTK (1), AppIndicator (2), or Swing (3). This is an advanced feature. */ - public static int FORCE_TRAY_TYPE = 1; + public static int FORCE_TRAY_TYPE = 0; @Property /** @@ -261,7 +262,7 @@ class SystemTray { } } - if (SystemTray.FORCE_TRAY_TYPE == SystemTray.TYPE_GTKSTATUSICON) { + if (SystemTray.FORCE_TRAY_TYPE == SystemTray.TYPE_GTK_STATUSICON) { try { trayType = GtkSystemTray.class; } catch (Throwable e1) { @@ -527,13 +528,7 @@ class SystemTray { break; } } finally { - if (bin != null) { - try { - bin.close(); - } catch (Exception ignored) { - } - bin = null; - } + IO.closeQuietly(bin); } } } @@ -541,16 +536,6 @@ class SystemTray { if (DEBUG) { logger.error("Error detecting gnome version", e); } - } finally { - if (bin != null) { - try { - bin.close(); - } catch (Throwable e) { - if (DEBUG) { - logger.error("Cannot close buffered reader", e); - } - } - } } } diff --git a/src/dorkbox/systemTray/linux/AppIndicatorTray.java b/src/dorkbox/systemTray/linux/AppIndicatorTray.java index 8694e65..80fe11e 100644 --- a/src/dorkbox/systemTray/linux/AppIndicatorTray.java +++ b/src/dorkbox/systemTray/linux/AppIndicatorTray.java @@ -45,7 +45,7 @@ class AppIndicatorTray extends GtkTypeSystemTray { public AppIndicatorTray() { - if (SystemTray.FORCE_TRAY_TYPE == SystemTray.TYPE_GTKSTATUSICON) { + if (SystemTray.FORCE_TRAY_TYPE == SystemTray.TYPE_GTK_STATUSICON) { // if we force GTK type system tray, don't attempt to load AppIndicator libs throw new IllegalArgumentException("Unable to start AppIndicator if 'SystemTray.FORCE_TRAY_TYPE' is set to GTK"); } diff --git a/src/dorkbox/systemTray/linux/GtkSystemTray.java b/src/dorkbox/systemTray/linux/GtkSystemTray.java index 369a5dc..9c309ff 100644 --- a/src/dorkbox/systemTray/linux/GtkSystemTray.java +++ b/src/dorkbox/systemTray/linux/GtkSystemTray.java @@ -83,7 +83,7 @@ class GtkSystemTray extends GtkTypeSystemTray { super.waitForStartup(); - ImageUtils.determineIconSize(SystemTray.TYPE_GTKSTATUSICON); + ImageUtils.determineIconSize(SystemTray.TYPE_GTK_STATUSICON); // we have to be able to set our title, otherwise the gnome-shell extension WILL NOT work dispatch(new Runnable() { diff --git a/src/dorkbox/systemTray/linux/GtkTypeSystemTray.java b/src/dorkbox/systemTray/linux/GtkTypeSystemTray.java index 5cfbe74..f0750ac 100644 --- a/src/dorkbox/systemTray/linux/GtkTypeSystemTray.java +++ b/src/dorkbox/systemTray/linux/GtkTypeSystemTray.java @@ -69,7 +69,7 @@ class GtkTypeSystemTray extends SystemTray { } } } else if (SystemTray.isSwtLoaded) { - if (SystemTray.FORCE_TRAY_TYPE != SystemTray.TYPE_GTKSTATUSICON) { + if (SystemTray.FORCE_TRAY_TYPE != SystemTray.TYPE_GTK_STATUSICON) { // GTK system tray has threading issues if we block here (because it is likely in the event thread) // AppIndicator version doesn't have this problem try { diff --git a/src/dorkbox/systemTray/linux/jna/AppIndicator.java b/src/dorkbox/systemTray/linux/jna/AppIndicator.java index 6fe9fdd..743227a 100644 --- a/src/dorkbox/systemTray/linux/jna/AppIndicator.java +++ b/src/dorkbox/systemTray/linux/jna/AppIndicator.java @@ -51,7 +51,7 @@ class AppIndicator { // ALSO WHAT VERSION OF GTK to use? appindiactor1 -> GTk2, appindicator3 -> GTK3. // appindicator3 doesn't support menu icons via GTK2!! - if (SystemTray.FORCE_TRAY_TYPE == SystemTray.TYPE_GTKSTATUSICON) { + if (SystemTray.FORCE_TRAY_TYPE == SystemTray.TYPE_GTK_STATUSICON) { // if we force GTK type system tray, don't attempt to load AppIndicator libs if (LIBRARY_DEBUG) { logger.error("Forcing GTK tray, not using appindicator"); diff --git a/src/dorkbox/systemTray/util/ImageUtils.java b/src/dorkbox/systemTray/util/ImageUtils.java index 66344db..230ef06 100644 --- a/src/dorkbox/systemTray/util/ImageUtils.java +++ b/src/dorkbox/systemTray/util/ImageUtils.java @@ -64,7 +64,7 @@ class ImageUtils { } else { // GtkStatusIcon will USUALLY automatically scale the icon // AppIndicator will NOT scale the icon - if (trayType == SystemTray.TYPE_SWING || trayType == SystemTray.TYPE_GTKSTATUSICON) { + if (trayType == SystemTray.TYPE_SWING || trayType == SystemTray.TYPE_GTK_STATUSICON) { // swing or GtkStatusIcon on linux/mac? use the default settings SIZE = SystemTray.DEFAULT_LINUX_SIZE; } else {