Updated comments, added BASIC support for Arch.
This commit is contained in:
parent
fdabacdf4b
commit
c0b3e9260c
@ -94,11 +94,10 @@ class SystemTray {
|
|||||||
@Property
|
@Property
|
||||||
/** Enables auto-detection for the system tray. This should be mostly successful.
|
/** Enables auto-detection for the system tray. This should be mostly successful.
|
||||||
* <p>
|
* <p>
|
||||||
* Auto-detection will use DEFAULT_WINDOWS_SIZE or DEFAULT_LINUX_SIZE as a 'base-line' for determining what size to use. On Linux,
|
* Auto-detection will use DEFAULT_TRAY_SIZE or DEFAULT_MENU_SIZE as a 'base-line' for determining what size to use.
|
||||||
* `gsettings get org.gnome.desktop.interface scaling-factor` is used to determine the scale factor (for HiDPI configurations).
|
|
||||||
* <p>
|
* <p>
|
||||||
* If auto-detection fails and the incorrect size is detected or used, disable this and specify the correct DEFAULT_WINDOWS_SIZE or
|
* If auto-detection fails and the incorrect size is detected or used, disable this and specify the correct DEFAULT_TRAY_SIZE or
|
||||||
* DEFAULT_LINUX_SIZE to use them instead
|
* DEFAULT_MENU_SIZE instead
|
||||||
*/
|
*/
|
||||||
public static boolean AUTO_TRAY_SIZE = true;
|
public static boolean AUTO_TRAY_SIZE = true;
|
||||||
|
|
||||||
@ -476,7 +475,7 @@ class SystemTray {
|
|||||||
// Fedora KDE requires GtkStatusIcon
|
// Fedora KDE requires GtkStatusIcon
|
||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
||||||
} else {
|
} else {
|
||||||
// kde (at least, plasma 5.5.6) requires appindicator
|
// kde (at least, plasma 5.5.6) requires appindicator
|
||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.AppIndicator);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.AppIndicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +486,11 @@ class SystemTray {
|
|||||||
// http://bazaar.launchpad.net/~wingpanel-devs/wingpanel/trunk/view/head:/sample/SampleIndicator.vala
|
// http://bazaar.launchpad.net/~wingpanel-devs/wingpanel/trunk/view/head:/sample/SampleIndicator.vala
|
||||||
|
|
||||||
if (!useNativeMenus && AUTO_FIX_INCONSISTENCIES) {
|
if (!useNativeMenus && AUTO_FIX_INCONSISTENCIES) {
|
||||||
logger.warn("Cannot use non-native menus with pantheon (elementaryOS). Forcing native menus.");
|
if (OS.isElementaryOSInstalled()) {
|
||||||
|
logger.warn("Cannot use non-native menus with pantheon (elementaryOS). Forcing native menus.");
|
||||||
|
} else {
|
||||||
|
logger.warn("Cannot use non-native menus with pantheon DE. Forcing native menus.");
|
||||||
|
}
|
||||||
useNativeMenus = true;
|
useNativeMenus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,6 +507,21 @@ class SystemTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ("gnome".equalsIgnoreCase(GDM)) {
|
if ("gnome".equalsIgnoreCase(GDM)) {
|
||||||
|
if (OS.isArchInstalled()) {
|
||||||
|
if (DEBUG) {
|
||||||
|
logger.debug("Running Arch Linux.");
|
||||||
|
}
|
||||||
|
if (!Extension.isInstalled()) {
|
||||||
|
logger.info("You may need a work-around for showing the SystemTray icon - we suggest installing the " +
|
||||||
|
"the [Top Icons] plugin (https://extensions.gnome.org/extension/1031/topicons/) which moves " +
|
||||||
|
"icons from the *notification drawer* (it is normally collapsed) at the bottom left corner " +
|
||||||
|
"of the screen to the menu panel next to the clock.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Automatically install the extension for everyone except Arch. It's bonkers.
|
||||||
|
Extension.install();
|
||||||
|
}
|
||||||
|
|
||||||
// are we fedora? If so, what version?
|
// are we fedora? If so, what version?
|
||||||
// now, what VERSION of fedora? 23/24/25 don't have AppIndicator installed, so we have to use GtkStatusIcon
|
// now, what VERSION of fedora? 23/24/25 don't have AppIndicator installed, so we have to use GtkStatusIcon
|
||||||
int fedoraVersion = OS.getFedoraVersion();
|
int fedoraVersion = OS.getFedoraVersion();
|
||||||
@ -516,9 +534,9 @@ class SystemTray {
|
|||||||
System.setProperty("SystemTray_IS_FEDORA_GNOME_ADJUST_SIZE", Integer.toString(fedoraVersion));
|
System.setProperty("SystemTray_IS_FEDORA_GNOME_ADJUST_SIZE", Integer.toString(fedoraVersion));
|
||||||
|
|
||||||
// 23 is gtk, 24/25 is gtk (but also wrong size unless we adjust it)
|
// 23 is gtk, 24/25 is gtk (but also wrong size unless we adjust it)
|
||||||
Extension.install();
|
|
||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.GtkStatusIcon);
|
||||||
} else {
|
} else {
|
||||||
|
// arch likely will have problems unless the correct/appropriate libraries are installed.
|
||||||
trayType = selectTypeQuietly(useNativeMenus, TrayType.AppIndicator);
|
trayType = selectTypeQuietly(useNativeMenus, TrayType.AppIndicator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -664,15 +682,13 @@ class SystemTray {
|
|||||||
|
|
||||||
final AtomicReference<Tray> reference = new AtomicReference<Tray>();
|
final AtomicReference<Tray> reference = new AtomicReference<Tray>();
|
||||||
|
|
||||||
/*
|
// - appIndicator/gtk require strings (which is the path)
|
||||||
* appIndicator/gtk require strings (which is the path)
|
// - swing version loads as an image (which can be stream or path, we use path)
|
||||||
* swing version loads as an image (which can be stream or path, we use path)
|
|
||||||
*/
|
|
||||||
CacheUtil.tempDir = "SysTray";
|
CacheUtil.tempDir = "SysTray";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (OS.isLinux()) {
|
if (OS.isLinux()) {
|
||||||
// load up our libraries NOTE: appindicator1 -> GTk2, appindicator3 -> GTK3.
|
// NOTE: appindicator1 -> GTk2, appindicator3 -> GTK3.
|
||||||
// appindicator3 doesn't support menu icons via GTK2!!
|
// appindicator3 doesn't support menu icons via GTK2!!
|
||||||
if (!Gtk.isLoaded) {
|
if (!Gtk.isLoaded) {
|
||||||
logger.error("Unable to initialize GTK! Something is severely wrong!");
|
logger.error("Unable to initialize GTK! Something is severely wrong!");
|
||||||
@ -680,6 +696,33 @@ class SystemTray {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (OS.isArchInstalled()) {
|
||||||
|
// arch linux is fun!
|
||||||
|
|
||||||
|
if (isTrayType(trayType, TrayType.AppIndicator)) {
|
||||||
|
// appindicators
|
||||||
|
|
||||||
|
// requires the install of libappindicator which is GTK2 (as of 25DEC2016)
|
||||||
|
// requires the install of libappindicator3 which is GTK3 (as of 25DEC2016)
|
||||||
|
|
||||||
|
if (!AppIndicator.isLoaded) {
|
||||||
|
if (Gtk.isGtk2) {
|
||||||
|
logger.error("Unable to initialize AppIndicator for Arch linux, it requires GTK2! " +
|
||||||
|
"Please install libappindicator, for example: 'sudo pacman -S libappindicator'");
|
||||||
|
systemTrayMenu = null;
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
logger.error("Unable to initialize AppIndicator for Arch linux, it requires GTK3! " +
|
||||||
|
"Please install libappindicator3, for example: 'sudo pacman -S libappindicator3'"); // GTK3
|
||||||
|
systemTrayMenu = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (isTrayType(trayType, TrayType.AppIndicator)) {
|
if (isTrayType(trayType, TrayType.AppIndicator)) {
|
||||||
if (Gtk.isGtk2 && AppIndicator.isVersion3) {
|
if (Gtk.isGtk2 && AppIndicator.isVersion3) {
|
||||||
try {
|
try {
|
||||||
@ -708,9 +751,12 @@ class SystemTray {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (isJavaFxLoaded) {
|
if (isJavaFxLoaded) {
|
||||||
if (isTrayType(trayType, TrayType.GtkStatusIcon)) {
|
if (isTrayType(trayType, TrayType.GtkStatusIcon)) {
|
||||||
// set a property so that GTK (if necessary) can set the name
|
// set a property so that GTK (if necessary) can set the name of the system tray icon
|
||||||
System.setProperty("SystemTray_GTK_SET_NAME", "true");
|
System.setProperty("SystemTray_GTK_SET_NAME", "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,6 +768,8 @@ class SystemTray {
|
|||||||
Swt.init();
|
Swt.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ((isJavaFxLoaded || isSwtLoaded) && SwingUtilities.isEventDispatchThread()) {
|
if ((isJavaFxLoaded || isSwtLoaded) && SwingUtilities.isEventDispatchThread()) {
|
||||||
// oh boy! This WILL NOT WORK. Let the dev know
|
// oh boy! This WILL NOT WORK. Let the dev know
|
||||||
logger.error("SystemTray initialization for JavaFX or SWT **CAN NOT** occur on the Swing Event Dispatch Thread " +
|
logger.error("SystemTray initialization for JavaFX or SWT **CAN NOT** occur on the Swing Event Dispatch Thread " +
|
||||||
@ -733,6 +781,8 @@ class SystemTray {
|
|||||||
|
|
||||||
// javaFX and SWT should not start on the EDT!!
|
// javaFX and SWT should not start on the EDT!!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if it's linux + native menus must not start on the EDT!
|
// if it's linux + native menus must not start on the EDT!
|
||||||
// _AwtTray must be constructed on the EDT however...
|
// _AwtTray must be constructed on the EDT however...
|
||||||
if (isJavaFxLoaded || isSwtLoaded ||
|
if (isJavaFxLoaded || isSwtLoaded ||
|
||||||
@ -770,6 +820,8 @@ class SystemTray {
|
|||||||
|
|
||||||
systemTrayMenu = reference.get();
|
systemTrayMenu = reference.get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// verify that we have what we are expecting.
|
// verify that we have what we are expecting.
|
||||||
if (OS.isWindows() && systemTrayMenu instanceof SwingUI) {
|
if (OS.isWindows() && systemTrayMenu instanceof SwingUI) {
|
||||||
// this configuration is OK.
|
// this configuration is OK.
|
||||||
@ -922,9 +974,7 @@ class SystemTray {
|
|||||||
setImage(bimage);
|
setImage(bimage);
|
||||||
|
|
||||||
Component[] menuComponents = jMenu.getMenuComponents();
|
Component[] menuComponents = jMenu.getMenuComponents();
|
||||||
for (int i = 0, menuComponentsLength = menuComponents.length; i < menuComponentsLength; i++) {
|
for (Component c : menuComponents) {
|
||||||
final Component c = menuComponents[i];
|
|
||||||
|
|
||||||
if (c instanceof JMenu) {
|
if (c instanceof JMenu) {
|
||||||
menu.add((JMenu) c);
|
menu.add((JMenu) c);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user