Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c69
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h3
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h5
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java34
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java56
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java30
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java100
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java10
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java18
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java15
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java62
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java22
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java19
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java62
22 files changed, 481 insertions, 98 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
index 21649e98d3..fd98017485 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -7341,6 +7341,33 @@ fail:
}
#endif
+#ifndef NO__1gdk_1rgba_1parse
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1rgba_1parse)
+ (JNIEnv *env, jclass that, jobject arg0, jbyteArray arg1)
+{
+ GdkRGBA _arg0, *lparg0=NULL;
+ jbyte *lparg1=NULL;
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gdk_1rgba_1parse_FUNC);
+ if (arg0) if ((lparg0 = getGdkRGBAFields(env, arg0, &_arg0)) == NULL) goto fail;
+ if (arg1) if ((lparg1 = (*env)->GetByteArrayElements(env, arg1, NULL)) == NULL) goto fail;
+/*
+ rc = (jintLong)gdk_rgba_parse((GdkRGBA *)lparg0, (const gchar *)lparg1);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gdk_rgba_parse)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(GdkRGBA *, const gchar *))fp)((GdkRGBA *)lparg0, (const gchar *)lparg1);
+ }
+ }
+fail:
+ if (arg1 && lparg1) (*env)->ReleaseByteArrayElements(env, arg1, lparg1, 0);
+ if (arg0 && lparg0) setGdkRGBAFields(env, arg0, lparg0);
+ OS_NATIVE_EXIT(env, that, _1gdk_1rgba_1parse_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gdk_1rgba_1to_1string
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gdk_1rgba_1to_1string)
(JNIEnv *env, jclass that, jobject arg0)
@@ -10145,6 +10172,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1css_1provider_1new)
}
#endif
+#ifndef NO__1gtk_1css_1provider_1to_1string
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1css_1provider_1to_1string)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1css_1provider_1to_1string_FUNC);
+/*
+ rc = (jintLong)gtk_css_provider_to_string(arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_css_provider_to_string)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gtk_1css_1provider_1to_1string_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1dialog_1add_1button
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1dialog_1add_1button)
(JNIEnv *env, jclass that, jintLong arg0, jbyteArray arg1, jint arg2)
@@ -18147,6 +18194,26 @@ JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1modifier_1style)
}
#endif
+#ifndef NO__1gtk_1widget_1get_1name
+JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1name)
+ (JNIEnv *env, jclass that, jintLong arg0)
+{
+ jintLong rc = 0;
+ OS_NATIVE_ENTER(env, that, _1gtk_1widget_1get_1name_FUNC);
+/*
+ rc = (jintLong)gtk_widget_get_name(arg0);
+*/
+ {
+ OS_LOAD_FUNCTION(fp, gtk_widget_get_name)
+ if (fp) {
+ rc = (jintLong)((jintLong (CALLING_CONVENTION*)(jintLong))fp)(arg0);
+ }
+ }
+ OS_NATIVE_EXIT(env, that, _1gtk_1widget_1get_1name_FUNC);
+ return rc;
+}
+#endif
+
#ifndef NO__1gtk_1widget_1get_1pango_1context
JNIEXPORT jintLong JNICALL OS_NATIVE(_1gtk_1widget_1get_1pango_1context)
(JNIEnv *env, jclass that, jintLong arg0)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
index 18d68f573c..f537d47c06 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.h
@@ -188,7 +188,7 @@
#define NO__1g_1object_1set__I_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2I
#define NO__1g_1object_1set__J_3BLorg_eclipse_swt_internal_gtk_GdkRGBA_2J
#define NO__1gdk_1rgba_1to_1string
-
+#define NO__1gdk_1rgba_1parse
#endif
#include "os_custom.h"
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
index a3d0c061ee..8676a92684 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_custom.h
@@ -300,6 +300,7 @@
#define gdk_region_polygon_LIB LIB_GDK
#define gdk_region_get_rectangles_LIB LIB_GDK
#define gdk_rgba_to_string_LIB LIB_GDK
+#define gdk_rgba_parse_LIB LIB_GDK
#define gdk_screen_get_default_LIB LIB_GDK
#define gdk_screen_get_monitor_at_point_LIB LIB_GDK
#define gdk_screen_get_monitor_at_window_LIB LIB_GDK
@@ -352,6 +353,7 @@
#define gtk_window_set_skip_taskbar_hint_LIB LIB_GTK
#define gtk_widget_is_composited_LIB LIB_GTK
#define gtk_widget_get_allocation_LIB LIB_GTK
+#define gtk_widget_get_name_LIB LIB_GTK
#define gtk_widget_size_request_LIB LIB_GTK
#define gtk_widget_get_default_style_LIB LIB_GTK
#define gtk_widget_get_preferred_size_LIB LIB_GTK
@@ -519,6 +521,7 @@
#define gtk_cell_renderer_get_preferred_height_for_width_LIB LIB_GTK
#define gtk_css_provider_load_from_data_LIB LIB_GTK
#define gtk_css_provider_new_LIB LIB_GTK
+#define gtk_css_provider_to_string_LIB LIB_GTK
#define gtk_icon_set_render_icon_pixbuf_LIB LIB_GTK
#define gtk_drag_set_icon_surface_LIB LIB_GTK
#define gtk_accel_label_set_accel_LIB LIB_GTK
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
index 2c786a8608..da376e5ece 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -554,6 +554,7 @@ char * OS_nativeFunctionNames[] = {
"_1gdk_1region_1subtract",
"_1gdk_1region_1union",
"_1gdk_1region_1union_1with_1rect",
+ "_1gdk_1rgba_1parse",
"_1gdk_1rgba_1to_1string",
"_1gdk_1screen_1get_1default",
"_1gdk_1screen_1get_1monitor_1at_1point",
@@ -730,6 +731,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1container_1set_1border_1width",
"_1gtk_1css_1provider_1load_1from_1data",
"_1gtk_1css_1provider_1new",
+ "_1gtk_1css_1provider_1to_1string",
"_1gtk_1dialog_1add_1button",
"_1gtk_1dialog_1run",
"_1gtk_1drag_1begin",
@@ -1354,6 +1356,7 @@ char * OS_nativeFunctionNames[] = {
"_1gtk_1widget_1get_1has_1window",
"_1gtk_1widget_1get_1mapped",
"_1gtk_1widget_1get_1modifier_1style",
+ "_1gtk_1widget_1get_1name",
"_1gtk_1widget_1get_1pango_1context",
"_1gtk_1widget_1get_1parent",
"_1gtk_1widget_1get_1parent_1window",
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
index 63d5db4bfb..71869def02 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others. All rights reserved.
+ * Copyright (c) 2000, 2016 IBM Corporation and others. All rights reserved.
* The contents of this file are made available under the terms
* of the GNU Lesser General Public License (LGPL) Version 2.1 that
* accompanies this distribution (lgpl-v21.txt). The LGPL is also
@@ -564,6 +564,7 @@ typedef enum {
_1gdk_1region_1subtract_FUNC,
_1gdk_1region_1union_FUNC,
_1gdk_1region_1union_1with_1rect_FUNC,
+ _1gdk_1rgba_1parse_FUNC,
_1gdk_1rgba_1to_1string_FUNC,
_1gdk_1screen_1get_1default_FUNC,
_1gdk_1screen_1get_1monitor_1at_1point_FUNC,
@@ -740,6 +741,7 @@ typedef enum {
_1gtk_1container_1set_1border_1width_FUNC,
_1gtk_1css_1provider_1load_1from_1data_FUNC,
_1gtk_1css_1provider_1new_FUNC,
+ _1gtk_1css_1provider_1to_1string_FUNC,
_1gtk_1dialog_1add_1button_FUNC,
_1gtk_1dialog_1run_FUNC,
_1gtk_1drag_1begin_FUNC,
@@ -1364,6 +1366,7 @@ typedef enum {
_1gtk_1widget_1get_1has_1window_FUNC,
_1gtk_1widget_1get_1mapped_FUNC,
_1gtk_1widget_1get_1modifier_1style_FUNC,
+ _1gtk_1widget_1get_1name_FUNC,
_1gtk_1widget_1get_1pango_1context_FUNC,
_1gtk_1widget_1get_1parent_FUNC,
_1gtk_1widget_1get_1parent_1window_FUNC,
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 80271a431e..9973a90ffa 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
@@ -1753,6 +1753,16 @@ public static final boolean gtk_widget_get_sensitive(long /*int*/ widget) {
lock.unlock();
}
}
+/** @method flags=dynamic */
+public static final native long /*int*/ _gtk_widget_get_name(long /*int*/ widget);
+public static final long /*int*/ gtk_widget_get_name(long /*int*/ widget) {
+ lock.lock();
+ try {
+ return _gtk_widget_get_name(widget);
+ } finally {
+ lock.unlock();
+ }
+}
public static final native void _GTK_WIDGET_SET_FLAGS(long /*int*/ wid, int flag);
public static final void GTK_WIDGET_SET_FLAGS(long /*int*/ wid, int flag) {
lock.lock();
@@ -5460,6 +5470,20 @@ public static final long /*int*/ gdk_rgba_to_string(GdkRGBA rgba) {
lock.unlock();
}
}
+/**
+ * @method flags=dynamic
+ * @param rgba cast=(GdkRGBA *)
+ * @param property cast=(const gchar *)
+ */
+public static final native long /*int*/ _gdk_rgba_parse(GdkRGBA rgba, byte[] property);
+public static final long /*int*/ gdk_rgba_parse(GdkRGBA rgba, byte[] property) {
+ lock.lock();
+ try {
+ return _gdk_rgba_parse(rgba, property);
+ } finally {
+ lock.unlock();
+ }
+}
/** @method flags=dynamic */
public static final native long /*int*/ _gdk_screen_get_default();
public static final long /*int*/ gdk_screen_get_default() {
@@ -9106,6 +9130,16 @@ public static final long /*int*/gtk_css_provider_new() {
lock.unlock();
}
}
+/** @method flags=dynamic */
+public static final native long /*int*/ _gtk_css_provider_to_string(long /*int*/ provider);
+public static final long /*int*/gtk_css_provider_to_string(long /*int*/ provider) {
+ lock.lock();
+ try {
+ return _gtk_css_provider_to_string(provider);
+ } finally {
+ lock.unlock();
+ }
+}
/**
* @method flags=dynamic
* @param screen cast=(GdkScreen *)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
index be06855b9b..9cfffdc9ca 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java
@@ -65,6 +65,7 @@ public class Combo extends Composite {
String [] items = new String [0];
boolean selectionAdded;
int indexSelected;
+ GdkRGBA background;
/**
* the operating system limit for the number of characters
* that the text field in an instance of this class can hold
@@ -888,6 +889,23 @@ public int getCaretPosition () {
}
@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground();
+ }
+}
+
+@Override
GdkColor getForegroundColor () {
return getTextColor ();
}
@@ -1854,30 +1872,28 @@ public void select (int index) {
@Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
- //Note, in Gtk3's CSS, we can't access all of the sub-widgets inside GtkComboBox.
- //Some have to be themed by the global system theme.
-
+ // CSS to be parsed for various widgets within Combo
+ background = rgba;
+ String css = "* {\n";
+ if (rgba != null) {
+ String color = gtk_rgba_to_css_string (rgba);
+ css += "background: " + color + ";}";
+ }
if (entryHandle == 0 || (style & SWT.READ_ONLY) != 0) {
- long /*int*/ buttonHandle = findButtonHandle (); //get's the GtkEntry handle.
- //TODO Refactor this and Button#setBackground, they have similar CSS construction code.
- String css = "* {\n";
- if (rgba != null) {
- String color = gtk_rgba_to_css_string (rgba);
- css += "background: " + color + ";\n";
- }
- css += "}\n";
- gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(buttonHandle), css); //Apply to Entry
+ // For read only Combos, we can just apply the background CSS to the GtkToggleButton.
+ gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(buttonHandle), css);
} else {
- setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
- super.setBackgroundColor (OS.gtk_widget_get_style_context (entryHandle), entryHandle, rgba);
- //Note, we can't get to the GtkToggleButton inside GtkComboBoxText, as it's in a private stuct.
- //We thus rely on global theme to style it via: GtkToggleButton { background: red}
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ // For GTK3.16+, only the GtkEntry needs to be themed.
+ gtk_css_provider_load_from_css (OS.gtk_widget_get_style_context(entryHandle), css);
+ } else {
+ // Maintain GTK3.14- functionality
+ setBackgroundColorGradient (OS.gtk_widget_get_style_context (entryHandle), handle, rgba);
+ super.setBackgroundColor (OS.gtk_widget_get_style_context (entryHandle), entryHandle, rgba);
+ }
}
-
- //Set the background color of the text of the drop down menu.
+ // Set the background color of the text of the drop down menu.
OS.g_object_set (textRenderer, OS.background_rgba, rgba, 0);
- //NOTE: We can't get to the actual menu background, beacuse it is in a private struct in GtkComboBoxText.
- //Thus we rely for the underlying theme to theme the menu via : GtkComboBoxText * { background: xzy }
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
index d893308395..7e08198642 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java
@@ -64,7 +64,6 @@ public class Composite extends Scrollable {
Layout layout;
Control[] tabList;
int layoutCount, backgroundMode;
- GdkRGBA background;
static final String NO_INPUT_METHOD = "org.eclipse.swt.internal.gtk.noInputMethod"; //$NON-NLS-1$
@@ -666,23 +665,6 @@ public Rectangle getClientArea () {
return super.getClientArea();
}
-@Override
-GdkColor getContextBackground () {
- if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
- if (background != null) {
- GdkColor color = new GdkColor ();
- color.red = (short)(background.red * 0xFFFF);
- color.green = (short)(background.green * 0xFFFF);
- color.blue = (short)(background.blue * 0xFFFF);
- return color;
- } else {
- return display.COLOR_WIDGET_BACKGROUND;
- }
- } else {
- return super.getContextBackground();
- }
-}
-
/**
* Returns layout which is associated with the receiver, or
* null if one has not been set.
@@ -1465,18 +1447,6 @@ public void setBackgroundMode (int mode) {
}
@Override
-void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
- if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
- background = rgba;
- String color = gtk_rgba_to_css_string(background);
- String css = "SwtFixed {background-color: " + color + "}";
- gtk_css_provider_load_from_css(context, css);
- } else {
- super.setBackgroundColor(context, handle, rgba);
- }
-}
-
-@Override
int setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
int result = super.setBounds (x, y, width, height, move, resize);
if ((result & RESIZED) != 0 && layout != null) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index c9719bc4b1..3e33e20be1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -2577,17 +2577,25 @@ public Image getBackgroundImage () {
GdkColor getContextBackground () {
long /*int*/ fontHandle = fontHandle ();
- long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
- GdkRGBA rgba = new GdkRGBA ();
- OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
- if (rgba.alpha == 0) {
- return display.COLOR_WIDGET_BACKGROUND;
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (provider != 0) {
+ return gtk_css_parse_background (provider);
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ long /*int*/ context = OS.gtk_widget_get_style_context (fontHandle);
+ GdkRGBA rgba = new GdkRGBA ();
+ OS.gtk_style_context_get_background_color (context, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ if (rgba.alpha == 0) {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ GdkColor color = new GdkColor ();
+ color.red = (short)(rgba.red * 0xFFFF);
+ color.green = (short)(rgba.green * 0xFFFF);
+ color.blue = (short)(rgba.blue * 0xFFFF);
+ return color;
}
- GdkColor color = new GdkColor ();
- color.red = (short)(rgba.red * 0xFFFF);
- color.green = (short)(rgba.green * 0xFFFF);
- color.blue = (short)(rgba.blue * 0xFFFF);
- return color;
}
GdkColor getContextColor () {
@@ -4031,7 +4039,22 @@ private void _setBackground (Color color) {
}
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
- OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ long /*int*/ str = OS.gtk_widget_get_name (handle);
+ String name;
+ if (str == 0) {
+ name = "*";
+ } else {
+ int length = OS.strlen (str);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, str, length);
+ name = new String (Converter.mbcsToWcs (null, buffer));
+ }
+ String css = name + " {background-color: " + gtk_rgba_to_css_string (rgba) + ";}";
+ gtk_css_provider_load_from_css (context, css);
+ } else {
+ OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_NORMAL, rgba);
+ }
}
void setBackgroundColorGradient (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
@@ -4046,6 +4069,61 @@ void setBackgroundColorGradient (long /*int*/ context, long /*int*/ handle, GdkR
gtk_css_provider_load_from_css (context, css);
}
+GdkColor gtk_css_parse_background (long /*int*/ provider) {
+ String shortOutput;
+ int startIndex;
+ GdkColor color = new GdkColor ();
+ GdkRGBA rgba = new GdkRGBA ();
+ // Fetch the CSS in char/string format from the GtkCssProvider.
+ long /*int*/ str = OS.gtk_css_provider_to_string (provider);
+ if (str == 0) return display.COLOR_WIDGET_BACKGROUND;
+ int length = OS.strlen (str);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, str, length);
+ String cssOutput = new String (Converter.mbcsToWcs (null, buffer));
+
+ /* Although we only set the property "background-color", we can handle
+ * the "background" property as well. We check for either of these cases
+ * and extract a GdkRGBA object from the parsed CSS string.
+ */
+ if (cssOutput.contains ("background-color:")) {
+ startIndex = cssOutput.indexOf ("background-color:");
+ shortOutput = cssOutput.substring (startIndex + 18);
+ // Double check to make sure with have a valid rgb/rgba property
+ if (shortOutput.contains ("rgba") || shortOutput.contains ("rgb")) {
+ rgba = gtk_css_property_to_rgba (shortOutput);
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else if (cssOutput.contains ("background:")) {
+ startIndex = cssOutput.indexOf ("background:");
+ shortOutput = cssOutput.substring (startIndex + 13);
+ // Double check to make sure with have a valid rgb/rgba property
+ if (shortOutput.contains ("rgba") || shortOutput.contains ("rgb")) {
+ rgba = gtk_css_property_to_rgba (shortOutput);
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ }
+ color.red = (short)(rgba.red * 0xFFFF);
+ color.green = (short)(rgba.green * 0xFFFF);
+ color.blue = (short)(rgba.blue * 0xFFFF);
+ return color;
+}
+
+GdkRGBA gtk_css_property_to_rgba(String property) {
+ /* Here we convert rgb(...) or rgba(...) properties
+ * into GdkRGBA objects using gdk_rgba_parse(). Note
+ * that we still need to remove the ";" character from the
+ * input string.
+ */
+ GdkRGBA rgba = new GdkRGBA ();
+ String [] propertyParsed = new String [1];
+ propertyParsed = property.split (";");
+ OS.gdk_rgba_parse (rgba, Converter.wcsToMbcs (null, propertyParsed[0], true));
+ return rgba;
+}
+
void gtk_css_provider_load_from_css (long /*int*/ context, String css) {
/* Utility function. */
//@param css : a 'css java' string like "{\nbackground: red;\n}".
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
index 12bca5452a..bede3cecbc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/DateTime.java
@@ -1361,7 +1361,12 @@ void setBackgroundColor (GdkColor color) {
if (isCalendar () && !OS.GTK3) {
OS.gtk_widget_modify_base (containerHandle, 0, color);
} else {
- super.setBackgroundColor (color);
+ if (isCalendar() && (OS.GTK_VERSION >= OS.VERSION(3, 16, 0))) {
+ super.setBackgroundColor (calendarHandle, color);
+ } else {
+ super.setBackgroundColor (color);
+ }
+
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
index adb91ef55f..1d11275f1b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ExpandBar.java
@@ -427,6 +427,16 @@ void reskinChildren (int flags) {
}
@Override
+void setWidgetBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ GdkColor color = (state & BACKGROUND) != 0 ? getBackgroundColor () : null;
+ super.setBackgroundColor (color);
+ } else {
+ super.setWidgetBackground();
+ }
+}
+
+@Override
void setFontDescription (long /*int*/ font) {
super.setFontDescription (font);
for (int i = 0; i < itemCount; i++) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
index 1e256003cc..e9b9e9712a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Group.java
@@ -294,10 +294,17 @@ void releaseWidget () {
@Override
void setBackgroundColor (GdkColor color) {
- super.setBackgroundColor (color);
- setBackgroundColor (fixedHandle, color);
- // Bug 453827 - client handle should also be painted as it's visible to the user now.
- setBackgroundColor (clientHandle, color);
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ // With CSS theming we only need to set the background color
+ // of the parent SwtFixed container.
+ setBackgroundColor (fixedHandle, color);
+ return;
+ } else {
+ super.setBackgroundColor (color);
+ setBackgroundColor (fixedHandle, color);
+ // Bug 453827 - client handle should also be painted as it's visible to the user now.
+ setBackgroundColor (clientHandle, color);
+ }
}
@Override
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
index c971970dab..c8ca500306 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Label.java
@@ -484,9 +484,11 @@ private void gtk_label_set_align (float xalign, float yalign) {
@Override
void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
- setBackgroundColor(fixedHandle, color);
- if (labelHandle != 0) setBackgroundColor(labelHandle, color);
- if (imageHandle != 0) setBackgroundColor(imageHandle, color);
+ if (OS.GTK_VERSION < OS.VERSION(3, 16, 0)) {
+ setBackgroundColor(fixedHandle, color);
+ if (labelHandle != 0) setBackgroundColor(labelHandle, color);
+ if (imageHandle != 0) setBackgroundColor(imageHandle, color);
+ }
}
@Override
@@ -640,6 +642,16 @@ public void setText (String string) {
}
@Override
+void setWidgetBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ GdkColor color = (state & BACKGROUND) != 0 ? getBackgroundColor () : null;
+ super.setBackgroundColor (color);
+ } else {
+ super.setWidgetBackground();
+ }
+}
+
+@Override
void showWidget () {
super.showWidget ();
if (frameHandle != 0) OS.gtk_widget_show (frameHandle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
index 08d7c5cc3a..d558dea7f6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Link.java
@@ -378,6 +378,21 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ event)
}
@Override
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context(widget);
+ GtkAllocation allocation = new GtkAllocation();
+ OS.gtk_widget_get_allocation (widget, allocation);
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ // We specify a 0 value for x & y as we want the whole widget to be
+ // colored, not some portion of it.
+ OS.gtk_render_background(context, cairo, 0, 0, width, height);
+ }
+ return super.gtk_draw(widget, cairo);
+}
+
+@Override
long /*int*/ gtk_event_after (long /*int*/ widget, long /*int*/ gdkEvent) {
long /*int*/ result = super.gtk_event_after (widget, gdkEvent);
GdkEvent event = new GdkEvent ();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index ad9ae65a7e..bf3f38b0a7 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -251,6 +251,21 @@ long /*int*/ gtk_button_release_event (long /*int*/ widget, long /*int*/ eventPt
}
@Override
+long /*int*/ gtk_draw (long /*int*/ widget, long /*int*/ cairo) {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ long /*int*/ context = OS.gtk_widget_get_style_context(widget);
+ GtkAllocation allocation = new GtkAllocation();
+ OS.gtk_widget_get_allocation (widget, allocation);
+ int width = (state & ZERO_WIDTH) != 0 ? 0 : allocation.width;
+ int height = (state & ZERO_HEIGHT) != 0 ? 0 : allocation.height;
+ // We specify a 0 value for x & y as we want the whole widget to be
+ // colored, not some portion of it.
+ OS.gtk_render_background(context, cairo, 0, 0, width, height);
+ }
+ return super.gtk_draw(widget, cairo);
+}
+
+@Override
long /*int*/ gtk_focus_in_event (long /*int*/ widget, long /*int*/ event) {
long /*int*/ result = super.gtk_focus_in_event (widget, event);
if (result != 0) return result;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index 60856c873d..f81e0674fd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -725,7 +725,11 @@ void createHandle (int index) {
if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.SHELL_TRIM)) == 0) {
OS.gtk_container_set_border_width (shellHandle, 1);
if (OS.GTK3) {
- OS.gtk_widget_override_background_color (shellHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ if (OS.GTK_VERSION >= OS.VERSION (3, 16, 0)) {
+ setBackgroundColor (OS.gtk_widget_get_style_context(shellHandle), shellHandle, new GdkRGBA());
+ } else {
+ OS.gtk_widget_override_background_color (shellHandle, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ }
} else {
GdkColor color = new GdkColor ();
OS.gtk_style_get_black (OS.gtk_widget_get_style (shellHandle), color);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
index 5208f87067..312f013e10 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Spinner.java
@@ -65,6 +65,10 @@ public class Spinner extends Composite {
static {
LIMIT = 0x7FFFFFFF;
}
+ /* Spinner uses non-standard CSS to set its background color, so we need
+ * a global variable to keep track of its background color.
+ */
+ GdkRGBA background;
/**
* Constructs a new instance of this class given its parent
@@ -916,7 +920,25 @@ void removeVerifyListener (VerifyListener listener) {
}
@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground ();
+ }
+}
+
+@Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
+ background = rgba;
setBackgroundColorGradient (context, handle, rgba);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
index a0c8046255..67bf2d7e58 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java
@@ -80,6 +80,7 @@ public class Table extends Composite {
boolean firstCustomDraw;
int drawState, drawFlags;
GdkColor drawForeground;
+ GdkRGBA background;
boolean ownerDraw, ignoreSize, ignoreAccessibility;
static final int CHECKED_COLUMN = 0;
@@ -1327,6 +1328,25 @@ public TableColumn [] getColumns () {
return result;
}
+@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ // For Tables and Trees, the default background is
+ // COLOR_LIST_BACKGROUND instead of COLOR_WIDGET_BACKGROUND.
+ return display.COLOR_LIST_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground ();
+ }
+}
+
TableItem getFocusItem () {
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_tree_view_get_cursor (handle, path, null);
@@ -3093,17 +3113,39 @@ void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
if (!OS.GTK3) {
OS.gtk_widget_modify_base (handle, 0, color);
+ }
+}
+
+@Override
+void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
+ /* Setting the background color overrides the selected background color.
+ * To prevent this, we need to re-set the default. This can be done with CSS
+ * on GTK3.16+, or by using GtkStateFlags as an argument to
+ * gtk_widget_override_background_color() on versions of GTK3 less than 3.16.
+ */
+ if (rgba == null) {
+ GdkColor temp = getDisplay().COLOR_LIST_BACKGROUND;
+ GdkRGBA background = new GdkRGBA ();
+ background.alpha = 1.0;
+ background.red = (temp.red & 0xFFFF) / (float)0xFFFF;
+ background.green = (temp.green & 0xFFFF) / (float)0xFFFF;
+ background.blue = (temp.blue & 0xFFFF) / (float)0xFFFF;
+ } else {
+ background = rgba;
+ }
+ GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION;
+ GdkRGBA selectedBackground = new GdkRGBA ();
+ selectedBackground.alpha = 1;
+ selectedBackground.red = (defaultColor.red & 0xFFFF) / (float)0xFFFF;
+ selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF;
+ selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF;
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(rgba) + ";}\n"
+ + "GtkTreeView:selected {background-color: " + gtk_rgba_to_css_string(selectedBackground) + ";}";
+ gtk_css_provider_load_from_css(context, css);
} else {
- // Setting the background color overrides the selected background color
- // so we have to reset it the default.
- GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION;
- GdkRGBA selectedBackground = new GdkRGBA ();
- selectedBackground.alpha = 1;
- selectedBackground.red = (defaultColor.red & 0xFFFF) / (float)0xFFFF;
- selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF;
- selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF;
-
- OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground);
+ super.setBackgroundColor(context, handle, rgba);
+ OS.gtk_widget_override_background_color(handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground);
}
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
index ec609a2dfa..9640d922ef 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Text.java
@@ -98,6 +98,10 @@ public class Text extends Scrollable {
LIMIT = 0x7FFFFFFF;
DELIMITER = "\n";
}
+ /* Text uses non-standard CSS to set its background color, so we need
+ * a global variable to keep track of its background color.
+ */
+ GdkRGBA background;
/**
* Constructs a new instance of this class given its parent
@@ -2145,7 +2149,25 @@ void setBackgroundColor (GdkColor color) {
}
@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ return display.COLOR_WIDGET_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground ();
+ }
+}
+
+@Override
void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
+ background = rgba;
if ((style & SWT.MULTI) != 0) {
super.setBackgroundColor (context, handle, rgba);
return;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
index 7ce46cf7c3..5a55c110c8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolBar.java
@@ -132,7 +132,7 @@ void createHandle (int index) {
handle = OS.gtk_toolbar_new ();
if (handle == 0) error (SWT.ERROR_NO_HANDLES);
OS.gtk_container_add (fixedHandle, handle);
- if ((style & SWT.FLAT) != 0) {
+ if ((style & SWT.FLAT) != 0 && !OS.GTK3) {
byte [] swt_toolbar_flat = Converter.wcsToMbcs (null, "swt-toolbar-flat", true);
OS.gtk_widget_set_name (handle, swt_toolbar_flat);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
index ddbef7dbb9..1870a87315 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tracker.java
@@ -12,9 +12,10 @@ package org.eclipse.swt.widgets;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.gtk.*;
-import org.eclipse.swt.graphics.*;
import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.gtk.*;
/**
* Instances of this class implement rubber banding rectangles that are
@@ -754,7 +755,19 @@ public boolean open () {
OS.gtk_widget_realize (overlay);
long /*int*/ overlayWindow = OS.gtk_widget_get_window (overlay);
OS.gdk_window_set_override_redirect (overlayWindow, true);
- OS.gtk_widget_override_background_color (overlay, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ if (OS.GTK_VERSION < OS.VERSION (3, 16, 0)) {
+ OS.gtk_widget_override_background_color (overlay, OS.GTK_STATE_FLAG_NORMAL, new GdkRGBA());
+ } else {
+ String css = "GtkWindow {background-color: rgb(0,0,0);}";
+ long /*int*/ provider = 0;
+ long /*int*/ context = OS.gtk_widget_get_style_context (overlay);
+ if (provider == 0) {
+ provider = OS.gtk_css_provider_new ();
+ OS.gtk_style_context_add_provider (context, provider, OS.GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ OS.g_object_unref (provider);
+ }
+ OS.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (null, css, true), -1, null);
+ }
long /*int*/ region = OS.gdk_region_new ();
OS.gtk_widget_shape_combine_region (overlay, region);
OS.gtk_widget_input_shape_combine_region (overlay, region);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
index ec3b2509a6..fe94a05086 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java
@@ -89,6 +89,7 @@ public class Tree extends Composite {
boolean expandAll;
int drawState, drawFlags;
GdkColor drawForeground;
+ GdkRGBA background;
boolean ownerDraw, ignoreSize, ignoreAccessibility;
static final int ID_COLUMN = 0;
@@ -1326,6 +1327,25 @@ public TreeColumn [] getColumns () {
return result;
}
+@Override
+GdkColor getContextBackground () {
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ if (background != null) {
+ GdkColor color = new GdkColor ();
+ color.red = (short)(background.red * 0xFFFF);
+ color.green = (short)(background.green * 0xFFFF);
+ color.blue = (short)(background.blue * 0xFFFF);
+ return color;
+ } else {
+ // For Tables and Trees, the default background is
+ // COLOR_LIST_BACKGROUND instead of COLOR_WIDGET_BACKGROUND.
+ return display.COLOR_LIST_BACKGROUND;
+ }
+ } else {
+ return super.getContextBackground ();
+ }
+}
+
TreeItem getFocusItem () {
long /*int*/ [] path = new long /*int*/ [1];
OS.gtk_tree_view_get_cursor (handle, path, null);
@@ -3080,17 +3100,39 @@ void setBackgroundColor (GdkColor color) {
super.setBackgroundColor (color);
if (!OS.GTK3) {
OS.gtk_widget_modify_base (handle, 0, color);
+ }
+}
+
+@Override
+void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) {
+ /* Setting the background color overrides the selected background color.
+ * To prevent this, we need to re-set the default. This can be done with CSS
+ * on GTK3.16+, or by using GtkStateFlags as an argument to
+ * gtk_widget_override_background_color() on versions of GTK3 less than 3.16.
+ */
+ if (rgba == null) {
+ GdkColor temp = getDisplay().COLOR_LIST_BACKGROUND;
+ GdkRGBA background = new GdkRGBA ();
+ background.alpha = 1.0;
+ background.red = (temp.red & 0xFFFF) / (float)0xFFFF;
+ background.green = (temp.green & 0xFFFF) / (float)0xFFFF;
+ background.blue = (temp.blue & 0xFFFF) / (float)0xFFFF;
+ } else {
+ background = rgba;
+ }
+ GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION;
+ GdkRGBA selectedBackground = new GdkRGBA ();
+ selectedBackground.alpha = 1;
+ selectedBackground.red = (defaultColor.red & 0xFFFF) / (float)0xFFFF;
+ selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF;
+ selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF;
+ if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) {
+ String css = "GtkTreeView {background-color: " + gtk_rgba_to_css_string(rgba) + ";}\n"
+ + "GtkTreeView:selected {background-color: " + gtk_rgba_to_css_string(selectedBackground) + ";}";
+ gtk_css_provider_load_from_css(context, css);
} else {
- // Setting the background color overrides the selected background color
- // so we have to reset it the default.
- GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION;
- GdkRGBA selectedBackground = new GdkRGBA ();
- selectedBackground.alpha = 1;
- selectedBackground.red = (defaultColor.red & 0xFFFF) / (float)0xFFFF;
- selectedBackground.green = (defaultColor.green & 0xFFFF) / (float)0xFFFF;
- selectedBackground.blue = (defaultColor.blue & 0xFFFF) / (float)0xFFFF;
-
- OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground);
+ super.setBackgroundColor(context, handle, rgba);
+ OS.gtk_widget_override_background_color(handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground);
}
}

Back to the top