From 76853b4981875dedb1f0f21ffc00c0083d294c6d Mon Sep 17 00:00:00 2001 From: Monsta Date: Fri, 25 Dec 2015 15:09:44 +0300 Subject: GTK+3: fix share name entry color when error or warning is set color and bg color depend on theme, so e.g. error color won't always be white-on-red as in GTK+2 build --- share/caja-share.c | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/share/caja-share.c b/share/caja-share.c index b74496e..07b2195 100644 --- a/share/caja-share.c +++ b/share/caja-share.c @@ -441,31 +441,60 @@ get_fullpath_from_fileinfo(CajaFileInfo *fileinfo) static void property_page_set_warning (PropertyPage *page) { - GdkColor colorYellow; - - gtk_label_set_text (GTK_LABEL (page->label_status), _("Share name is too long")); - +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (page->entry_share_name)); + if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_ERROR)) + { + gtk_style_context_remove_class (context, GTK_STYLE_CLASS_ERROR); + } + gtk_style_context_add_class (context, GTK_STYLE_CLASS_WARNING); +#else + GdkColor colorYellow; gdk_color_parse ("#ECDF62", &colorYellow); gtk_widget_modify_base (page->entry_share_name, GTK_STATE_NORMAL, &colorYellow); -} +#endif + gtk_label_set_text (GTK_LABEL (page->label_status), _("Share name is too long")); +} static void property_page_set_error (PropertyPage *page, const char *message) { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (page->entry_share_name)); + if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_WARNING)) + { + gtk_style_context_remove_class (context, GTK_STYLE_CLASS_WARNING); + } + gtk_style_context_add_class (context, GTK_STYLE_CLASS_ERROR); +#else GdkColor colorRed; - - gtk_label_set_text (GTK_LABEL (page->label_status), message); - gdk_color_parse ("#C1665A", &colorRed); gtk_widget_modify_base (page->entry_share_name, GTK_STATE_NORMAL, &colorRed); +#endif + + gtk_label_set_text (GTK_LABEL (page->label_status), message); } static void property_page_set_normal (PropertyPage *page) { - gtk_label_set_text (GTK_LABEL (page->label_status), ""); +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (page->entry_share_name)); + if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_WARNING)) + { + gtk_style_context_remove_class (context, GTK_STYLE_CLASS_WARNING); + } + + if (gtk_style_context_has_class (context, GTK_STYLE_CLASS_ERROR)) + { + gtk_style_context_remove_class (context, GTK_STYLE_CLASS_ERROR); + } +#else gtk_widget_modify_base (page->entry_share_name, GTK_STATE_NORMAL, NULL); +#endif + + gtk_label_set_text (GTK_LABEL (page->label_status), ""); } static gboolean -- cgit v1.2.1