Bug 465660 - [GTK3] Add support for setting preference on dark theme in
SWT/GTK3

Change-Id: I88b05320f1517a21654a1f7bfee781d30eab8a61
Signed-off-by: Sopot Cela <scela@redhat.com>
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 5d59b5a..4d93979 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
@@ -650,6 +650,12 @@
 	public static final byte[] xalign = ascii("xalign");
 	public static final byte[] ypad = ascii("ypad");
 	public static final byte[] GTK_PRINT_SETTINGS_OUTPUT_URI = ascii("output-uri");
+	
+	/*
+	 * Needed to tell GTK 3 to prefer a dark or light theme in the UI.
+	 * Improves the look of the Eclipse Dark theme in GTK 3 systems. 
+	 */
+	public static final byte[] gtk_application_prefer_dark_theme = ascii("gtk-application-prefer-dark-theme");
 
 	/* Named icons.
 	 * See https://docs.google.com/spreadsheet/pub?key=0AsPAM3pPwxagdGF4THNMMUpjUW5xMXZfdUNzMXhEa2c&output=html
@@ -16761,4 +16767,17 @@
 		lock.unlock();
 	}
 }
+
+/*
+ * Method used to hint GTK 3 to natively 
+ * prefer a dark or light theme.
+ */
+public static final void setDarkThemePreferred(boolean preferred){
+	if (!GTK3) return; //only applicable to GTK3
+	gdk_flush();
+	g_object_set(gtk_settings_get_default(), gtk_application_prefer_dark_theme,
+			preferred, 0);
+	g_object_notify(gtk_settings_get_default(),
+			gtk_application_prefer_dark_theme);
+}
 }