From 440e43d2894fdd517cc91302d4364b082e7d1d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Fri, 27 Jul 2012 12:12:39 +0200 Subject: Bug #679404 - Read colors for message preview from Gtk theme --- data/webview.css | 10 --------- e-util/e-util.c | 25 ++++++++++++++++++++++ e-util/e-util.h | 2 ++ em-format/e-mail-formatter.c | 12 ++++++++--- mail/e-mail-display.c | 29 +++++++++++++------------- modules/itip-formatter/e-mail-formatter-itip.c | 2 +- modules/itip-formatter/itip-view.c | 13 +++++------- modules/itip-formatter/itip-view.h | 4 +++- widgets/misc/e-web-view.c | 19 ++++++++++++++++- 9 files changed, 78 insertions(+), 38 deletions(-) diff --git a/data/webview.css b/data/webview.css index a8a936d0a2..8d4c3397c2 100644 --- a/data/webview.css +++ b/data/webview.css @@ -12,21 +12,12 @@ body { margin: 10px; } -h1, h2, h3 { - color: #7f7f7f; -} - th { - color: #7f7f7f; text-align: left; font-weight: normal; vertical-align: top; } -.header { - color: #7f7f7f; -} - span.navigable, div.navigable, p.navigable { cursor: pointer; text-decoration: underline; @@ -123,7 +114,6 @@ object { /* GtkWidgets */ } .itip th { - color: #000; vertical-align: middle; } diff --git a/e-util/e-util.c b/e-util/e-util.c index a57998576a..2f84c34d9e 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -835,6 +835,31 @@ e_color_to_value (GdkColor *color) return (guint32) (((red << 16) | (green << 8) | blue) & 0xffffff); } +/** + * e_rgba_to_value: + * @rgba: a #GdkRGBA + * + + * Converts #GdkRGBA to a 24-bit RGB color value + * + * Returns: a 24-bit color value + **/ +guint32 +e_rgba_to_value (GdkRGBA *rgba) +{ + guint16 red; + guint16 green; + guint16 blue; + + g_return_val_if_fail (rgba != NULL, 0); + + red = ((guint16) (G_MAXUINT16 * rgba->red)) >> 8; + green = ((guint16) (G_MAXUINT16 * rgba->green)) >> 8; + blue = ((guint16) (G_MAXUINT16 * rgba->blue)) >> 8; + + return (guint32) (((red << 16) | (green << 8) | blue) & 0xffffff); +} + static gint epow10 (gint number) { diff --git a/e-util/e-util.h b/e-util/e-util.h index 11dd77541e..fa98153223 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -86,6 +86,8 @@ gint e_int_compare (gconstpointer x, gconstpointer y); guint32 e_color_to_value (GdkColor *color); +guint32 e_rgba_to_value (GdkRGBA *rgba); + /* This only makes a filename safe for usage as a filename. * It still may have shell meta-characters in it. */ gchar * e_format_number (gint number); diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c index 2957f867b1..99b00361c9 100644 --- a/em-format/e-mail-formatter.c +++ b/em-format/e-mail-formatter.c @@ -1060,12 +1060,18 @@ e_mail_formatter_get_html_header (EMailFormatter *formatter) "Evolution Mail Display\n" "\n" "\n" - "", + "", e_color_to_value ((GdkColor *) e_mail_formatter_get_color ( - formatter, E_MAIL_FORMATTER_COLOR_BODY))); + formatter, E_MAIL_FORMATTER_COLOR_HEADER)), + e_color_to_value ((GdkColor *) + e_mail_formatter_get_color ( + formatter, E_MAIL_FORMATTER_COLOR_BODY)), + e_color_to_value ((GdkColor *) + e_mail_formatter_get_color ( + formatter, E_MAIL_FORMATTER_COLOR_TEXT))); } EMailExtensionRegistry * diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index 6cbbaa6091..57666ea5e8 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -1802,24 +1802,25 @@ void e_mail_display_set_status (EMailDisplay *display, const gchar *status) { - gchar *str; + gchar *str, *header; g_return_if_fail (E_IS_MAIL_DISPLAY (display)); + header = e_mail_formatter_get_html_header (display->priv->formatter); str = g_strdup_printf ( - "" - "" - "Evolution Mail Display" - "" - "" - "" - "" - "" - "
" - "%s" - "
" - "" - "", status); + "%s\n" + " \n" + " \n" + " \n" + " \n" + " \n" + "
\n" + " %s\n" + "
\n" + "\n" + "\n", + header, status); + g_free (header); e_web_view_load_string (E_WEB_VIEW (display), str); g_free (str); diff --git a/modules/itip-formatter/e-mail-formatter-itip.c b/modules/itip-formatter/e-mail-formatter-itip.c index bf64a96f67..c129c89150 100644 --- a/modules/itip-formatter/e-mail-formatter-itip.c +++ b/modules/itip-formatter/e-mail-formatter-itip.c @@ -85,7 +85,7 @@ emfe_itip_format (EMailFormatterExtension *extension, } else if (context->mode == E_MAIL_FORMATTER_MODE_RAW) { buffer = g_string_sized_new (2048); - itip_view_write (buffer); + itip_view_write (formatter, buffer); } else { gchar *uri; diff --git a/modules/itip-formatter/itip-view.c b/modules/itip-formatter/itip-view.c index 8e651f0ec9..bc54c65139 100644 --- a/modules/itip-formatter/itip-view.c +++ b/modules/itip-formatter/itip-view.c @@ -1416,15 +1416,12 @@ itip_view_set_extension_name (ItipView *view, } void -itip_view_write (GString *buffer) +itip_view_write (EMailFormatter *formatter, + GString *buffer) { - g_string_append (buffer, - "\n" - "\n" - "ITIP\n" - "\n" - "\n" - "\n"); + gchar *header = e_mail_formatter_get_html_header (formatter); + g_string_append (buffer, header); + g_free (header); g_string_append_printf (buffer, "\n", diff --git a/modules/itip-formatter/itip-view.h b/modules/itip-formatter/itip-view.h index 60b8b1d4ba..90558e7408 100644 --- a/modules/itip-formatter/itip-view.h +++ b/modules/itip-formatter/itip-view.h @@ -30,6 +30,7 @@ #include #include #include +#include G_BEGIN_DECLS @@ -100,7 +101,8 @@ ItipView * itip_view_new (EMailPartItip *puri, ESourceRegistry *registry); void itip_view_init_view (ItipView *view); -void itip_view_write (GString *buffer); +void itip_view_write (EMailFormatter *formatter, + GString *buffer); void itip_view_write_for_printing (ItipView *view, GString *buffer); diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index 5a65ad7155..8d6f9fe8cd 100644 --- a/widgets/misc/e-web-view.c +++ b/widgets/misc/e-web-view.c @@ -1874,9 +1874,26 @@ e_web_view_new (void) void e_web_view_clear (EWebView *web_view) { + GtkStyleContext *style_context; + GtkStateFlags state_flags; + GdkRGBA rgba; + gchar *html; + g_return_if_fail (E_IS_WEB_VIEW (web_view)); - webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_view), "about:blank"); + style_context = gtk_widget_get_style_context (GTK_WIDGET (web_view)); + state_flags = gtk_widget_get_state_flags (GTK_WIDGET (web_view)); + gtk_style_context_get_background_color ( + style_context, state_flags, &rgba); + + html = g_strdup_printf ( + "", + e_rgba_to_value (&rgba)); + + webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (web_view), html, NULL); + + g_free (html); } void -- cgit v1.2.3