From fbfda267e8f4b55dff30a3827bff760565f36fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Fri, 15 Apr 2022 17:19:05 +0100 Subject: [PATCH] gtk[3|4] add the css "warning" "error" to GtkEntry when those states fit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4063155d25b80f6b5912f0b63dc3c8fa21c7263b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133079 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- vcl/unx/gtk3/gtkinst.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 53f9e3bb644f..50e3b7949877 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -12586,30 +12586,42 @@ public: namespace { -#if GTK_CHECK_VERSION(4, 0, 0) // CSS nodes: entry[.flat][.warning][.error] void set_widget_css_message_type(GtkWidget* pWidget, weld::EntryMessageType eType) { +#if GTK_CHECK_VERSION(4, 0, 0) + gtk_widget_remove_css_class(pWidget, "error"); + gtk_widget_remove_css_class(pWidget, "warning"); +#else + GtkStyleContext *pWidgetContext = gtk_widget_get_style_context(pWidget); + gtk_style_context_remove_class(pWidgetContext, "error"); + gtk_style_context_remove_class(pWidgetContext, "warning"); +#endif + switch (eType) { case weld::EntryMessageType::Normal: - gtk_widget_remove_css_class(pWidget, "error"); - gtk_widget_remove_css_class(pWidget, "warning"); break; case weld::EntryMessageType::Warning: - gtk_widget_remove_css_class(pWidget, "error"); +#if GTK_CHECK_VERSION(4, 0, 0) gtk_widget_add_css_class(pWidget, "warning"); +#else + gtk_style_context_add_class(pWidgetContext, "warning"); +#endif break; case weld::EntryMessageType::Error: - gtk_widget_remove_css_class(pWidget, "warning"); +#if GTK_CHECK_VERSION(4, 0, 0) gtk_widget_add_css_class(pWidget, "error"); +#else + gtk_style_context_add_class(pWidgetContext, "error"); +#endif break; } } -#endif void set_entry_message_type(GtkEntry* pEntry, weld::EntryMessageType eType) { + set_widget_css_message_type(GTK_WIDGET(pEntry), eType); switch (eType) { case weld::EntryMessageType::Normal: