diff options
author | Xi Yan | 2018-06-27 15:21:15 +0000 |
---|---|---|
committer | Xi Yan | 2018-06-27 16:36:18 +0000 |
commit | f7e1f70a68b53c38b4752ebfcfa9076c216396e3 (patch) | |
tree | 253c8dd672e2fd2923a7158de70d563629dafe58 | |
parent | abf5602e800498ad60816c3115dd592ad24b5fe3 (diff) | |
download | eclipse.platform.swt-f7e1f70a68b53c38b4752ebfcfa9076c216396e3.tar.gz eclipse.platform.swt-f7e1f70a68b53c38b4752ebfcfa9076c216396e3.tar.xz eclipse.platform.swt-f7e1f70a68b53c38b4752ebfcfa9076c216396e3.zip |
Bug 464228 - [Gtk3] Combo box styling differences
Re-set the default selected background color in setBackgroundGdkRGBA to
prevent the background color from overriding the highlighted text
background in Combo.
Change-Id: I07602bfce2fa8909e00bae1eb54fb117723e9443
Signed-off-by: Xi Yan <xixiyan@redhat.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java | 18 |
1 files changed, 15 insertions, 3 deletions
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 9265206ba7..0c33a518f7 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 @@ -2053,9 +2053,13 @@ public void select (int index) { @Override void setBackgroundGdkRGBA (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { assert GTK.GTK3 : "GTK3 code was run by GTK2"; + if (rgba == null) { + background = defaultBackground(); + } else { + background = rgba; + } // CSS to be parsed for various widgets within Combo - background = rgba; - String css = "* {\n"; + String css = "* {"; String color; if (rgba != null) { color = display.gtk_rgba_to_css_string (rgba); @@ -2066,7 +2070,15 @@ void setBackgroundGdkRGBA (long /*int*/ context, long /*int*/ handle, GdkRGBA rg color = display.gtk_rgba_to_css_string (display.COLOR_LIST_BACKGROUND_RGBA); } } - css += "background: " + color + ";}"; + css += "background: " + color + ";}\n"; + + // Set the selected background color + GdkRGBA selectedBackground = display.getSystemColor(SWT.COLOR_LIST_SELECTION).handleRGBA; + GdkRGBA selectedForeground = display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT).handleRGBA; + String name = GTK.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "entry" : "GtkEntry"; + String selection = GTK.GTK_VERSION >= OS.VERSION(3, 20, 0) ? " selection" : ":selected"; + css += name + selection + " {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}\n"; + css += name + selection + " {color: " + display.gtk_rgba_to_css_string(selectedForeground) + ";}"; // Cache background color cssBackground = css; |