diff options
| author | Eric Williams | 2016-04-14 13:09:01 +0000 |
|---|---|---|
| committer | Eric Williams | 2016-04-22 12:54:14 +0000 |
| commit | 84ec0e619bac5a9b2208d8b35fe0fc7d85a0818a (patch) | |
| tree | c38958a62d1bb7b229992be11ce43744f36e359d | |
| parent | 00080914af012aea726331752a392d1b7b390f1e (diff) | |
| download | eclipse.platform.swt-84ec0e619bac5a9b2208d8b35fe0fc7d85a0818a.tar.gz eclipse.platform.swt-84ec0e619bac5a9b2208d8b35fe0fc7d85a0818a.tar.xz eclipse.platform.swt-84ec0e619bac5a9b2208d8b35fe0fc7d85a0818a.zip | |
Bug 487023: [GTK3.20] Update SWT to use proper GTK CSS nodes/selectors
Some style fixes for 3.20 version splits.
Change-Id: I2e85a8411519f215eabe6b39f3315a2663ae0bfa
Signed-off-by: Eric Williams <ericwill@redhat.com>
10 files changed, 45 insertions, 84 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java index 9018659efc..c21c4e624b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Button.java @@ -954,12 +954,8 @@ void setForegroundColor (long /*int*/ handle, GdkRGBA rgba) { // Form foreground string String color = display.gtk_rgba_to_css_string(toSet); - String css; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "button {color: " + color + ";}"; - } else { - css = "GtkButton {color: " + color + ";}"; - } + String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "button" : "GtkButton"; + String css = name + " {color: " + color + ";}"; // Cache foreground color cssForeground = css; 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 2d07de5f15..2789a094e6 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 @@ -4224,12 +4224,8 @@ private void _setBackground (Color color) { void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { // Form background string - String name; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - name = display.gtk_widget_class_get_css_name(handle); - } else { - name = display.gtk_widget_get_name(handle); - } + String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? display.gtk_widget_class_get_css_name(handle) + : display.gtk_widget_get_name(handle); String css = name + " {background-color: " + display.gtk_rgba_to_css_string (rgba) + ";}"; // Cache background diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java index eb5f380651..c6f42e40dd 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/List.java @@ -1355,14 +1355,10 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION; GdkRGBA selectedBackground = display.toGdkRGBA (defaultColor); if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { - String css; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "treeview {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "treeview:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } else { - css = "GtkTreeView {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "GtkTreeView:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } + 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; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java index 690651b637..348817f896 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TabFolder.java @@ -745,21 +745,16 @@ void reskinChildren (int flags) { @Override void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { - // Form background string - String name; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - name = "notebook header"; - } else { - name = "GtkNotebook"; - } - String css = name + " {background-color: " + display.gtk_rgba_to_css_string (rgba) + ";}"; - - // Cache background - cssBackground = css; - - // Apply background color and any cached foreground color - String finalCss = display.gtk_css_create_css_color_string (cssBackground, cssForeground, SWT.BACKGROUND); - gtk_css_provider_load_from_css (context, finalCss); + // Form background string + String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "notebook header" : "GtkNotebook"; + String css = name + " {background-color: " + display.gtk_rgba_to_css_string (rgba) + ";}"; + + // Cache background + cssBackground = css; + + // Apply background color and any cached foreground color + String finalCss = display.gtk_css_create_css_color_string (cssBackground, cssForeground, SWT.BACKGROUND); + gtk_css_provider_load_from_css (context, finalCss); } else { OS.gtk_widget_override_background_color (handle, OS.GTK_STATE_FLAG_NORMAL, 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 5dc045e9a7..e1f84ec38a 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 @@ -3175,14 +3175,10 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION; GdkRGBA selectedBackground = display.toGdkRGBA (defaultColor); if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { - String css; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "treeview {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "treeview:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } else { - css = "GtkTreeView {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "GtkTreeView:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } + 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; 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 c7d182dfd9..80bf9082aa 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 @@ -2230,22 +2230,19 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba GdkRGBA selectedBackground = display.toGdkRGBA (defaultColor); if (OS.GTK3) { String css; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - if ((style & SWT.SINGLE) != 0) { - css = "entry {background: " + display.gtk_rgba_to_css_string(background) + ";}\n"; - } else { - css = "textview text {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "textview:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } + String properties; + String name; + if ((style & SWT.SINGLE) != 0) { + name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "entry" : "GtkEntry"; + properties = " {background: " + display.gtk_rgba_to_css_string(background) + ";}\n"; } else { - if ((style & SWT.SINGLE) != 0) { - css = "GtkEntry {background: " + display.gtk_rgba_to_css_string(background) + ";}\n"; - } else { - css = "GtkTextView {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "GtkTextView:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } + name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "textview text" : "GtkTextView"; + properties = " {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" + + name + ":selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; } - // Cache background color + css = name + properties; + + // Cache background color cssBackground = css; // Apply background color and any foreground color 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 a8ff219df9..1dbd9fbf5f 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 @@ -596,10 +596,9 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba) { if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { // Form background string - String css = "GtkToolbar {background-color: " + display.gtk_rgba_to_css_string(rgba) + "}"; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "toolbar {background-color: " + display.gtk_rgba_to_css_string(rgba) + "}"; - } + String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "toolbar" : "GtkToolbar"; + String css = name + " {background-color: " + display.gtk_rgba_to_css_string(rgba) + "}"; + // Cache background color this.cssBackground = css; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java index 1346a30170..c0ebd76641 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/ToolTip.java @@ -270,15 +270,9 @@ void createHandle (int index) { Color background = display.getSystemColor (SWT.COLOR_INFO_BACKGROUND); if (OS.GTK3) { long /*int*/ context = OS.gtk_widget_get_style_context (handle); - double alpha = (background.getAlpha() & 0xFFFF) / (float)0xFFFF; - String css; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "window {background-color: rgba(" + background.getRed() +", " + - background.getGreen() +", " + background.getBlue() +", " + alpha + ");}"; - } else { - css = "GtkWindow {background-color: rgba(" + background.getRed() +", " + - background.getGreen() +", " + background.getBlue() +", " + alpha + ");}"; - } + GdkRGBA bgRGBA = display.toGdkRGBA(display.COLOR_INFO_BACKGROUND); + String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "window" : "GtkWindow"; + String css = name + " {background-color: " + display.gtk_rgba_to_css_string(bgRGBA) + ";}"; gtk_css_provider_load_from_css (context, css); OS.gtk_style_context_invalidate (context); } else { 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 204ed4b628..aa84f02e99 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 @@ -768,12 +768,8 @@ public boolean open () { 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; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "window {background-color: rgb(0,0,0);}"; - } else { - css = "GtkWindow {background-color: rgb(0,0,0);}"; - } + String name = OS.GTK_VERSION >= OS.VERSION(3, 20, 0) ? "window" : "GtkWindow"; + String css = name + " {background-color: rgb(0,0,0);}"; long /*int*/ provider = 0; long /*int*/ context = OS.gtk_widget_get_style_context (overlay); if (provider == 0) { 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 d290179e28..c8d6c232cf 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 @@ -3165,14 +3165,10 @@ void setBackgroundColor (long /*int*/ context, long /*int*/ handle, GdkRGBA rgba GdkColor defaultColor = getDisplay().COLOR_LIST_SELECTION; GdkRGBA selectedBackground = display.toGdkRGBA (defaultColor); if (OS.GTK_VERSION >= OS.VERSION(3, 16, 0)) { - String css; - if (OS.GTK_VERSION >= OS.VERSION(3, 20, 0)) { - css = "treeview {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "treeview:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } else { - css = "GtkTreeView {background-color: " + display.gtk_rgba_to_css_string(background) + ";}\n" - + "GtkTreeView:selected {background-color: " + display.gtk_rgba_to_css_string(selectedBackground) + ";}"; - } + 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; |
