Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy2019-04-03 10:27:58 -0400
committerEric Williams2019-04-09 10:17:35 -0400
commitf867f7e6a01df090080f0a6f89b37bcbf0ec7d4b (patch)
tree0161d8f9fc2c890f1b73c9d550a8e8fab11e7a9c
parent5187ed6e90f2808173b79f3968ac66987ac4128e (diff)
downloadeclipse.platform.swt-f867f7e6a01df090080f0a6f89b37bcbf0ec7d4b.tar.gz
eclipse.platform.swt-f867f7e6a01df090080f0a6f89b37bcbf0ec7d4b.tar.xz
eclipse.platform.swt-f867f7e6a01df090080f0a6f89b37bcbf0ec7d4b.zip
Bug 545923 - [regression][GTK] Tooltip foreground is wrong
Fix 1: ------ The problem with previous approach taken in Bug 545587 was: 'Clearlooks-Phenix' does not define 'color' property for 'tooltip *' CSS selector. Instead, it's expected to be inherited from 'tooltip' CSS selector. However, 'gtk_style_context_set_path' is flawed: it will use parent for searching CSS selector, but it will *not* use parent for inheritance. I'm not sure whether this is GTK bug, GTK design bug, GTK documentation bug, or something else. One thing for sure, 'GtkWidgetPath' approach proved fragile. Also, it requires to set various components carefully, and GTK guys love to change these. Also, 'GtkWidgetPath' seems to be abandoned (even though not deprecated yet), for example GTK commit 101df329 mentions '... applications that still use widget paths ...' So I decided to take another approach: actually create the tooltip and let it handle all the magic itself, then request its GtkStyleContext. This seems to work much more reliably. Since this no longer requires anything from GTK higher then 3.0, I also removed all fallback code paths. Fix 2: ------ Added a quick workaround for 'HighContrast' theme. Change-Id: Icbb0b315bdfed2a1668e622240026a942148ac66 Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os.c102
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.c8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/os_stats.h8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java94
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java113
5 files changed, 79 insertions, 246 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 3fcfe45787..b23c90c278 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
@@ -9501,18 +9501,6 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1invalidate)
}
#endif
-#ifndef NO__1gtk_1style_1context_1new
-JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1style_1context_1new)
- (JNIEnv *env, jclass that)
-{
- jlong rc = 0;
- GTK_NATIVE_ENTER(env, that, _1gtk_1style_1context_1new_FUNC);
- rc = (jlong)gtk_style_context_new();
- GTK_NATIVE_EXIT(env, that, _1gtk_1style_1context_1new_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gtk_1style_1context_1remove_1class
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1remove_1class)
(JNIEnv *env, jclass that, jlong arg0, jbyteArray arg1)
@@ -9547,16 +9535,6 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1save)
}
#endif
-#ifndef NO__1gtk_1style_1context_1set_1path
-JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1set_1path)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
-{
- GTK_NATIVE_ENTER(env, that, _1gtk_1style_1context_1set_1path_FUNC);
- gtk_style_context_set_path((GtkStyleContext *)arg0, (GtkWidgetPath *)arg1);
- GTK_NATIVE_EXIT(env, that, _1gtk_1style_1context_1set_1path_FUNC);
-}
-#endif
-
#ifndef NO__1gtk_1style_1context_1set_1state
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1style_1context_1set_1state)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1)
@@ -10460,6 +10438,28 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1toolbar_1set_1style)
}
#endif
+#ifndef NO__1gtk_1tooltip_1get_1type
+JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1tooltip_1get_1type)
+ (JNIEnv *env, jclass that)
+{
+ jlong rc = 0;
+ GTK_NATIVE_ENTER(env, that, _1gtk_1tooltip_1get_1type_FUNC);
+ rc = (jlong)gtk_tooltip_get_type();
+ GTK_NATIVE_EXIT(env, that, _1gtk_1tooltip_1get_1type_FUNC);
+ return rc;
+}
+#endif
+
+#ifndef NO__1gtk_1tooltip_1set_1custom
+JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1tooltip_1set_1custom)
+ (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
+{
+ GTK_NATIVE_ENTER(env, that, _1gtk_1tooltip_1set_1custom_FUNC);
+ gtk_tooltip_set_custom((GtkTooltip *)arg0, (GtkWidget *)arg1);
+ GTK_NATIVE_EXIT(env, that, _1gtk_1tooltip_1set_1custom_FUNC);
+}
+#endif
+
#ifndef NO__1gtk_1tree_1model_1get__JJI_3II
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1tree_1model_1get__JJI_3II)
(JNIEnv *env, jclass that, jlong arg0, jlong arg1, jint arg2, jintArray arg3, jint arg4)
@@ -12539,64 +12539,6 @@ JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1override_1font)
}
#endif
-#ifndef NO__1gtk_1widget_1path_1append_1type
-JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1widget_1path_1append_1type)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1)
-{
- jlong rc = 0;
- GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1append_1type_FUNC);
- rc = (jlong)gtk_widget_path_append_type((GtkWidgetPath *)arg0, (GType)arg1);
- GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1append_1type_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO__1gtk_1widget_1path_1free
-JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1path_1free)
- (JNIEnv *env, jclass that, jlong arg0)
-{
- GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1free_FUNC);
- gtk_widget_path_free((GtkWidgetPath *)arg0);
- GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1free_FUNC);
-}
-#endif
-
-#ifndef NO__1gtk_1widget_1path_1iter_1set_1object_1name
-JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1widget_1path_1iter_1set_1object_1name)
- (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jbyteArray arg2)
-{
- jbyte *lparg2=NULL;
- jlong rc = 0;
- GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1iter_1set_1object_1name_FUNC);
- if (arg2) if ((lparg2 = (*env)->GetByteArrayElements(env, arg2, NULL)) == NULL) goto fail;
-/*
- rc = (jlong)gtk_widget_path_iter_set_object_name((GtkWidgetPath *)arg0, (gint)arg1, (const char *)lparg2);
-*/
- {
- GTK_LOAD_FUNCTION(fp, gtk_widget_path_iter_set_object_name)
- if (fp) {
- rc = (jlong)((jlong (CALLING_CONVENTION*)(GtkWidgetPath *, gint, const char *))fp)((GtkWidgetPath *)arg0, (gint)arg1, (const char *)lparg2);
- }
- }
-fail:
- if (arg2 && lparg2) (*env)->ReleaseByteArrayElements(env, arg2, lparg2, 0);
- GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1iter_1set_1object_1name_FUNC);
- return rc;
-}
-#endif
-
-#ifndef NO__1gtk_1widget_1path_1new
-JNIEXPORT jlong JNICALL GTK_NATIVE(_1gtk_1widget_1path_1new)
- (JNIEnv *env, jclass that)
-{
- jlong rc = 0;
- GTK_NATIVE_ENTER(env, that, _1gtk_1widget_1path_1new_FUNC);
- rc = (jlong)gtk_widget_path_new();
- GTK_NATIVE_EXIT(env, that, _1gtk_1widget_1path_1new_FUNC);
- return rc;
-}
-#endif
-
#ifndef NO__1gtk_1widget_1queue_1draw
JNIEXPORT void JNICALL GTK_NATIVE(_1gtk_1widget_1queue_1draw)
(JNIEnv *env, jclass that, jlong arg0)
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 1d9288674a..1e05d046e6 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
@@ -760,11 +760,9 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1style_1context_1get_1padding__JILorg_eclipse_swt_internal_gtk_GtkBorder_2",
"_1gtk_1style_1context_1get_1padding__JLorg_eclipse_swt_internal_gtk_GtkBorder_2",
"_1gtk_1style_1context_1invalidate",
- "_1gtk_1style_1context_1new",
"_1gtk_1style_1context_1remove_1class",
"_1gtk_1style_1context_1restore",
"_1gtk_1style_1context_1save",
- "_1gtk_1style_1context_1set_1path",
"_1gtk_1style_1context_1set_1state",
"_1gtk_1target_1list_1new",
"_1gtk_1target_1list_1unref",
@@ -829,6 +827,8 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1toolbar_1set_1icon_1size",
"_1gtk_1toolbar_1set_1show_1arrow",
"_1gtk_1toolbar_1set_1style",
+ "_1gtk_1tooltip_1get_1type",
+ "_1gtk_1tooltip_1set_1custom",
"_1gtk_1tree_1model_1get__JJI_3II",
"_1gtk_1tree_1model_1get__JJI_3JI",
"_1gtk_1tree_1model_1get_1iter",
@@ -988,10 +988,6 @@ char * GTK_nativeFunctionNames[] = {
"_1gtk_1widget_1override_1background_1color",
"_1gtk_1widget_1override_1color",
"_1gtk_1widget_1override_1font",
- "_1gtk_1widget_1path_1append_1type",
- "_1gtk_1widget_1path_1free",
- "_1gtk_1widget_1path_1iter_1set_1object_1name",
- "_1gtk_1widget_1path_1new",
"_1gtk_1widget_1queue_1draw",
"_1gtk_1widget_1queue_1resize",
"_1gtk_1widget_1realize",
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 c261995026..3e2cf733ab 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
@@ -758,11 +758,9 @@ typedef enum {
_1gtk_1style_1context_1get_1padding__JILorg_eclipse_swt_internal_gtk_GtkBorder_2_FUNC,
_1gtk_1style_1context_1get_1padding__JLorg_eclipse_swt_internal_gtk_GtkBorder_2_FUNC,
_1gtk_1style_1context_1invalidate_FUNC,
- _1gtk_1style_1context_1new_FUNC,
_1gtk_1style_1context_1remove_1class_FUNC,
_1gtk_1style_1context_1restore_FUNC,
_1gtk_1style_1context_1save_FUNC,
- _1gtk_1style_1context_1set_1path_FUNC,
_1gtk_1style_1context_1set_1state_FUNC,
_1gtk_1target_1list_1new_FUNC,
_1gtk_1target_1list_1unref_FUNC,
@@ -827,6 +825,8 @@ typedef enum {
_1gtk_1toolbar_1set_1icon_1size_FUNC,
_1gtk_1toolbar_1set_1show_1arrow_FUNC,
_1gtk_1toolbar_1set_1style_FUNC,
+ _1gtk_1tooltip_1get_1type_FUNC,
+ _1gtk_1tooltip_1set_1custom_FUNC,
_1gtk_1tree_1model_1get__JJI_3II_FUNC,
_1gtk_1tree_1model_1get__JJI_3JI_FUNC,
_1gtk_1tree_1model_1get_1iter_FUNC,
@@ -986,10 +986,6 @@ typedef enum {
_1gtk_1widget_1override_1background_1color_FUNC,
_1gtk_1widget_1override_1color_FUNC,
_1gtk_1widget_1override_1font_FUNC,
- _1gtk_1widget_1path_1append_1type_FUNC,
- _1gtk_1widget_1path_1free_FUNC,
- _1gtk_1widget_1path_1iter_1set_1object_1name_FUNC,
- _1gtk_1widget_1path_1new_FUNC,
_1gtk_1widget_1queue_1draw_FUNC,
_1gtk_1widget_1queue_1resize_FUNC,
_1gtk_1widget_1realize_FUNC,
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
index 6d85fbd4fe..163906e608 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GTK.java
@@ -4034,28 +4034,6 @@ public class GTK extends OS {
lock.unlock();
}
}
- public static final native long _gtk_style_context_new ();
- public static final long gtk_style_context_new() {
- lock.lock();
- try {
- return _gtk_style_context_new();
- } finally {
- lock.unlock();
- }
- }
- /**
- * @param context cast=(GtkStyleContext *)
- * @param path cast=(GtkWidgetPath *)
- */
- public static final native void _gtk_style_context_set_path (long context, long path);
- public static final void gtk_style_context_set_path(long context, long path) {
- lock.lock();
- try {
- _gtk_style_context_set_path(context, path);
- } finally {
- lock.unlock();
- }
- }
/**
* @param list_store cast=(GtkListStore *)
* @param iter cast=(GtkTreeIter *)
@@ -7090,6 +7068,28 @@ public class GTK extends OS {
lock.unlock();
}
}
+ public static final native long _gtk_tooltip_get_type();
+ public static final long gtk_tooltip_get_type() {
+ lock.lock();
+ try {
+ return _gtk_tooltip_get_type();
+ } finally {
+ lock.unlock();
+ }
+ }
+ /**
+ * @param tooltip cast=(GtkTooltip *)
+ * @param custom_widget cast=(GtkWidget *)
+ */
+ public static final native void _gtk_tooltip_set_custom(long tooltip, long custom_widget);
+ public static final void gtk_tooltip_set_custom(long tooltip, long custom_widget) {
+ lock.lock();
+ try {
+ _gtk_tooltip_set_custom(tooltip, custom_widget);
+ } finally {
+ lock.unlock();
+ }
+ }
/**
* @param tree_model cast=(GtkTreeModel *)
* @param iter cast=(GtkTreeIter *)
@@ -8889,56 +8889,6 @@ public class GTK extends OS {
lock.unlock();
}
}
- /**
- * @param path cast=(GtkWidgetPath *)
- * @param type cast=(GType)
- */
- public static final native long _gtk_widget_path_append_type (long path, long type);
- public static final long gtk_widget_path_append_type(long path, long type) {
- lock.lock();
- try {
- return _gtk_widget_path_append_type(path, type);
- } finally {
- lock.unlock();
- }
- }
- /**
- * @param path cast=(GtkWidgetPath *)
- */
- public static final native void _gtk_widget_path_free (long path);
- public static final void gtk_widget_path_free(long path) {
- lock.lock();
- try {
- _gtk_widget_path_free(path);
- } finally {
- lock.unlock();
- }
- }
- /**
- * @method flags=dynamic
- * @param path cast=(GtkWidgetPath *)
- * @param pos cast=(gint)
- * @param name cast=(const char *)
- */
- public static final native long _gtk_widget_path_iter_set_object_name (long path, long pos, byte[] name);
- /** [since 3.20] */
- public static final long gtk_widget_path_iter_set_object_name(long path, long pos, byte[] name) {
- lock.lock();
- try {
- return _gtk_widget_path_iter_set_object_name(path, pos, name);
- } finally {
- lock.unlock();
- }
- }
- public static final native long _gtk_widget_path_new ();
- public static final long gtk_widget_path_new() {
- lock.lock();
- try {
- return _gtk_widget_path_new();
- } finally {
- lock.unlock();
- }
- }
/** @param widget cast=(GtkWidget *) */
public static final native void _gtk_widget_queue_resize(long widget);
public static final void gtk_widget_queue_resize(long widget) {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
index ce3ef2eb3b..3de6839d6b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java
@@ -3182,6 +3182,7 @@ GdkRGBA toGdkRGBA (GdkRGBA rgba, double brightness) {
* multiplied component, so all of those inverses are equivalent.
*/
static int inversePremultipliedColor(int color, int alpha) {
+ if (alpha == 0) return 0;
return (255*color + alpha-1) / alpha;
}
@@ -3211,8 +3212,19 @@ GdkRGBA styleContextGetBackgroundColor(long context, int state) {
int g = Byte.toUnsignedInt(buffer[1]);
int b = Byte.toUnsignedInt(buffer[0]);
- // NOTE: cairo uses premultiplied alpha (see CAIRO_FORMAT_ARGB32)
GdkRGBA rgba = new GdkRGBA ();
+
+ if (a == 0) {
+ // 'HighContrast' theme has a transparent label in tooltip.
+ // For whatever reason, rendering tooltip also renders children,
+ // and children are not alpha-blended on parent. This is a dirty
+ // workaround for it. It will not work in case of partial
+ // transparency.
+ GTK.gtk_style_context_get_background_color (context, GTK.GTK_STATE_FLAG_NORMAL, rgba);
+ return rgba;
+ }
+
+ // NOTE: cairo uses premultiplied alpha (see CAIRO_FORMAT_ARGB32)
rgba.alpha = a / 255f;
rgba.red = inversePremultipliedColor(r, a) / 255f;
rgba.green = inversePremultipliedColor(g, a) / 255f;
@@ -3279,7 +3291,7 @@ void initializeSystemColors () {
initializeSystemColorsList(cssOutput);
initializeSystemColorsTitle(cssOutput);
initializeSystemColorsLink(cssOutput);
- initializeSystemColorsTooltip(cssOutput);
+ initializeSystemColorsTooltip();
COLOR_TITLE_FOREGROUND_RGBA = COLOR_LIST_SELECTION_TEXT_RGBA;
COLOR_TITLE_BACKGROUND_RGBA = COLOR_LIST_SELECTION_RGBA;
@@ -3452,91 +3464,28 @@ private void initializeSystemColorsLink(String cssOutput) {
}
}
-void initializeSystemColorsTooltip(String cssOutput) {
- // gtk_widget_path_iter_set_object_name is available since 3.20
- if (GTK.GTK_VERSION >= OS.VERSION(3, 20, 0)) {
- // NOTE: One other approach would be to create a temporary 'GtkTooltipWindow'
- // widget, obtaining its GType with 'g_type_from_name'. See snippet
- // attached to Bug 545587 for a demo.
+void initializeSystemColorsTooltip() {
+ // Create a temporary tooltip
+ long tooltip = OS.g_object_new(GTK.gtk_tooltip_get_type(), 0);
- byte[] tooltipCssNode = Converter.javaStringToCString("tooltip"); //$NON-NLS-1$
+ // Add temporary label as custom control into tooltip
+ long customLabel = OS.g_object_new(GTK.gtk_label_get_type(), 0);
+ GTK.gtk_tooltip_set_custom(tooltip, customLabel);
- // Separate style contexts are used to avoid complex state manipulations
- {
- // Foreground color is taken from 'tooltip label' css node
- long labelType = GTK.gtk_label_get_type();
- long context = GTK.gtk_style_context_new();
- long widgetPath = GTK.gtk_widget_path_new();
- GTK.gtk_widget_path_append_type(widgetPath, 0);
- GTK.gtk_widget_path_iter_set_object_name(widgetPath, -1, tooltipCssNode);
- GTK.gtk_widget_path_append_type(widgetPath, labelType);
- GTK.gtk_style_context_set_path(context, widgetPath);
- GTK.gtk_widget_path_free(widgetPath);
+ // Find tooltip window, using custom widget as entry point
+ long tooltipBox = GTK.gtk_widget_get_parent(customLabel);
+ long tooltipWindow = GTK.gtk_widget_get_parent(tooltipBox);
- COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor(context, GTK.GTK_STATE_FLAG_NORMAL);
-
- // Destroy temporary style context
- OS.g_object_unref(context);
- }
-
- // Separate style contexts are used to avoid complex state manipulations
- {
- // Background color is taken from 'tooltip.background' css node
- byte[] backgroundClass = Converter.javaStringToCString("background"); //$NON-NLS-1$
- long context = GTK.gtk_style_context_new();
- long widgetPath = GTK.gtk_widget_path_new();
- GTK.gtk_widget_path_append_type(widgetPath, 0);
- GTK.gtk_widget_path_iter_set_object_name(widgetPath, -1, tooltipCssNode);
- GTK.gtk_style_context_set_path(context, widgetPath);
- GTK.gtk_style_context_add_class(context, backgroundClass);
- GTK.gtk_widget_path_free(widgetPath);
-
- COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(context, GTK.GTK_STATE_FLAG_NORMAL);
-
- // Destroy temporary style context
- OS.g_object_unref(context);
- }
- } else {
- // Create a temporary Tooltip widget
- long tooltipShellHandle = GTK.gtk_window_new (GTK.GTK_WINDOW_POPUP);
- if (tooltipShellHandle == 0) error (SWT.ERROR_NO_HANDLES);
- byte[] gtk_tooltip = Converter.wcsToMbcs ("gtk-tooltip", true); //$NON-NLS-1$
- GTK.gtk_widget_set_name (tooltipShellHandle, gtk_tooltip);
- GTK.gtk_widget_realize (tooltipShellHandle);
-
- long context = GTK.gtk_widget_get_style_context (tooltipShellHandle);
- GTK.gtk_style_context_add_class (context, GTK.GTK_STYLE_CLASS_TOOLTIP);
- GTK.gtk_style_context_invalidate(context);
-
- if (GTK.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
- String colorInfoForeground = gtk_css_default_theme_values(SWT.COLOR_INFO_FOREGROUND, cssOutput);
- if (!colorInfoForeground.isEmpty()) {
- if (colorInfoForeground != "parsed") {
- COLOR_INFO_FOREGROUND_RGBA = gtk_css_property_to_rgba (colorInfoForeground);
- }
- } else {
- COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor (context, GTK.GTK_STATE_FLAG_NORMAL);
- }
- } else {
- COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor (context, GTK.GTK_STATE_FLAG_NORMAL);
- }
+ // Just use temporary label; this is easier then finding the original label
+ long styleContextLabel = GTK.gtk_widget_get_style_context(customLabel);
+ COLOR_INFO_FOREGROUND_RGBA = styleContextGetColor(styleContextLabel, GTK.GTK_STATE_FLAG_NORMAL);
- if (GTK.GTK_VERSION >= OS.VERSION(3, 14, 0)) {
- String colorInfoBackground = gtk_css_default_theme_values(SWT.COLOR_INFO_BACKGROUND, cssOutput);
- if (!colorInfoBackground.isEmpty()) {
- if (colorInfoBackground != "parsed") {
- COLOR_INFO_BACKGROUND_RGBA = gtk_css_property_to_rgba (colorInfoBackground);
- }
- } else {
- COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(context, GTK.GTK_STATE_FLAG_NORMAL);
- }
- } else {
- COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(context, GTK.GTK_STATE_FLAG_NORMAL);
- }
+ long styleContextTooltipWindow = GTK.gtk_widget_get_style_context(tooltipWindow);
+ COLOR_INFO_BACKGROUND_RGBA = styleContextGetBackgroundColor(styleContextTooltipWindow, GTK.GTK_STATE_FLAG_NORMAL);
- // Destroy temporary Tooltip widget
- GTK.gtk_widget_destroy (tooltipShellHandle);
- }
+ // Cleanup
+ // customLabel is owned by tooltip and will be destroyed automatically
+ OS.g_object_unref(tooltip);
}
GdkRGBA styleContextGetColor(long context, int flag) {

Back to the top