Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Williams2018-05-02 16:05:36 +0000
committerEric Williams2018-05-02 18:02:32 +0000
commit28eadb40942449b5b13e2a2cfce263f140e9d4f4 (patch)
tree122d77bfa64d60ec307e243c7ff83d317f2c7fbd /bundles/org.eclipse.swt/Eclipse SWT PI/gtk
parent6f7c898268e4449ff992db1dc518e7df9420ae6e (diff)
downloadeclipse.platform.swt-28eadb40942449b5b13e2a2cfce263f140e9d4f4.tar.gz
eclipse.platform.swt-28eadb40942449b5b13e2a2cfce263f140e9d4f4.tar.xz
eclipse.platform.swt-28eadb40942449b5b13e2a2cfce263f140e9d4f4.zip
Bug 534007: [GTK3] Support for detecting themes like in 4.7.3 (but
without the memory leaks) Check for the presence of the GTK_THEME environment variable. When loading system colors from the GTK CSS theme, we can make use of this information to load the proper theme information and dark variants, if necessary. Tested with the Adwaita and Arc themes (and their dark variants) on GTK3.22, X11 and Wayland. No AllNonBrowser JUnit tests fail. Change-Id: If3697495a941ac4e26fb2d714d4b221da65325a1 Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT PI/gtk')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
index 7b7685e406..b83491e7ba 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java
@@ -691,6 +691,28 @@ public class OS extends C {
*/
public static final boolean SWT_MENU_LOCATION_DEBUGGING;
+ /*
+ * Check for the GTK_THEME environment variable. If set, parse
+ * it to get the theme name and check if a dark variant is specified.
+ * We can make use of this information when loading SWT system colors.
+ * See bug 534007.
+ */
+ /**
+ * True if the GTK_THEME environment variable is specified
+ * and is non-empty.
+ */
+ public static final boolean GTK_THEME_SET;
+ /**
+ * A string containing the theme name supplied via the GTK_THEME
+ * environment variable. Otherwise this will contain an empty string.
+ */
+ public static final String GTK_THEME_NAME;
+ /**
+ * True if GTK_THEME_SET is true, and if the dark variant was
+ * specified via the GTK_THEME environment variable.
+ */
+ public static final boolean GTK_THEME_DARK;
+
/* Feature in Gtk: with the switch to GtkMenuItems from GtkImageMenuItems
* in Gtk3 came a small Gtk shortfall: a small amount of padding on the left hand
* side of MenuItems was added. This padding is not accessible to the developer,
@@ -720,6 +742,21 @@ public class OS extends C {
}
SWT_MENU_LOCATION_DEBUGGING = menuLocationDebuggingEnabled;
+ String gtkThemeProperty = "GTK_THEME";
+ String gtkThemeCheck = getEnvironmentalVariable(gtkThemeProperty);
+ boolean gtkThemeSet = false;
+ String gtkThemeName = "";
+ boolean gtkThemeDark = false;
+ if (gtkThemeCheck != null && !gtkThemeCheck.isEmpty()) {
+ gtkThemeSet = true;
+ gtkThemeDark = gtkThemeCheck.contains(":dark") ? true : false;
+ String [] themeNameSplit = gtkThemeCheck.split(":");
+ gtkThemeName = themeNameSplit[0];
+ }
+ GTK_THEME_SET = gtkThemeSet;
+ GTK_THEME_NAME = gtkThemeName;
+ GTK_THEME_DARK = gtkThemeDark;
+
System.setProperty("org.eclipse.swt.internal.gtk.version",
(GTK.GTK_VERSION >>> 16) + "." + (GTK.GTK_VERSION >>> 8 & 0xFF) + "." + (GTK.GTK_VERSION & 0xFF));
// set GDK backend if we are on X11

Back to the top