diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2012-04-12 20:50:07 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2012-04-12 20:50:07 +0800 |
commit | 5768b8c03808c64e1f8b458c6ce0d37dff13aa26 (patch) | |
tree | 1e077414ac8f18fa72e6b83f3514a010a7d683c8 /widgets/misc | |
parent | 13762515153f9e254e5c17fb747ad76121f8710c (diff) | |
download | gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.tar gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.tar.gz gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.tar.bz2 gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.tar.lz gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.tar.xz gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.tar.zst gsoc2013-evolution-5768b8c03808c64e1f8b458c6ce0d37dff13aa26.zip |
EWebView: Make antialiasing settings optional.
Check if the "org.gnome.settings-daemon.plugins.xsettings" schema is
available before creating a GSettings object for it, to avoid a hard
dependency on gnome-settings-daemon.
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/e-web-view.c | 63 |
1 files changed, 38 insertions, 25 deletions
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c index ca021b71f7..7baf5bb5cd 100644 --- a/widgets/misc/e-web-view.c +++ b/widgets/misc/e-web-view.c @@ -1671,6 +1671,8 @@ e_web_view_init (EWebView *web_view) GtkActionGroup *action_group; EPopupAction *popup_action; WebKitWebSettings *web_settings; + GSettingsSchema *settings_schema; + GSettings *settings; const gchar *domain = GETTEXT_PACKAGE; const gchar *id; GError *error = NULL; @@ -1710,15 +1712,26 @@ e_web_view_init (EWebView *web_view) e_web_view_set_settings (web_view, web_settings); g_object_unref (web_settings); - web_view->priv->font_settings = g_settings_new ("org.gnome.desktop.interface"); - g_signal_connect_swapped (web_view->priv->font_settings, "changed::font-name", - G_CALLBACK (e_web_view_update_fonts), web_view); - g_signal_connect_swapped (web_view->priv->font_settings, "changed::monospace-font-name", + settings = g_settings_new ("org.gnome.desktop.interface"); + g_signal_connect_swapped ( + settings, "changed::font-name", G_CALLBACK (e_web_view_update_fonts), web_view); - - web_view->priv->aliasing_settings = g_settings_new ("org.gnome.settings-daemon.plugins.xsettings"); - g_signal_connect_swapped (web_view->priv->aliasing_settings, "changed::antialiasing", + g_signal_connect_swapped ( + settings, "changed::monospace-font-name", G_CALLBACK (e_web_view_update_fonts), web_view); + web_view->priv->font_settings = settings; + + /* This schema is optional. Use if available. */ + id = "org.gnome.settings-daemon.plugins.xsettings"; + settings_schema = g_settings_schema_source_lookup ( + g_settings_schema_source_get_default (), id, FALSE); + if (settings_schema != NULL) { + settings = g_settings_new (id); + g_signal_connect_swapped ( + settings, "changed::antialiasing", + G_CALLBACK (e_web_view_update_fonts), web_view); + web_view->priv->aliasing_settings = settings; + } e_web_view_update_fonts (web_view); @@ -2841,10 +2854,12 @@ void e_web_view_update_fonts(EWebView *web_view) { GString *stylesheet; - gchar *aa, *base64; + gchar *base64; + gchar *aa = NULL; WebKitWebSettings *settings; PangoFontDescription *min_size, *ms, *vw; const gchar *styles[] = { "normal", "oblique", "italic" }; + const gchar *smoothing = NULL; ms = NULL; vw = NULL; @@ -2896,26 +2911,24 @@ e_web_view_update_fonts(EWebView *web_view) pango_font_description_get_weight (vw), styles[pango_font_description_get_style (vw)]); - aa = g_settings_get_string (web_view->priv->aliasing_settings, "antialiasing"); - if (aa) { - const gchar *smoothing = NULL; + if (web_view->priv->aliasing_settings != NULL) + aa = g_settings_get_string ( + web_view->priv->aliasing_settings, "antialiasing"); - if (g_strcmp0 (aa, "none") == 0) { - smoothing = "none"; - } else if (g_strcmp0 (aa, "grayscale") == 0) { - smoothing = "antialiased"; - } else if (g_strcmp0 (aa, "rgba") == 0) { - smoothing = "subpixel-antialiased"; - } + if (g_strcmp0 (aa, "none") == 0) + smoothing = "none"; + else if (g_strcmp0 (aa, "grayscale") == 0) + smoothing = "antialiased"; + else if (g_strcmp0 (aa, "rgba") == 0) + smoothing = "subpixel-antialiased"; - if (smoothing) { - g_string_append_printf (stylesheet, - " -webkit-font-smoothing: %s;\n", - smoothing); - } + if (smoothing != NULL) + g_string_append_printf ( + stylesheet, + " -webkit-font-smoothing: %s;\n", + smoothing); - g_free (aa); - } + g_free (aa); g_string_append (stylesheet, "}\n"); |