Code polish

This commit is contained in:
nathan 2016-09-26 02:44:36 +02:00
parent fb8c5c2378
commit ffb5657f61
6 changed files with 11 additions and 26 deletions

View File

@ -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);
}
}
}
}
}

View File

@ -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");
}

View File

@ -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() {

View File

@ -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 {

View File

@ -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");

View File

@ -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 {