[evolution/wip-webkit2] Introduce another WebKitWebView group for EMailDisplay.
- From: Tomas Popela <tpopela src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/wip-webkit2] Introduce another WebKitWebView group for EMailDisplay.
- Date: Fri, 8 Nov 2013 13:51:59 +0000 (UTC)
commit 373a1203127197f842285f65f807289df8766e7b
Author: Tomas Popela <tpopela redhat com>
Date: Fri Nov 8 14:47:29 2013 +0100
Introduce another WebKitWebView group for EMailDisplay.
Now we have two separate groups. One that is used for email preview and
the other one that is used for Addressbook and Calendar. Also the WK
inicialization was grouped together into e_web_view_initialize_webkit.
addressbook/gui/widgets/eab-contact-display.c | 9 +-
calendar/gui/e-cal-component-preview.c | 5 +-
e-util/Makefile.am | 1 +
e-util/e-web-view.c | 543 ++++++++++++++---------
e-util/e-web-view.h | 14 +-
mail/e-mail-display.c | 119 ++++--
mail/e-mail-display.h | 3 +
mail/e-mail-paned-view.c | 4 +-
mail/e-mail-printer.c | 4 +-
modules/mail/e-mail-shell-backend.c | 5 +-
modules/web-inspector/evolution-web-inspector.c | 5 +-
shell/Makefile.am | 1 -
shell/main.c | 5 +-
13 files changed, 459 insertions(+), 259 deletions(-)
---
diff --git a/addressbook/gui/widgets/eab-contact-display.c b/addressbook/gui/widgets/eab-contact-display.c
index d270973..8a8b9eb 100644
--- a/addressbook/gui/widgets/eab-contact-display.c
+++ b/addressbook/gui/widgets/eab-contact-display.c
@@ -535,10 +535,10 @@ eab_contact_display_init (EABContactDisplay *display)
e_web_view_register_uri_scheme (E_WEB_VIEW (display), FILE_URI_SCHEME, NULL, NULL);
e_web_view_register_uri_scheme (E_WEB_VIEW (display), GTK_STOCK_URI_SCHEME, NULL, NULL);
- /*
+#if 0
e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_FILE_REQUEST);
e_web_view_install_request_handler (E_WEB_VIEW (display), E_TYPE_STOCK_REQUEST);
-*/
+#endif
action_group = gtk_action_group_new ("internal-mailto");
gtk_action_group_set_translation_domain (action_group, domain);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
@@ -559,7 +559,10 @@ eab_contact_display_init (EABContactDisplay *display)
GtkWidget *
eab_contact_display_new (void)
{
- return g_object_new (EAB_TYPE_CONTACT_DISPLAY, NULL);
+ return g_object_new (
+ EAB_TYPE_CONTACT_DISPLAY,
+ "group", e_web_view_get_web_view_group (),
+ NULL);
}
EContact *
diff --git a/calendar/gui/e-cal-component-preview.c b/calendar/gui/e-cal-component-preview.c
index c96e064..33a6646 100644
--- a/calendar/gui/e-cal-component-preview.c
+++ b/calendar/gui/e-cal-component-preview.c
@@ -446,7 +446,10 @@ e_cal_component_preview_init (ECalComponentPreview *preview)
GtkWidget *
e_cal_component_preview_new (void)
{
- return g_object_new (E_TYPE_CAL_COMPONENT_PREVIEW, NULL);
+ return g_object_new (
+ E_TYPE_CAL_COMPONENT_PREVIEW,
+ "group", e_web_view_get_web_view_group (),
+ NULL);
}
void
diff --git a/e-util/Makefile.am b/e-util/Makefile.am
index ab874f4..4fab4ac 100644
--- a/e-util/Makefile.am
+++ b/e-util/Makefile.am
@@ -94,6 +94,7 @@ libevolution_util_la_CPPFLAGS = \
-DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \
-DEVOLUTION_UIDIR=\""$(uidir)"\" \
-DEVOLUTION_RULEDIR=\"$(ruledir)\" \
+ -DEVOLUTION_WEB_EXTENSIONS_DIR=\""$(webextensionsdir)"\" \
-DG_LOG_DOMAIN=\"evolution-util\" \
$(EVOLUTION_DATA_SERVER_CFLAGS) \
$(GNOME_PLATFORM_CFLAGS) \
diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c
index d79dfeb..1d7dca6 100644
--- a/e-util/e-web-view.c
+++ b/e-util/e-web-view.c
@@ -359,39 +359,6 @@ static GtkActionEntry standard_entries[] = {
};
static void
-web_view_init_webkit_settings (EWebView *web_view)
-{
- WebKitSettings *webkit_settings;
-
- webkit_settings =
- webkit_settings_new_with_settings (
- "enable-frame-flattening", TRUE,
- "auto-load-images", TRUE,
- "enable-page-cache", FALSE,
- "enable-java", FALSE,
- "enable-javascript", FALSE,
- "enable-plugins", FALSE,
- "enable-html5-database", FALSE,
- "enable-html5-local-storage", FALSE,
- "enable-private-browsing", TRUE,
- "enable-smooth-scrolling", TRUE,
- "enable-offline-web-application-cache", FALSE,
- "media-playback-allows-inline", FALSE,
- NULL);
-
- g_object_bind_property (
- webkit_settings, "enable-caret-browsing",
- web_view, "caret-mode",
- G_BINDING_BIDIRECTIONAL |
- G_BINDING_SYNC_CREATE);
-
- webkit_web_view_set_settings (
- WEBKIT_WEB_VIEW (web_view), webkit_settings);
-
- g_object_unref (webkit_settings);
-}
-
-static void
web_view_menu_item_select_cb (EWebView *web_view,
GtkWidget *widget)
{
@@ -531,7 +498,7 @@ web_view_context_menu_cb (WebKitWebView *webkit_web_view,
return event_handled;
}
-
+#if 0
static GtkWidget *
web_view_create_plugin_widget_cb (EWebView *web_view,
const gchar *mime_type,
@@ -549,7 +516,7 @@ web_view_create_plugin_widget_cb (EWebView *web_view,
return class->create_plugin_widget (web_view, mime_type, uri, param);
}
-
+#endif
static void
web_view_mouse_target_changed_cb (EWebView *web_view,
WebKitHitTestResult *hit_test_result,
@@ -904,6 +871,7 @@ web_view_finalize (GObject *object)
static void
web_view_constructed (GObject *object)
{
+ WebKitSettings *web_settings;
#ifndef G_OS_WIN32
GSettings *settings;
@@ -921,6 +889,14 @@ web_view_constructed (GObject *object)
g_object_unref (settings);
#endif
+ web_settings = webkit_web_view_group_get_settings (
+ e_web_view_get_web_view_group ());
+
+ g_object_bind_property (
+ web_settings, "enable-caret-browsing",
+ E_WEB_VIEW (object), "caret-mode",
+ G_BINDING_BIDIRECTIONAL |
+ G_BINDING_SYNC_CREATE);
e_extensible_load_extensions (E_EXTENSIBLE (object));
@@ -1819,6 +1795,34 @@ e_web_view_register_uri_scheme (EWebView *web_view,
}
static void
+web_view_update_fonts (EWebView *web_view)
+{
+ e_web_view_update_fonts (web_view, e_web_view_get_web_view_group ());
+}
+
+void
+e_web_view_update_fonts (EWebView *web_view,
+ WebKitWebViewGroup *web_view_group)
+{
+ EWebViewClass *class;
+ PangoFontDescription *ms = NULL, *vw = NULL;
+
+ g_return_if_fail (E_IS_WEB_VIEW (web_view));
+
+ class = E_WEB_VIEW_GET_CLASS (web_view);
+ if (class->set_fonts != NULL)
+ class->set_fonts (web_view, &ms, &vw);
+
+ e_web_view_update_fonts_settings (
+ web_view->priv->font_settings,
+ web_view->priv->aliasing_settings,
+ web_view_group, ms, vw, GTK_WIDGET (web_view));
+
+ pango_font_description_free (ms);
+ pango_font_description_free (vw);
+}
+
+static void
e_web_view_init (EWebView *web_view)
{
GtkUIManager *ui_manager;
@@ -1830,17 +1834,16 @@ e_web_view_init (EWebView *web_view)
const gchar *id;
gulong handler_id;
GError *error = NULL;
- WebKitWebContext *web_context;
web_view->priv = E_WEB_VIEW_GET_PRIVATE (web_view);
/* XXX No WebKitWebView class method pointers to
* override so we have to use signal handlers. */
-
+#if 0
g_signal_connect (
web_view, "create-plugin-widget",
G_CALLBACK (web_view_create_plugin_widget_cb), NULL);
-
+#endif
g_signal_connect (
web_view, "context-menu",
G_CALLBACK (web_view_context_menu_cb), NULL);
@@ -1873,28 +1876,23 @@ e_web_view_init (EWebView *web_view)
ui_manager, "connect-proxy",
G_CALLBACK (web_view_connect_proxy_cb), web_view);
- web_view_init_webkit_settings (web_view);
web_view_watch_web_extension (web_view);
- web_view_set_find_controller (web_view);
-
- web_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (web_view));
- webkit_web_context_set_cache_model (web_context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
e_web_view_register_uri_scheme (web_view, FILE_URI_SCHEME, NULL, NULL);
e_web_view_register_uri_scheme (web_view, GTK_STOCK_URI_SCHEME, NULL, NULL);
-/*
+#if 0
e_web_view_install_request_handler (web_view, E_TYPE_FILE_REQUEST);
e_web_view_install_request_handler (web_view, E_TYPE_STOCK_REQUEST);
-*/
+#endif
settings = g_settings_new ("org.gnome.desktop.interface");
web_view->priv->font_settings = g_object_ref (settings);
handler_id = g_signal_connect_swapped (
settings, "changed::font-name",
- G_CALLBACK (e_web_view_update_fonts), web_view);
+ G_CALLBACK (web_view_update_fonts), web_view);
web_view->priv->font_name_changed_handler_id = handler_id;
handler_id = g_signal_connect_swapped (
settings, "changed::monospace-font-name",
- G_CALLBACK (e_web_view_update_fonts), web_view);
+ G_CALLBACK (web_view_update_fonts), web_view);
web_view->priv->monospace_font_name_changed_handler_id = handler_id;
g_object_unref (settings);
@@ -1907,13 +1905,11 @@ e_web_view_init (EWebView *web_view)
web_view->priv->aliasing_settings = g_object_ref (settings);
handler_id = g_signal_connect_swapped (
settings, "changed::antialiasing",
- G_CALLBACK (e_web_view_update_fonts), web_view);
+ G_CALLBACK (web_view_update_fonts), web_view);
web_view->priv->antialiasing_changed_handler_id = handler_id;
g_object_unref (settings);
}
- e_web_view_update_fonts (web_view);
-
action_group = gtk_action_group_new ("uri");
gtk_action_group_set_translation_domain (action_group, domain);
gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
@@ -2020,14 +2016,292 @@ e_web_view_init (EWebView *web_view)
id = "org.gnome.evolution.webview";
e_plugin_ui_register_manager (ui_manager, id, web_view);
e_plugin_ui_enable_manager (ui_manager, id);
+}
+
+static gdouble
+get_screen_dpi (GdkScreen *screen)
+{
+ gdouble dpi;
+ gdouble dp, di;
+
+ dpi = gdk_screen_get_resolution (screen);
+ if (dpi != -1)
+ return dpi;
+
+ dp = hypot (gdk_screen_get_width (screen), gdk_screen_get_height (screen));
+ di = hypot (gdk_screen_get_width_mm (screen), gdk_screen_get_height_mm (screen)) / 25.4;
+
+ return dp / di;
+}
+
+static guint
+normalize_font_size (GtkWidget *widget,
+ gdouble font_size)
+{
+ /* WebKit2 uses font sizes in pixels. */
+ GdkScreen *screen;
+ gdouble dpi;
+
+ if (widget) {
+ screen = gtk_widget_has_screen (widget) ?
+ gtk_widget_get_screen (widget) : gdk_screen_get_default ();
+ } else {
+ screen = gdk_screen_get_default ();
+ }
+
+ dpi = screen ? get_screen_dpi (screen) : 96;
+
+ return font_size / 72.0 * dpi;
+}
+
+void
+e_web_view_update_fonts_settings (GSettings *font_settings,
+ GSettings *aliasing_settings,
+ WebKitWebViewGroup *web_view_group,
+ PangoFontDescription *ms_font,
+ PangoFontDescription *vw_font,
+ GtkWidget *view_widget)
+{
+ gboolean clean_ms = FALSE, clean_vw = FALSE;
+ gchar *aa = NULL;
+ const gchar *styles[] = { "normal", "oblique", "italic" };
+ const gchar *smoothing = NULL;
+ GdkColor *link = NULL;
+ GdkColor *visited = NULL;
+ GString *stylesheet;
+ GtkStyleContext *context;
+ PangoFontDescription *min_size, *ms, *vw;
+ WebKitSettings *wk_settings;
+
+ if (!ms_font) {
+ gchar *font;
+
+ font = g_settings_get_string (
+ font_settings,
+ "monospace-font-name");
+
+ ms = pango_font_description_from_string (
+ (font != NULL) ? font : "monospace 10");
+
+ clean_ms = TRUE;
+
+ g_free (font);
+ } else
+ ms = ms_font;
+
+ if (vw_font == NULL) {
+ gchar *font;
+
+ font = g_settings_get_string (
+ font_settings,
+ "font-name");
+
+ vw = pango_font_description_from_string (
+ (font != NULL) ? font : "serif 10");
+
+ clean_vw = TRUE;
+
+ g_free (font);
+ } else
+ vw = vw_font;
+
+ if (pango_font_description_get_size (ms) < pango_font_description_get_size (vw))
+ min_size = ms;
+ else
+ min_size = vw;
+
+ stylesheet = g_string_new ("");
+ g_string_append_printf (
+ stylesheet,
+ "body {\n"
+ " font-family: '%s';\n"
+ " font-size: %dpt;\n"
+ " font-weight: %d;\n"
+ " font-style: %s;\n",
+ pango_font_description_get_family (vw),
+ pango_font_description_get_size (vw) / PANGO_SCALE,
+ pango_font_description_get_weight (vw),
+ styles[pango_font_description_get_style (vw)]);
+
+ if (aliasing_settings != NULL)
+ aa = g_settings_get_string (
+ 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 (smoothing != NULL)
+ g_string_append_printf (
+ stylesheet,
+ " -webkit-font-smoothing: %s;\n",
+ smoothing);
+
+ g_free (aa);
+
+ g_string_append (stylesheet, "}\n");
+
+ g_string_append_printf (
+ stylesheet,
+ "pre,code,.pre {\n"
+ " font-family: '%s';\n"
+ " font-size: %dpt;\n"
+ " font-weight: %d;\n"
+ " font-style: %s;\n"
+ "} \n",
+ pango_font_description_get_family (ms),
+ pango_font_description_get_size (ms) / PANGO_SCALE,
+ pango_font_description_get_weight (ms),
+ styles[pango_font_description_get_style (ms)]);
+
+ if (view_widget) {
+ context = gtk_widget_get_style_context (view_widget);
+ gtk_style_context_get_style (
+ context,
+ "link-color", &link,
+ "visited-link-color", &visited,
+ NULL);
+
+ if (link == NULL) {
+ link = g_slice_new0 (GdkColor);
+ link->blue = G_MAXINT16;
+ }
+
+ if (visited == NULL) {
+ visited = g_slice_new0 (GdkColor);
+ visited->red = G_MAXINT16;
+ }
+
+ g_string_append_printf (
+ stylesheet,
+ "a {\n"
+ " color: #%06x;\n"
+ "}\n"
+ "a:visited {\n"
+ " color: #%06x;\n"
+ "}\n",
+ e_color_to_value (link),
+ e_color_to_value (visited));
+
+ gdk_color_free (link);
+ gdk_color_free (visited);
+ }
+
+ wk_settings = webkit_web_view_group_get_settings (web_view_group);
+
+ g_object_set (
+ wk_settings,
+ "default-font-size",
+ normalize_font_size (
+ view_widget, pango_font_description_get_size (vw) / PANGO_SCALE),
+ "default-font-family",
+ pango_font_description_get_family (vw),
+ "monospace-font-family",
+ pango_font_description_get_family (ms),
+ "default-monospace-font-size",
+ normalize_font_size (
+ view_widget, pango_font_description_get_size (ms) / PANGO_SCALE),
+ "minimum-font-size",
+ normalize_font_size (
+ view_widget, pango_font_description_get_size (min_size) / PANGO_SCALE),
+ NULL);
+
+ webkit_web_view_group_add_user_style_sheet (
+ web_view_group,
+ stylesheet->str,
+ NULL, NULL, NULL,
+ WEBKIT_INJECTED_CONTENT_FRAMES_ALL);
+
+ g_string_free (stylesheet, TRUE);
- e_web_view_clear (E_WEB_VIEW (web_view));
+ if (clean_ms)
+ pango_font_description_free (ms);
+ if (clean_vw)
+ pango_font_description_free (vw);
+}
+
+void
+e_web_view_initialize_settings (WebKitSettings *settings)
+{
+ g_object_set (settings,
+ "auto-load-images", TRUE,
+ "enable-html5-database", FALSE,
+ "enable-html5-local-storage", FALSE,
+ "enable-java", FALSE,
+ "enable-javascript", FALSE,
+ "enable-offline-web-application-cache", FALSE,
+ "enable-page-cache", FALSE,
+ "enable-plugins", FALSE,
+ "enable-private-browsing", TRUE,
+ "enable-smooth-scrolling", TRUE,
+ "media-playback-allows-inline", FALSE,
+ NULL);
+}
+
+static void
+web_view_initialize_group (WebKitWebViewGroup *web_view_group)
+{
+ const gchar *id = "org.gnome.settings-daemon.plugins.xsettings";
+ GSettings *settings;
+ GSettingsSchema *settings_schema;
+ WebKitSettings *wk_settings;
+
+ wk_settings = webkit_web_view_group_get_settings (web_view_group);
+
+ e_web_view_initialize_settings (wk_settings);
+
+ /* Optional schema */
+ settings_schema = g_settings_schema_source_lookup (
+ g_settings_schema_source_get_default (), id, FALSE);
+
+ if (settings_schema)
+ settings = g_settings_new (id);
+ else
+ settings = NULL;
+
+ e_web_view_update_fonts_settings (
+ g_settings_new ("org.gnome.desktop.interface"),
+ settings,
+ web_view_group, NULL, NULL, NULL);
+}
+
+WebKitWebViewGroup *
+e_web_view_get_web_view_group (void)
+{
+ static WebKitWebViewGroup *web_view_group = NULL;
+
+ if (!web_view_group) {
+ web_view_group = webkit_web_view_group_new ("Evolution WebView Group");
+ web_view_initialize_group (web_view_group);
+ }
+
+ return web_view_group;
+}
+
+void
+e_web_view_initialize_webkit (void)
+{
+ WebKitWebContext *web_context;
+
+ web_context = webkit_web_context_get_default ();
+
+ /* Set the web extensions dir before the process is launched */
+ webkit_web_context_set_web_extensions_directory (
+ web_context, EVOLUTION_WEB_EXTENSIONS_DIR);
+
+ webkit_web_context_set_cache_model (web_context, WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
}
GtkWidget *
e_web_view_new (void)
{
- return g_object_new (E_TYPE_WEB_VIEW, NULL);
+ return g_object_new (
+ E_TYPE_WEB_VIEW,
+ "group", e_web_view_get_web_view_group (),
+ NULL);
}
void
@@ -2971,171 +3245,6 @@ e_web_view_get_selection_content_html_sync (EWebView *web_view,
return NULL;
}
-void
-e_web_view_update_fonts (EWebView *web_view)
-{
- EWebViewClass *class;
- GString *stylesheet;
- gchar *base64;
- gchar *aa = NULL;
- WebKitSettings *settings;
- PangoFontDescription *min_size, *ms, *vw;
- const gchar *styles[] = { "normal", "oblique", "italic" };
- const gchar *smoothing = NULL;
- GtkStyleContext *context;
- GdkColor *link = NULL;
- GdkColor *visited = NULL;
-
- g_return_if_fail (E_IS_WEB_VIEW (web_view));
-
- ms = NULL;
- vw = NULL;
-
- class = E_WEB_VIEW_GET_CLASS (web_view);
- if (class->set_fonts != NULL)
- class->set_fonts (web_view, &ms, &vw);
-
- if (ms == NULL) {
- gchar *font;
-
- font = g_settings_get_string (
- web_view->priv->font_settings,
- "monospace-font-name");
-
- ms = pango_font_description_from_string (
- (font != NULL) ? font : "monospace 10");
-
- g_free (font);
- }
-
- if (vw == NULL) {
- gchar *font;
-
- font = g_settings_get_string (
- web_view->priv->font_settings,
- "font-name");
-
- vw = pango_font_description_from_string (
- (font != NULL) ? font : "serif 10");
-
- g_free (font);
- }
-
- if (pango_font_description_get_size (ms) < pango_font_description_get_size (vw)) {
- min_size = ms;
- } else {
- min_size = vw;
- }
-
- stylesheet = g_string_new ("");
- g_string_append_printf (
- stylesheet,
- "body {\n"
- " font-family: '%s';\n"
- " font-size: %dpt;\n"
- " font-weight: %d;\n"
- " font-style: %s;\n",
- pango_font_description_get_family (vw),
- pango_font_description_get_size (vw) / PANGO_SCALE,
- pango_font_description_get_weight (vw),
- styles[pango_font_description_get_style (vw)]);
-
- 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 (smoothing != NULL)
- g_string_append_printf (
- stylesheet,
- " -webkit-font-smoothing: %s;\n",
- smoothing);
-
- g_free (aa);
-
- g_string_append (stylesheet, "}\n");
-
- g_string_append_printf (
- stylesheet,
- "pre,code,.pre {\n"
- " font-family: '%s';\n"
- " font-size: %dpt;\n"
- " font-weight: %d;\n"
- " font-style: %s;\n"
- "}",
- pango_font_description_get_family (ms),
- pango_font_description_get_size (ms) / PANGO_SCALE,
- pango_font_description_get_weight (ms),
- styles[pango_font_description_get_style (ms)]);
-
- context = gtk_widget_get_style_context (GTK_WIDGET (web_view));
- gtk_style_context_get_style (
- context,
- "link-color", &link,
- "visited-link-color", &visited,
- NULL);
-
- if (link == NULL) {
- link = g_slice_new0 (GdkColor);
- link->blue = G_MAXINT16;
- }
-
- if (visited == NULL) {
- visited = g_slice_new0 (GdkColor);
- visited->red = G_MAXINT16;
- }
-
- g_string_append_printf (
- stylesheet,
- "a {\n"
- " color: #%06x;\n"
- "}\n"
- "a:visited {\n"
- " color: #%06x;\n"
- "}\n",
- e_color_to_value (link),
- e_color_to_value (visited));
-
- gdk_color_free (link);
- gdk_color_free (visited);
-
- base64 = g_base64_encode ((guchar *) stylesheet->str, stylesheet->len);
- g_string_free (stylesheet, TRUE);
-
- stylesheet = g_string_new ("data:text/css;charset=utf-8;base64,");
- g_string_append (stylesheet, base64);
- g_free (base64);
-
- settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view));
- g_object_set (
- G_OBJECT (settings),
- "default-font-size",
- pango_font_description_get_size (vw) / PANGO_SCALE,
- "default-font-family",
- pango_font_description_get_family (vw),
- "monospace-font-family",
- pango_font_description_get_family (ms),
- "default-monospace-font-size",
- pango_font_description_get_size (ms) / PANGO_SCALE,
- "minimum-font-size",
- pango_font_description_get_size (min_size) / PANGO_SCALE,
-/* "user-stylesheet-uri",
- stylesheet->str,*/
- NULL);
-
-/*FIXME XXX stylesheet uri*/
- g_string_free (stylesheet, TRUE);
-
- pango_font_description_free (ms);
- pango_font_description_free (vw);
-}
-
/* Helper for e_web_view_cursor_image_copy() */
static void
web_view_cursor_image_copy_pixbuf_cb (GObject *source_object,
diff --git a/e-util/e-web-view.h b/e-util/e-web-view.h
index 84fb491..24f8ccb 100644
--- a/e-util/e-web-view.h
+++ b/e-util/e-web-view.h
@@ -113,6 +113,17 @@ struct _EWebViewClass {
GType e_web_view_get_type (void) G_GNUC_CONST;
GtkWidget * e_web_view_new (void);
+void e_web_view_initialize_webkit (void);
+void e_web_view_initialize_settings (WebKitSettings *settings);
+WebKitWebViewGroup *
+ e_web_view_get_web_view_group (void);
+void e_web_view_update_fonts_settings
+ (GSettings *font_settings,
+ GSettings *aliasing_settings,
+ WebKitWebViewGroup *web_view_group,
+ PangoFontDescription *ms_font,
+ PangoFontDescription *vw_font,
+ GtkWidget *view_widget);
void e_web_view_clear (EWebView *web_view);
void e_web_view_load_string (EWebView *web_view,
const gchar *string);
@@ -218,7 +229,8 @@ const gchar * e_web_view_get_selection_content_html_sync
(EWebView *web_view,
GCancellable *cancellable,
GError **error);
-void e_web_view_update_fonts (EWebView *web_view);
+void e_web_view_update_fonts (EWebView *web_view,
+ WebKitWebViewGroup *web_view_group);
void e_web_view_cursor_image_copy (EWebView *web_view);
void e_web_view_cursor_image_save (EWebView *web_view);
void e_web_view_request (EWebView *web_view,
diff --git a/mail/e-mail-display.c b/mail/e-mail-display.c
index 42466a3..26d67a6 100644
--- a/mail/e-mail-display.c
+++ b/mail/e-mail-display.c
@@ -1252,27 +1252,24 @@ mail_display_suggest_filename (EWebView *web_view,
}
static void
-mail_display_set_fonts (EWebView *web_view,
- PangoFontDescription **monospace,
- PangoFontDescription **variable)
+mail_display_get_font_settings (GSettings *settings,
+ PangoFontDescription **monospace,
+ PangoFontDescription **variable)
{
- EMailDisplay *display = E_MAIL_DISPLAY (web_view);
gboolean use_custom_font;
gchar *monospace_font;
gchar *variable_font;
- use_custom_font = g_settings_get_boolean (
- display->priv->settings, "use-custom-font");
+ use_custom_font = g_settings_get_boolean (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_font = g_settings_get_string (settings, "monospace-font");
+ variable_font = g_settings_get_string (settings, "variable-width-font");
*monospace = (monospace_font != NULL) ?
pango_font_description_from_string (monospace_font) : NULL;
@@ -1284,6 +1281,16 @@ mail_display_set_fonts (EWebView *web_view,
}
static void
+mail_display_set_fonts (EWebView *web_view,
+ PangoFontDescription **monospace,
+ PangoFontDescription **variable)
+{
+ EMailDisplay *display = E_MAIL_DISPLAY (web_view);
+
+ mail_display_get_font_settings (display->priv->settings, monospace, variable);
+}
+
+static void
e_mail_display_class_init (EMailDisplayClass *class)
{
GObjectClass *object_class;
@@ -1616,11 +1623,16 @@ mail_mail_uri_scheme_appeared_cb (WebKitURISchemeRequest *request,
}
static void
+mail_display_update_fonts (EMailDisplay *display)
+{
+ e_web_view_update_fonts (E_WEB_VIEW (display), e_mail_display_get_web_view_group ());
+}
+
+static void
e_mail_display_init (EMailDisplay *display)
{
GtkUIManager *ui_manager;
const gchar *user_cache_dir;
- WebKitSettings *settings;
GtkActionGroup *actions;
display->priv = E_MAIL_DISPLAY_GET_PRIVATE (display);
@@ -1632,25 +1644,25 @@ e_mail_display_init (EMailDisplay *display)
display->priv->force_image_load = FALSE;
display->priv->scheduled_reload = 0;
- settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (display));
- g_object_set (settings, "enable-frame-flattening", TRUE, NULL);
-
g_signal_connect (
display, "decide-policy",
G_CALLBACK (decide_policy_cb), NULL);
-/* g_signal_connect (
+#if 0
+ g_signal_connect (
display, "resource-request-starting",
- G_CALLBACK (mail_display_resource_requested), NULL);*/
+ G_CALLBACK (mail_display_resource_requested), NULL);
+#endif
g_signal_connect (
display, "process-mailto",
G_CALLBACK (mail_display_process_mailto), NULL);
-/* g_signal_connect (
+#if 0
+ g_signal_connect (
display, "create-plugin-widget",
- G_CALLBACK (mail_display_plugin_widget_requested), NULL);*/
+ G_CALLBACK (mail_display_plugin_widget_requested), NULL);
g_signal_connect (
display, "notify::uri",
G_CALLBACK (mail_display_uri_changed), NULL);
-
+#endif
g_signal_connect (
display, "mouse-target-changed",
G_CALLBACK (mail_display_mouse_target_changed_cb), NULL);
@@ -1658,15 +1670,13 @@ e_mail_display_init (EMailDisplay *display)
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_CALLBACK (mail_display_update_fonts), display);
g_signal_connect_swapped (
display->priv->settings , "changed::variable-width-font",
- G_CALLBACK (e_web_view_update_fonts), display);
+ G_CALLBACK (mail_display_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));
+ G_CALLBACK (mail_display_update_fonts), display);
g_signal_connect (
display, "load-changed",
@@ -1700,7 +1710,8 @@ e_mail_display_init (EMailDisplay *display)
e_web_view_register_uri_scheme (
E_WEB_VIEW (display), GTK_STOCK_URI_SCHEME,
mail_gtk_stock_uri_scheme_appeared_cb, display);
-/*
+
+#if 0
e_web_view_install_request_handler (
E_WEB_VIEW (display), E_TYPE_MAIL_REQUEST);
e_web_view_install_request_handler (
@@ -1709,7 +1720,7 @@ e_mail_display_init (EMailDisplay *display)
E_WEB_VIEW (display), E_TYPE_FILE_REQUEST);
e_web_view_install_request_handler (
E_WEB_VIEW (display), E_TYPE_STOCK_REQUEST);
-*/
+#endif
if (emd_global_http_cache == NULL) {
user_cache_dir = e_get_user_cache_dir ();
emd_global_http_cache = camel_data_cache_new (user_cache_dir, NULL);
@@ -1746,10 +1757,64 @@ e_mail_display_update_colors (EMailDisplay *display,
g_free (color_value);
}
+static void
+mail_display_initialize_group (WebKitWebViewGroup *web_view_group)
+{
+ const gchar *id = "org.gnome.settings-daemon.plugins.xsettings";
+ GSettings *settings;
+ GSettingsSchema *settings_schema;
+ WebKitSettings *wk_settings;
+ PangoFontDescription *ms = NULL, *vw = NULL;
+
+ wk_settings = webkit_web_view_group_get_settings (web_view_group);
+
+ e_web_view_initialize_settings (wk_settings);
+
+ g_object_set (wk_settings,
+ "enable-frame-flattening", TRUE,
+ NULL);
+
+ settings = g_settings_new ("org.gnome.evolution.mail");
+ mail_display_get_font_settings (settings, &ms, &vw);
+
+ /* Optional schema */
+ settings_schema = g_settings_schema_source_lookup (
+ g_settings_schema_source_get_default (), id, FALSE);
+
+ if (settings_schema)
+ settings = g_settings_new (id);
+ else
+ settings = NULL;
+
+ e_web_view_update_fonts_settings (
+ g_settings_new ("org.gnome.desktop.interface"),
+ settings,
+ web_view_group, ms, vw, NULL);
+
+ pango_font_description_free (ms);
+ pango_font_description_free (vw);
+}
+
+WebKitWebViewGroup *
+e_mail_display_get_web_view_group (void)
+{
+ static WebKitWebViewGroup *web_view_group = NULL;
+
+ if (!web_view_group) {
+ web_view_group = webkit_web_view_group_new ("Evolution Mail WebView Group");
+ mail_display_initialize_group (web_view_group);
+ }
+
+ return web_view_group;
+}
+
GtkWidget *
e_mail_display_new (void)
{
- return g_object_new (E_TYPE_MAIL_DISPLAY, NULL);
+ return g_object_new (
+ E_TYPE_MAIL_DISPLAY,
+ "group", e_mail_display_get_web_view_group (),
+ NULL);
}
EMailFormatterMode
diff --git a/mail/e-mail-display.h b/mail/e-mail-display.h
index f8e3199..9411850 100644
--- a/mail/e-mail-display.h
+++ b/mail/e-mail-display.h
@@ -63,6 +63,9 @@ struct _EMailDisplayClass {
GType e_mail_display_get_type (void) G_GNUC_CONST;
GtkWidget * e_mail_display_new (void);
+WebKitWebViewGroup *
+ e_mail_display_get_web_view_group
+ (void);
EMailFormatterMode
e_mail_display_get_mode (EMailDisplay *display);
void e_mail_display_set_mode (EMailDisplay *display,
diff --git a/mail/e-mail-paned-view.c b/mail/e-mail-paned-view.c
index f8b008a..b4be0ee 100644
--- a/mail/e-mail-paned-view.c
+++ b/mail/e-mail-paned-view.c
@@ -644,7 +644,9 @@ mail_paned_view_constructed (GObject *object)
priv->display = g_object_new (
E_TYPE_MAIL_DISPLAY,
- "headers-collapsable", TRUE, NULL);
+ "headers-collapsable", TRUE,
+ "group", e_mail_display_get_web_view_group (),
+ NULL);
view = E_MAIL_VIEW (object);
shell_view = e_mail_view_get_shell_view (view);
diff --git a/mail/e-mail-printer.c b/mail/e-mail-printer.c
index 4aa2875..cb34786 100644
--- a/mail/e-mail-printer.c
+++ b/mail/e-mail-printer.c
@@ -354,7 +354,9 @@ mail_printer_new_web_view (const gchar *charset,
web_view = g_object_new (
E_TYPE_MAIL_DISPLAY,
- "mode", E_MAIL_FORMATTER_MODE_PRINTING, NULL);
+ "mode", E_MAIL_FORMATTER_MODE_PRINTING,
+ "group", e_mail_display_get_web_view_group (),
+ NULL);
/* XXX EMailDisplay enables frame flattening to prevent scrollable
* subparts in an email, which understandable. This resets it
diff --git a/modules/mail/e-mail-shell-backend.c b/modules/mail/e-mail-shell-backend.c
index b3dc883..484de92 100644
--- a/modules/mail/e-mail-shell-backend.c
+++ b/modules/mail/e-mail-shell-backend.c
@@ -1080,7 +1080,10 @@ mbox_create_preview_cb (GObject *preview,
g_return_if_fail (preview != NULL);
g_return_if_fail (preview_widget != NULL);
- display = g_object_new (E_TYPE_MAIL_DISPLAY, NULL);
+ display = g_object_new (
+ E_TYPE_MAIL_DISPLAY,
+ "group", e_mail_display_get_web_view_group (),
+ NULL);
g_object_set_data_full (
preview, "mbox-imp-display",
g_object_ref (display), g_object_unref);
diff --git a/modules/web-inspector/evolution-web-inspector.c b/modules/web-inspector/evolution-web-inspector.c
index 2b5b5ea..88c3dfd 100644
--- a/modules/web-inspector/evolution-web-inspector.c
+++ b/modules/web-inspector/evolution-web-inspector.c
@@ -95,9 +95,10 @@ web_inspector_constructed (GObject *object)
extension = E_WEB_INSPECTOR (object);
web_view = web_inspector_get_web_view (extension);
- settings = webkit_web_view_get_settings (web_view);
- g_object_set (settings, "enable-developer-extras", TRUE, NULL);
+ settings = webkit_web_view_group_get_settings (
+ webkit_web_view_get_group (web_view));
+ webkit_settings_set_enable_developer_extras (settings, TRUE);
g_signal_connect (
web_view, "key-press-event",
diff --git a/shell/Makefile.am b/shell/Makefile.am
index d6f2cf5..7d42a68 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -114,7 +114,6 @@ evolution_CPPFLAGS = \
-DEVOLUTION_RULEDIR=\""$(privdatadir)"\" \
-DEVOLUTION_TOOLSDIR=\""$(privlibexecdir)"\" \
-DEVOLUTION_UIDIR=\""$(uidir)"\" \
- -DEVOLUTION_WEB_EXTENSIONS_DIR=\""$(webextensionsdir)"\" \
-DPREFIX=\""$(prefix)"\" \
-DEVOLUTION_MX_THEMEDIR=\"$(privdatadir)/theme\" \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
diff --git a/shell/main.c b/shell/main.c
index 5689f82..e5a5c02 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -609,10 +609,7 @@ main (gint argc,
if (setup_only)
exit (0);
- /* Set the web extensions dir before the process is launched */
- webkit_web_context_set_web_extensions_directory (
- webkit_web_context_get_default (),
- EVOLUTION_WEB_EXTENSIONS_DIR);
+ e_web_view_initialize_webkit ();
categories_icon_theme_hack ();
gtk_accel_map_load (e_get_accels_filename ());
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]