[evolution] Read link/visited-link colors also from the style context flags



commit 5ca0cd8d70d45ef9a8476b95881fccbf0fbe5f59
Author: Milan Crha <mcrha redhat com>
Date:   Fri Nov 13 15:32:09 2015 +0100

    Read link/visited-link colors also from the style context flags
    
    The flags are available since Gtk 3.12. In case the theme switched
    to provide these colors exclusively through the flags the default
    colors were used, which might not be good for the current theme.

 e-util/e-html-editor-view.c |   14 ++++++++++----
 e-util/e-web-view.c         |   30 ++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 4 deletions(-)
---
diff --git a/e-util/e-html-editor-view.c b/e-util/e-html-editor-view.c
index 55b3ca7..1028729 100644
--- a/e-util/e-html-editor-view.c
+++ b/e-util/e-html-editor-view.c
@@ -10341,18 +10341,24 @@ get_color_from_context (GtkStyleContext *context,
        gtk_style_context_get_style (context, name, &color, NULL);
 
        if (color == NULL) {
+               gboolean is_visited = strstr (name, "visited") != NULL;
+
                out_color->alpha = 1;
-               out_color->red = strstr (name, "visited") ? 1 : 0;
+               out_color->red = is_visited ? 1 : 0;
                out_color->green = 0;
-               out_color->blue = strstr (name, "visited") ? 0 : 1;
+               out_color->blue = is_visited ? 0 : 1;
+
+               #if GTK_CHECK_VERSION(3,12,0)
+               gtk_style_context_get_color (context, is_visited ? GTK_STATE_FLAG_VISITED : 
GTK_STATE_FLAG_LINK, out_color);
+               #endif
        } else {
                out_color->alpha = 1;
                out_color->red = ((gdouble) color->red) / G_MAXUINT16;
                out_color->green = ((gdouble) color->green) / G_MAXUINT16;
                out_color->blue = ((gdouble) color->blue) / G_MAXUINT16;
-       }
 
-       gdk_color_free (color);
+               gdk_color_free (color);
+       }
 }
 
 static void
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 8d91ff1..e42b018 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -2811,13 +2811,43 @@ e_web_view_update_fonts (EWebView *web_view)
                NULL);
 
        if (link == NULL) {
+               #if GTK_CHECK_VERSION(3,12,0)
+               GdkRGBA rgba;
+               #endif
+
                link = g_slice_new0 (GdkColor);
                link->blue = G_MAXINT16;
+
+               #if GTK_CHECK_VERSION(3,12,0)
+               rgba.alpha = 1;
+               rgba.red = 0;
+               rgba.green = 0;
+               rgba.blue = 1;
+
+               gtk_style_context_get_color (context, GTK_STATE_FLAG_LINK, &rgba);
+
+               e_rgba_to_color (&rgba, link);
+               #endif
        }
 
        if (visited == NULL) {
+               #if GTK_CHECK_VERSION(3,12,0)
+               GdkRGBA rgba;
+               #endif
+
                visited = g_slice_new0 (GdkColor);
                visited->red = G_MAXINT16;
+
+               #if GTK_CHECK_VERSION(3,12,0)
+               rgba.alpha = 1;
+               rgba.red = 1;
+               rgba.green = 0;
+               rgba.blue = 0;
+
+               gtk_style_context_get_color (context, GTK_STATE_FLAG_VISITED, &rgba);
+
+               e_rgba_to_color (&rgba, visited);
+               #endif
        }
 
        g_string_append_printf (


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