diff options
author | Eric Williams | 2017-07-14 12:46:28 +0000 |
---|---|---|
committer | Eric Williams | 2017-07-18 16:08:32 +0000 |
commit | 96f0522cddf7d1c748b48ed1d89b9374b0298000 (patch) | |
tree | f3e5cbb528aeac02a67e27c7b307d930bd936d47 /bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java | |
parent | 2b5e88cf9f34cbada712e9b4a64a270452696c69 (diff) | |
download | eclipse.platform.swt-96f0522cddf7d1c748b48ed1d89b9374b0298000.tar.gz eclipse.platform.swt-96f0522cddf7d1c748b48ed1d89b9374b0298000.tar.xz eclipse.platform.swt-96f0522cddf7d1c748b48ed1d89b9374b0298000.zip |
Bug 519576: [GTK3] Use GTK CSS for background/foreground colors on
GTK3.14 and below
This patch brings GTK CSS machinery to GTK 3.14. We already use GTK CSS
for system colors on GTK 3.14, no reason why background/foreground
colors can't use it either.
Change-Id: Id8cc46abba9e2e5c333d3d0decf7f11c20d02117
Signed-off-by: Eric Williams <ericwill@redhat.com>
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java | 49 |
1 files changed, 3 insertions, 46 deletions
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 602ad3fe5f..e4f041449a 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 @@ -90,7 +90,7 @@ public class Tree extends Composite { boolean expandAll; int drawState, drawFlags; GdkColor drawForeground; - GdkRGBA background, foreground, drawForegroundRGBA; + GdkRGBA foreground, drawForegroundRGBA; boolean ownerDraw, ignoreSize, ignoreAccessibility, pixbufSizeSet; int pixbufHeight, pixbufWidth; TreeItem topItem; @@ -1414,20 +1414,8 @@ public TreeColumn [] getColumns () { } @Override -GdkRGBA getContextBackgroundGdkRGBA () { - assert OS.GTK3 : "GTK3 code was run by GTK2"; - if (background != null) { - return background; - } else { - // For Tables and Trees, the default background is - // COLOR_LIST_BACKGROUND instead of COLOR_WIDGET_BACKGROUND. - return display.COLOR_LIST_BACKGROUND_RGBA; - } -} - -@Override GdkRGBA getContextColorGdkRGBA () { - if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { + if (OS.GTK_VERSION >= OS.VERSION(3, 14, 0)) { if (foreground != null) { return foreground; } else { @@ -3390,37 +3378,6 @@ void setBackgroundGdkColor (GdkColor color) { } @Override -void setBackgroundGdkRGBA (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { - assert OS.GTK3 : "GTK3 code was run by GTK2"; - /* 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) { - background = display.COLOR_LIST_BACKGROUND_RGBA; - } else { - background = rgba; - } - GdkRGBA selectedBackground = display.getSystemColor(SWT.COLOR_LIST_SELECTION).handleRGBA; - if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { - String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "treeview" : "GtkTreeView"; - String css = name + " {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + name + ":selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - - // Cache background color - cssBackground = css; - - // Apply background color and any foreground color - String finalCss = display.gtk_css_create_css_color_string (cssBackground, cssForeground, SWT.BACKGROUND); - gtk_css_provider_load_from_css(context, finalCss); - } else { - super.setBackgroundGdkRGBA(context, handle, rgba); - OS.gtk_widget_override_background_color(handle, OS.GTK_STATE_FLAG_SELECTED, selectedBackground); - } -} - -@Override void setBackgroundPixmap (Image image) { ownerDraw = true; recreateRenderers (); @@ -3501,7 +3458,7 @@ void setFontDescription (long /*int*/ font) { @Override void setForegroundGdkRGBA (GdkRGBA rgba) { - if (OS.GTK_VERSION >= OS.VERSION (3, 16, 0)) { + if (OS.GTK_VERSION >= OS.VERSION (3, 14, 0)) { foreground = rgba; GdkRGBA toSet = rgba == null ? display.COLOR_LIST_FOREGROUND_RGBA : rgba; setForegroundGdkRGBA (handle, toSet); |