aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Keller <sebastian-keller@gmx.de>2014-06-23 17:39:46 +0800
committerMilan Crha <mcrha@redhat.com>2014-06-23 17:39:46 +0800
commit74366fc820e481fa67c66c2dc3c156c986f450c4 (patch)
tree53e3e6167a8bc52d597028b26ed4b9bc3e15e663
parent28c1fe23b166dd2e663c1622469c83a98a42e8a7 (diff)
downloadgsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.tar
gsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.tar.gz
gsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.tar.bz2
gsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.tar.lz
gsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.tar.xz
gsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.tar.zst
gsoc2013-evolution-74366fc820e481fa67c66c2dc3c156c986f450c4.zip
Bug 731872 - EWebView: Use named colors from themes
-rw-r--r--e-util/e-web-view.c40
-rw-r--r--em-format/e-mail-formatter.c38
2 files changed, 43 insertions, 35 deletions
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index 5a1881dd85..abe33b99e8 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -606,20 +606,20 @@ style_updated_cb (EWebView *web_view)
gchar *style;
GtkStateFlags state_flags;
GtkStyleContext *style_context;
- GtkWidgetPath *widget_path;
+ gboolean backdrop;
state_flags = gtk_widget_get_state_flags (GTK_WIDGET (web_view));
- style_context = gtk_style_context_new ();
- widget_path = gtk_widget_path_new ();
- gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
- gtk_style_context_set_path (style_context, widget_path);
- gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_ENTRY);
-
- gtk_style_context_get_background_color (
- style_context,
- state_flags | GTK_STATE_FLAG_FOCUSED,
- &color);
- color_value = g_strdup_printf ("#%06x", e_rgba_to_value (&color));
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (web_view));
+ backdrop = (state_flags & GTK_STATE_FLAG_BACKDROP) != 0;
+
+ if (gtk_style_context_lookup_color (
+ style_context,
+ backdrop ? "theme_unfocused_base_color" : "theme_base_color",
+ &color))
+ color_value = g_strdup_printf ("#%06x", e_rgba_to_value (&color));
+ else
+ color_value = g_strdup("#ffffff");
+
style = g_strconcat ("background-color: ", color_value, ";", NULL);
e_web_view_add_css_rule_into_style_sheet (
@@ -631,11 +631,14 @@ style_updated_cb (EWebView *web_view)
g_free (color_value);
g_free (style);
- gtk_style_context_get_color (
- style_context,
- state_flags | GTK_STATE_FLAG_FOCUSED,
- &color);
- color_value = g_strdup_printf ("#%06x", e_rgba_to_value (&color));
+ if (gtk_style_context_lookup_color (
+ style_context,
+ backdrop ? "theme_unfocused_fg_color" : "theme_fg_color",
+ &color))
+ color_value = g_strdup_printf ("#%06x", e_rgba_to_value (&color));
+ else
+ color_value = g_strdup("#000000");
+
style = g_strconcat ("color: ", color_value, ";", NULL);
e_web_view_add_css_rule_into_style_sheet (
@@ -644,9 +647,6 @@ style_updated_cb (EWebView *web_view)
".-e-web-view-text-color",
style);
- gtk_widget_path_free (widget_path);
- g_object_unref (style_context);
-
g_free (color_value);
g_free (style);
}
diff --git a/em-format/e-mail-formatter.c b/em-format/e-mail-formatter.c
index a21f51c308..4d00cf2b84 100644
--- a/em-format/e-mail-formatter.c
+++ b/em-format/e-mail-formatter.c
@@ -489,20 +489,21 @@ mail_formatter_update_style (EMailFormatter *formatter,
GtkStyleContext *style_context;
GtkWidgetPath *widget_path;
GdkRGBA rgba;
+ gboolean backdrop;
g_object_freeze_notify (G_OBJECT (formatter));
- /* derive colors from top-level window */
style_context = gtk_style_context_new ();
widget_path = gtk_widget_path_new ();
gtk_widget_path_append_type (widget_path, GTK_TYPE_WINDOW);
gtk_style_context_set_path (style_context, widget_path);
- gtk_style_context_invalidate (style_context);
+ backdrop = (state & GTK_STATE_FLAG_BACKDROP) != 0;
- gtk_style_context_save (style_context);
- gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_TOOLBAR);
-
- gtk_style_context_get_background_color (style_context, state, &rgba);
+ if (!gtk_style_context_lookup_color (
+ style_context,
+ backdrop ? "theme_unfocused_bg_color" : "theme_bg_color",
+ &rgba))
+ gdk_rgba_parse (&rgba, "#eeeeee");
e_mail_formatter_set_color (
formatter, E_MAIL_FORMATTER_COLOR_BODY, &rgba);
@@ -512,20 +513,27 @@ mail_formatter_update_style (EMailFormatter *formatter,
e_mail_formatter_set_color (
formatter, E_MAIL_FORMATTER_COLOR_FRAME, &rgba);
- gtk_style_context_restore (style_context);
- gtk_style_context_add_class (style_context, GTK_STYLE_CLASS_ENTRY);
-
- gtk_style_context_get_color (style_context, state, &rgba);
+ if (!gtk_style_context_lookup_color (
+ style_context,
+ backdrop ? "theme_unfocused_fg_color" : "theme_fg_color",
+ &rgba))
+ gdk_rgba_parse (&rgba, "#000000");
e_mail_formatter_set_color (
formatter, E_MAIL_FORMATTER_COLOR_HEADER, &rgba);
- gtk_style_context_get_background_color (
- style_context, state | GTK_STATE_FLAG_FOCUSED, &rgba);
+ if (!gtk_style_context_lookup_color (
+ style_context,
+ backdrop ? "theme_unfocused_base_color" : "theme_base_color",
+ &rgba))
+ gdk_rgba_parse (&rgba, "#ffffff");
e_mail_formatter_set_color (
formatter, E_MAIL_FORMATTER_COLOR_CONTENT, &rgba);
- gtk_style_context_get_color (
- style_context, state | GTK_STATE_FLAG_FOCUSED, &rgba);
+ if (!gtk_style_context_lookup_color (
+ style_context,
+ backdrop ? "theme_unfocused_fg_color" : "theme_fg_color",
+ &rgba))
+ gdk_rgba_parse (&rgba, "#000000");
e_mail_formatter_set_color (
formatter, E_MAIL_FORMATTER_COLOR_TEXT, &rgba);
@@ -605,7 +613,7 @@ e_mail_formatter_class_init (EMailFormatterClass *class)
gdk_rgba_parse (rgba, "#3f3f3f");
rgba = &class->colors[E_MAIL_FORMATTER_COLOR_HEADER];
- gdk_rgba_parse (rgba, "#eeeeee");
+ gdk_rgba_parse (rgba, "#000000");
rgba = &class->colors[E_MAIL_FORMATTER_COLOR_TEXT];
gdk_rgba_parse (rgba, "#000000");