From f143dff1fdc93bd79587ab62776b5040b89a13c3 Mon Sep 17 00:00:00 2001 From: nathan Date: Sat, 15 Jul 2017 18:37:03 +0200 Subject: [PATCH] Added isGtk2, isGtk3, and isGtkLoaded to OSUtil.DesktopEnv, so that one can query to see GTK status without loading GTK. --- src/dorkbox/util/OSUtil.java | 16 ++++++++++++++++ src/dorkbox/util/jna/linux/GtkLoader.java | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/dorkbox/util/OSUtil.java b/src/dorkbox/util/OSUtil.java index 1dc94cd..f1be714 100644 --- a/src/dorkbox/util/OSUtil.java +++ b/src/dorkbox/util/OSUtil.java @@ -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, diff --git a/src/dorkbox/util/jna/linux/GtkLoader.java b/src/dorkbox/util/jna/linux/GtkLoader.java index d10d5a8..e69b579 100644 --- a/src/dorkbox/util/jna/linux/GtkLoader.java +++ b/src/dorkbox/util/jna/linux/GtkLoader.java @@ -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, " +