From fed0eb78ab77538a2deff33ce8c900a2de4c392d Mon Sep 17 00:00:00 2001 From: Alexandr Miloslavskiy Date: Wed, 29 Nov 2023 00:41:53 +0100 Subject: [PATCH] [GTK] Don't use deprecated gtk_style_context_invalidate() GTK sources say: Deprecated: 3.12: Style contexts are invalidated automatically. https://www.eclipse.org/swt/faq.php#gtkstartup says: Eclipse/SWT 4.16.x: GTK+ 3.20.0 and its dependencies Eclipse/SWT 4.15.x: GTK+ 3.14.0 and its dependencies This means that it's been at least 3 years since SWT requires GTK 3.20. Sounds safe to stop using the deprecated function now. Signed-off-by: Alexandr Miloslavskiy --- .../Eclipse SWT PI/gtk/library/gtk3.c | 14 +------------- .../Eclipse SWT PI/gtk/library/gtk3_stats.h | 1 - .../gtk/org/eclipse/swt/internal/gtk3/GTK3.java | 5 ----- .../gtk/org/eclipse/swt/widgets/Control.java | 1 - .../gtk/org/eclipse/swt/widgets/Display.java | 1 - .../gtk/org/eclipse/swt/widgets/Text.java | 1 - .../gtk/org/eclipse/swt/widgets/ToolTip.java | 1 - .../gtk/org/eclipse/swt/widgets/Tracker.java | 1 - .../gtk/org/eclipse/swt/widgets/Widget.java | 2 -- 9 files changed, 1 insertion(+), 26 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c index fbe9f243cba..64d2ac2963f 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2022 IBM Corporation and others. + * Copyright (c) 2000, 2023 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -1736,18 +1736,6 @@ JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1style_1context_1get_1parent) } #endif -#ifndef NO_gtk_1style_1context_1invalidate -G_GNUC_BEGIN_IGNORE_DEPRECATIONS -JNIEXPORT void JNICALL GTK3_NATIVE(gtk_1style_1context_1invalidate) - (JNIEnv *env, jclass that, jlong arg0) -{ - GTK3_NATIVE_ENTER(env, that, gtk_1style_1context_1invalidate_FUNC); - gtk_style_context_invalidate((GtkStyleContext *)arg0); - GTK3_NATIVE_EXIT(env, that, gtk_1style_1context_1invalidate_FUNC); -} -G_GNUC_END_IGNORE_DEPRECATIONS -#endif - #ifndef NO_gtk_1target_1list_1new JNIEXPORT jlong JNICALL GTK3_NATIVE(gtk_1target_1list_1new) (JNIEnv *env, jclass that, jlong arg0, jint arg1) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h index 387870e7ae4..05b2dc758ad 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/library/gtk3_stats.h @@ -165,7 +165,6 @@ typedef enum { gtk_1style_1context_1get_1font_FUNC, gtk_1style_1context_1get_1padding_FUNC, gtk_1style_1context_1get_1parent_FUNC, - gtk_1style_1context_1invalidate_FUNC, gtk_1target_1list_1new_FUNC, gtk_1target_1list_1unref_FUNC, gtk_1text_1view_1get_1window_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java index 5adb1ecbcfa..967a6eff9a9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk3/GTK3.java @@ -916,11 +916,6 @@ public class GTK3 { public static final native boolean gtk_css_provider_load_from_data(long css_provider, byte[] data, long length, long error[]); /* GtkStyleContext */ - /** - * @method flags=ignore_deprecations - * @param context cast=(GtkStyleContext *) - */ - public static final native void gtk_style_context_invalidate(long context); /** * @param screen cast=(GdkScreen *) * @param provider cast=(GtkStyleProvider *) 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 224dab38809..ee564ae93fa 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 @@ -5307,7 +5307,6 @@ void setBackgroundGdkRGBA (long handle, GdkRGBA rgba) { long context = GTK.gtk_widget_get_style_context(handle); setBackgroundGdkRGBA(context, handle, rgba); - if (!GTK.GTK4) GTK3.gtk_style_context_invalidate(context); } /** * Sets the receiver's background image to the image specified 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 0df349dda82..51cec98b04e 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 @@ -3220,7 +3220,6 @@ void initializeSystemColorsList(long shellContext) { GTK.gtk_style_context_save (shellContext); GTK.gtk_style_context_add_class(shellContext, GTK.GTK_STYLE_CLASS_VIEW); GTK.gtk_style_context_add_class(shellContext, GTK.GTK_STYLE_CLASS_CELL); - if (!GTK.GTK4) GTK3.gtk_style_context_invalidate(shellContext); COLOR_LIST_FOREGROUND_RGBA = styleContextGetColor (shellContext, GTK.GTK_STATE_FLAG_NORMAL); COLOR_LIST_BACKGROUND_RGBA = styleContextEstimateBackgroundColor(shellContext, GTK.GTK_STATE_FLAG_NORMAL); 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 c6f99130fed..493c9614cbf 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 @@ -259,7 +259,6 @@ void createHandle (int index) { long context = GTK.gtk_widget_get_style_context(handle); String background = display.gtk_rgba_to_css_string(display.COLOR_LIST_BACKGROUND_RGBA); gtk_css_provider_load_from_css(context, "entry {border: solid; background: " + background + ";}"); - if (!GTK.GTK4) GTK3.gtk_style_context_invalidate(context); } float alignment = 0.0f; 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 9f467287625..b58deb17e3a 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 @@ -308,7 +308,6 @@ void createHandle (int index) { GdkRGBA bgRGBA = background.handle; String css = "window {background-color: " + display.gtk_rgba_to_css_string(bgRGBA) + ";}"; gtk_css_provider_load_from_css (context, css); - GTK3.gtk_style_context_invalidate (context); GTK3.gtk_window_set_type_hint (handle, GDK.GDK_WINDOW_TYPE_HINT_TOOLTIP); } } 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 d2d967f0a62..d41006ea416 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 @@ -917,7 +917,6 @@ private void setTrackerBackground(boolean opaque) { GTK4.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (css, true), -1); } else { GTK3.gtk_css_provider_load_from_data (provider, Converter.wcsToMbcs (css, true), -1, null); - GTK3.gtk_style_context_invalidate (context); } long region = Cairo.cairo_region_create (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java index ee086b24725..9d0e934c940 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Widget.java @@ -1851,8 +1851,6 @@ void setFontDescription(long widget, long fontDescription) { // gtk_widget_override_font() copies the fields from 'fontDescription' // and does not remember the pointer passed to it. GTK3.gtk_widget_override_font(widget, fontDescription); - long context = GTK.gtk_widget_get_style_context(widget); - GTK3.gtk_style_context_invalidate(context); } }