aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Vrátil <dvratil@redhat.com>2012-07-27 18:12:39 +0800
committerDan Vrátil <dvratil@redhat.com>2012-07-27 18:13:20 +0800
commit440e43d2894fdd517cc91302d4364b082e7d1d8b (patch)
tree7c39a2b70fe8bdef99ed1cce3c7b2e6d2406d0cc
parente03d9fbc7efba1a0239f85a8cf7339bbad6b1c7d (diff)
downloadgsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.gz
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.tar.zst
gsoc2013-evolution-440e43d2894fdd517cc91302d4364b082e7d1d8b.zip
Bug #679404 - Read colors for message preview from Gtk theme
-rw-r--r--data/webview.css10
-rw-r--r--e-util/e-util.c25
-rw-r--r--e-util/e-util.h2
-rw-r--r--em-format/e-mail-formatter.c12
-rw-r--r--mail/e-mail-display.c29
-rw-r--r--modules/itip-formatter/e-mail-formatter-itip.c2
-rw-r--r--modules/itip-formatter/itip-view.c13
-rw-r--r--modules/itip-formatter/itip-view.h4
-rw-r--r--widgets/misc/e-web-view.c19
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)
"<title>Evolution Mail Display</title>\n"
"<link type=\"text/css\" rel=\"stylesheet\" href=\"evo-file://" EVOLUTION_PRIVDATADIR "/theme/webview.css\" />\n"
"<style type=\"text/css\">\n"
- " table th { color: #000; font-weight: bold; }\n"
+ " table th { color: #%06x; font-weight: bold; }\n"
"</style>\n"
- "</head><body bgcolor=\"#%06x\">",
+ "</head><body bgcolor=\"#%06x\" text=\"#%06x\">",
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 (
- "<!DOCTYPE>"
- "<html>"
- "<head><title>Evolution Mail Display</title></head>"
- "<body>"
- "<table border=\"0\" width=\"100%%\" height=\"100%%\">"
- "<tr height=\"100%%\" valign=\"middle\">"
- "<td width=\"100%%\" align=\"center\">"
- "<strong>%s</strong>"
- "</td>"
- "</tr>"
- "</table>"
- "</body>"
- "</html>", status);
+ "%s\n"
+ " <style>html, body { height: 100%%; }</style>\n"
+ " <table border=\"0\" width=\"100%%\" height=\"100%%\">\n"
+ " <tr height=\"100%%\" valign=\"middle\">\n"
+ " <td width=\"100%%\" align=\"center\">\n"
+ " <strong>%s</strong>\n"
+ " </td>\n"
+ " </tr>\n"
+ " </table>\n"
+ "</body>\n"
+ "</html>\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,
- "<html>\n"
- "<head>\n"
- "<title>ITIP</title>\n"
- "<link type=\"text/css\" rel=\"stylesheet\" href=\"evo-file://" EVOLUTION_PRIVDATADIR "/theme/webview.css\" />\n"
- "</head>\n"
- "<body>\n");
+ gchar *header = e_mail_formatter_get_html_header (formatter);
+ g_string_append (buffer, header);
+ g_free (header);
g_string_append_printf (buffer,
"<img src=\"gtk-stock://%s?size=%d\" class=\"itip icon\" />\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 <webkit/webkitdom.h>
#include <libecal/libecal.h>
#include <libedataserver/libedataserver.h>
+#include <em-format/e-mail-formatter.h>
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 (
+ "<html><head></hea
+ d><body bgcolor=\"#%06x\"></body></html>",
+ e_rgba_to_value (&rgba));
+
+ webkit_web_view_load_html_string (WEBKIT_WEB_VIEW (web_view), html, NULL);
+
+ g_free (html);
}
void