Added isGtk2, isGtk3, and isGtkLoaded to OSUtil.DesktopEnv, so that one

can query to see GTK status without loading GTK.
This commit is contained in:
nathan 2017-07-15 18:37:03 +02:00
parent 92c0a7f42a
commit f143dff1fd
2 changed files with 22 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import java.io.PrintStream;
import java.util.LinkedList;
import java.util.List;
import dorkbox.util.jna.linux.Gtk;
import dorkbox.util.process.ShellProcessBuilder;
/**
@ -398,6 +399,21 @@ class OSUtil {
public static
class DesktopEnv {
/**
* Determine if the application is running via GTK2. This does not cause GTK to load, where calls to {@link Gtk#isGtk2} will
*/
public static volatile boolean isGtk2 = false;
/**
* Determine if the application is running via GTK3. This does not cause GTK to load, where calls to {@link Gtk#isGtk3} will
*/
public static volatile boolean isGtk3 = false;
/**
* Determine if the application has loaded GTK yet or not. This does not cause GTK to load, where calls to {@link Gtk#isLoaded} will
*/
public static volatile boolean isGtkLoaded = false;
public enum Env {
Gnome,
KDE,

View File

@ -23,6 +23,7 @@ import com.sun.jna.Function;
import com.sun.jna.NativeLibrary;
import dorkbox.util.OS;
import dorkbox.util.OSUtil;
import dorkbox.util.Swt;
import dorkbox.util.jna.JnaHelper;
@ -192,6 +193,11 @@ class GtkLoader {
MICRO = 0;
}
// This is so that queries for the GTK version DO NOT try to load GTK
OSUtil.DesktopEnv.isGtk2 = isGtk2;
OSUtil.DesktopEnv.isGtk3 = isGtk3;
OSUtil.DesktopEnv.isGtkLoaded = isLoaded;
if (shouldLoadGtk) {
if (!_isLoaded) {
throw new RuntimeException("We apologize for this, but we are unable to determine the GTK library is in use, " +