Fixed issues with deteching/loading gnome-shell extension
This commit is contained in:
parent
619edcb3fe
commit
488ca5564d
|
@ -69,11 +69,11 @@ class SystemTray {
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
/** Forces the system tray to always choose GTK2 (even when GTK3 might be available). */
|
/** Forces the system tray to always choose GTK2 (even when GTK3 might be available). */
|
||||||
public static boolean FORCE_GTK2 = false;
|
public static boolean FORCE_GTK2 = true;
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
/** If != 0, forces the system tray in linux to be GTK (1), AppIndicator (2), or Swing (3). This is an advanced feature. */
|
/** If != 0, forces the system tray in linux to be GTK (1), AppIndicator (2), or Swing (3). This is an advanced feature. */
|
||||||
public static int FORCE_LINUX_TYPE = 0;
|
public static int FORCE_LINUX_TYPE = 1;
|
||||||
|
|
||||||
@Property
|
@Property
|
||||||
/**
|
/**
|
||||||
|
@ -99,12 +99,18 @@ class SystemTray {
|
||||||
boolean isJavaFxLoaded_ = false;
|
boolean isJavaFxLoaded_ = false;
|
||||||
boolean isSwtLoaded_ = false;
|
boolean isSwtLoaded_ = false;
|
||||||
try {
|
try {
|
||||||
|
// this is important to use reflection, because if JavaFX is not being used, calling getToolkit() will initialize it...
|
||||||
|
java.lang.reflect.Method m = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
|
||||||
|
m.setAccessible(true);
|
||||||
|
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||||
|
|
||||||
// JavaFX Java7,8 is GTK2 only. Java9 can have it be GTK3 if -Djdk.gtk.version=3 is specified
|
// JavaFX Java7,8 is GTK2 only. Java9 can have it be GTK3 if -Djdk.gtk.version=3 is specified
|
||||||
// see http://mail.openjdk.java.net/pipermail/openjfx-dev/2016-May/019100.html
|
// see http://mail.openjdk.java.net/pipermail/openjfx-dev/2016-May/019100.html
|
||||||
isJavaFxLoaded_ = JavaFX.isLoaded();
|
isJavaFxLoaded_ = (null != m.invoke(cl, "com.sun.javafx.tk.Toolkit")) || (null != m.invoke(cl, "javafx.application.Application"));
|
||||||
|
|
||||||
|
// maybe we should load the SWT version? (In order for us to work with SWT, BOTH must be the same!!
|
||||||
// SWT is GTK2, but if -DSWT_GTK3=1 is specified, it can be GTK3
|
// SWT is GTK2, but if -DSWT_GTK3=1 is specified, it can be GTK3
|
||||||
isSwtLoaded_ = Swt.isLoaded();
|
isSwtLoaded_ = null != m.invoke(cl, "org.eclipse.swt.widgets.Display");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
logger.debug("Error detecting javaFX/SWT mode", e);
|
logger.debug("Error detecting javaFX/SWT mode", e);
|
||||||
|
@ -129,6 +135,12 @@ class SystemTray {
|
||||||
|
|
||||||
Class<? extends SystemTray> trayType = null;
|
Class<? extends SystemTray> trayType = null;
|
||||||
|
|
||||||
|
|
||||||
|
if (DEBUG) {
|
||||||
|
logger.debug("is JavaFX detected? {}", isJavaFxLoaded);
|
||||||
|
logger.debug("is SWT detected? {}", isSwtLoaded);
|
||||||
|
}
|
||||||
|
|
||||||
// kablooie if SWT is not configured in a way that works with us.
|
// kablooie if SWT is not configured in a way that works with us.
|
||||||
if (FORCE_LINUX_TYPE != SWING_INDICATOR && OS.isLinux()) {
|
if (FORCE_LINUX_TYPE != SWING_INDICATOR && OS.isLinux()) {
|
||||||
if (isSwtLoaded) {
|
if (isSwtLoaded) {
|
||||||
|
@ -247,10 +259,10 @@ class SystemTray {
|
||||||
|
|
||||||
|
|
||||||
// quick check, because we know that unity uses app-indicator. Maybe REALLY old versions do not. We support 14.04 LTE at least
|
// quick check, because we know that unity uses app-indicator. Maybe REALLY old versions do not. We support 14.04 LTE at least
|
||||||
if (trayType == null) {
|
|
||||||
String XDG = System.getenv("XDG_CURRENT_DESKTOP");
|
String XDG = System.getenv("XDG_CURRENT_DESKTOP");
|
||||||
|
|
||||||
// BLEH. if gnome-shell is running, IT'S REALLY GNOME!
|
// BLEH. if gnome-shell is running, IT'S REALLY GNOME!
|
||||||
|
// we must ALWAYS do this check!!
|
||||||
boolean isReallyGnome = false;
|
boolean isReallyGnome = false;
|
||||||
try {
|
try {
|
||||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
|
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(8196);
|
||||||
|
@ -371,8 +383,9 @@ class SystemTray {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// is likely 'gnome', but it can also be unknown (or something completely different), install extension and go from there
|
// is likely 'gnome' (gnome-shell exists on the platform), but it can also be unknown (or something completely different),
|
||||||
if (trayType == null) {
|
// install extension and go from there
|
||||||
|
if (isReallyGnome) {
|
||||||
// if the "topicons" extension is installed, don't install us (because it will override what we do, where ours
|
// if the "topicons" extension is installed, don't install us (because it will override what we do, where ours
|
||||||
// is more specialized - so it only modified our tray icon (instead of ALL tray icons)
|
// is more specialized - so it only modified our tray icon (instead of ALL tray icons)
|
||||||
|
|
||||||
|
@ -393,15 +406,15 @@ class SystemTray {
|
||||||
logger.info("Installing gnome-shell extension");
|
logger.info("Installing gnome-shell extension");
|
||||||
}
|
}
|
||||||
|
|
||||||
GnomeShellExtension.install(logger, output);
|
GnomeShellExtension.install(output);
|
||||||
|
if (trayType == null) {
|
||||||
trayType = GtkSystemTray.class;
|
trayType = GtkSystemTray.class;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
logger.error("Cannot auto-detect gnome-shell version", e);
|
logger.error("Cannot auto-detect gnome-shell version", e);
|
||||||
}
|
}
|
||||||
trayType = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user