From 13762515153f9e254e5c17fb747ad76121f8710c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Vr=C3=A1til?= Date: Thu, 12 Apr 2012 12:48:00 +0200 Subject: Bug #673108 - Font settings and monospace fonts don't work --- mail/e-mail-display.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ mail/em-format-html.c | 2 +- 2 files changed, 57 insertions(+), 1 deletion(-) (limited to 'mail') diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c index a1d95bdaaa..d1f3137c80 100644 --- a/mail/e-mail-display.c +++ b/mail/e-mail-display.c @@ -66,6 +66,8 @@ struct _EMailDisplayPrivate { GtkActionGroup *images_actions; gint force_image_load: 1; + + GSettings *settings; }; enum { @@ -314,6 +316,11 @@ mail_display_dispose (GObject *object) priv->formatter = NULL; } + if (priv->settings) { + g_object_unref (priv->settings); + priv->settings = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -1179,10 +1186,43 @@ mail_display_frame_created (WebKitWebView *web_view, G_CALLBACK (puri_bind_dom), NULL); } +static void +mail_display_set_fonts (EWebView *web_view, + PangoFontDescription **monospace, + PangoFontDescription **variable) +{ + EMailDisplay *display = E_MAIL_DISPLAY (web_view); + gboolean use_custom_font; + gchar *monospace_font, *variable_font; + + use_custom_font = g_settings_get_boolean (display->priv->settings, "use-custom-font"); + if (!use_custom_font) { + *monospace = NULL; + *variable = NULL; + return; + } + + monospace_font = g_settings_get_string ( + display->priv->settings, + "monospace-font"); + variable_font = g_settings_get_string ( + display->priv->settings, + "variable-width-font"); + + *monospace = monospace_font ? pango_font_description_from_string (monospace_font) : NULL; + *variable = variable_font ? pango_font_description_from_string (variable_font) : NULL; + + if (monospace_font) + g_free (monospace_font); + if (variable_font) + g_free (variable_font); +} + static void e_mail_display_class_init (EMailDisplayClass *class) { GObjectClass *object_class; + EWebViewClass *web_view_class; GtkWidgetClass *widget_class; parent_class = g_type_class_peek_parent (class); @@ -1193,6 +1233,9 @@ e_mail_display_class_init (EMailDisplayClass *class) object_class->get_property = mail_display_get_property; object_class->dispose = mail_display_dispose; + web_view_class = E_WEB_VIEW_CLASS (class); + web_view_class->set_fonts = mail_display_set_fonts; + widget_class = GTK_WIDGET_CLASS (class); widget_class->realize = mail_display_realize; widget_class->style_set = mail_display_style_set; @@ -1280,6 +1323,19 @@ e_mail_display_init (EMailDisplay *display) g_signal_connect (display, "frame-created", G_CALLBACK (mail_display_frame_created), NULL); + display->priv->settings = g_settings_new ("org.gnome.evolution.mail"); + g_signal_connect_swapped ( + display->priv->settings , "changed::monospace-font", + G_CALLBACK (e_web_view_update_fonts), display); + g_signal_connect_swapped ( + display->priv->settings , "changed::variable-width-font", + G_CALLBACK (e_web_view_update_fonts), display); + g_signal_connect_swapped ( + display->priv->settings , "changed::use-custom-font", + G_CALLBACK (e_web_view_update_fonts), display); + + e_web_view_update_fonts (E_WEB_VIEW (display)); + main_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (display)); g_signal_connect (main_frame, "notify::load-status", G_CALLBACK (setup_DOM_bindings), NULL); diff --git a/mail/em-format-html.c b/mail/em-format-html.c index 0dd190eba9..020ca9e721 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -760,7 +760,7 @@ efh_write_text_plain (EMFormat *emf, content = g_strdup_printf ( "
" - "
\n", + "
\n", e_color_to_value (&efh->priv->colors[ EM_FORMAT_HTML_COLOR_FRAME]), e_color_to_value (&efh->priv->colors[ -- cgit v1.2.3