[telepathy-account-widgets] account-widget: use the "error" CSS class on wrong entries



commit 6cf47a8c759b8962e4345b2122e51e18454f4346
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Tue Jan 7 13:58:37 2014 +0100

    account-widget: use the "error" CSS class on wrong entries
    
    That's the proper way to do as GTK+ defines this class for exactly this
    purpose. Our current code was pretty hacky anyway.
    
    This also has the nice side effect of fixing a bug making the text unreadable
    when selecting it from the entry.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710252

 tp-account-widgets/tpaw-account-widget.c |   22 ++++++----------------
 1 files changed, 6 insertions(+), 16 deletions(-)
---
diff --git a/tp-account-widgets/tpaw-account-widget.c b/tp-account-widgets/tpaw-account-widget.c
index e15a3d1..f4e3cd7 100644
--- a/tp-account-widgets/tpaw-account-widget.c
+++ b/tp-account-widgets/tpaw-account-widget.c
@@ -216,29 +216,19 @@ static void
 account_widget_set_entry_highlighting (GtkEntry *entry,
     gboolean highlight)
 {
+  GtkStyleContext *style;
+
   g_return_if_fail (GTK_IS_ENTRY (entry));
 
+  style = gtk_widget_get_style_context (GTK_WIDGET (entry));
+
   if (highlight)
     {
-      GtkStyleContext *style;
-      GdkRGBA color;
-
-      style = gtk_widget_get_style_context (GTK_WIDGET (entry));
-      gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED,
-          &color);
-
-      /* Here we take the current theme colour and add it to
-       * the colour for white and average the two. This
-       * gives a colour which is inline with the theme but
-       * slightly whiter.
-       */
-      tpaw_make_color_whiter (&color);
-
-      gtk_widget_override_background_color (GTK_WIDGET (entry), 0, &color);
+      gtk_style_context_add_class (style, GTK_STYLE_CLASS_ERROR);
     }
   else
     {
-      gtk_widget_override_background_color (GTK_WIDGET (entry), 0, NULL);
+      gtk_style_context_remove_class (style, GTK_STYLE_CLASS_ERROR);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]