diff options
author | Leo Ufimtsev | 2015-04-07 19:23:12 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2015-04-08 12:11:44 +0000 |
commit | 41bdd68738c0b4aa849e6a0d483da956ec49ea3d (patch) | |
tree | 77ae970e40afa499f1dfc0d14252668aafe27216 | |
parent | 476b88e18102db1fbb9ef3a7784dd7270d0ecf3b (diff) | |
download | eclipse.platform.swt-41bdd68738c0b4aa849e6a0d483da956ec49ea3d.tar.gz eclipse.platform.swt-41bdd68738c0b4aa849e6a0d483da956ec49ea3d.tar.xz eclipse.platform.swt-41bdd68738c0b4aa849e6a0d483da956ec49ea3d.zip |
Bug 461616 - [GTK3] Combo improvements in background/foreground for gtk3
(fix 2)
- Combox with READ_ONLY now get background as well.
- Menu 'text' gets background. But GtkTreeMenu is inside a private
struct inside GtkComboBoxText so we can't theme it's background.
Tests:
- [X] Gtk 3.8
- [X] Gtk 3.10
- [X] Gtk 3.12
- [X] Gtk 3.14
- [X] Gtk 3.16
Change-Id: Idc315a02dbdb8fbec3f699e39735903709e1ed8c
Signed-off-by: Leo Ufimtsev <lufimtse@redhat.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/OS.java | 1 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Combo.java | 20 |
2 files changed, 20 insertions, 1 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 06b3eb22fd..54268e60df 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 @@ -603,6 +603,7 @@ public class OS extends C { /** Properties */ public static final byte[] active = ascii("active"); public static final byte[] background_gdk = ascii("background-gdk"); + public static final byte[] background_rgba = ascii("background-rgba"); public static final byte[] button_relief = ascii("button-relief"); public static final byte[] cell_background_gdk = ascii("cell-background-gdk"); public static final byte[] default_border = ascii("default-border"); 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 cb650e3e5e..7edd29d291 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 @@ -1848,12 +1848,30 @@ 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. + if (entryHandle == 0 || (style & SWT.READ_ONLY) != 0) { - super.setBackgroundColor (context, handle, rgba); + 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 } 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} } + + //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 |