From 810242e4c9cdb41c00e1ad24106fbb0e4ab0d5af Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Mon, 22 Jul 2013 11:57:09 -0400 Subject: EWebView: Initialize WebKitWebSettings internally. Don't expose public API for this. Even though it's still possible through the WebKitWebView API, we don't want to encourage setting an arbitrary WebKitWebSettings on an EWebView. Removed functions: e_web_view_set_settings() e_web_view_get_default_settings() --- e-util/e-web-view.c | 99 +++++++++++++++++++++++------------------------------ e-util/e-web-view.h | 7 ---- 2 files changed, 43 insertions(+), 63 deletions(-) (limited to 'e-util') diff --git a/e-util/e-web-view.c b/e-util/e-web-view.c index 2921adbd30..77d9887ffb 100644 --- a/e-util/e-web-view.c +++ b/e-util/e-web-view.c @@ -333,6 +333,48 @@ static GtkActionEntry standard_entries[] = { G_CALLBACK (action_select_all_cb) } }; +static void +web_view_init_web_settings (WebKitWebView *web_view) +{ + WebKitWebSettings *web_settings; + GObjectClass *class; + GParamSpec *pspec; + + web_settings = webkit_web_settings_new (); + + g_object_set ( + G_OBJECT (web_settings), + "enable-frame-flattening", TRUE, + "enable-java-applet", FALSE, + "enable-html5-database", FALSE, + "enable-html5-local-storage", FALSE, + "enable-offline-web-application-cache", FALSE, + "enable-site-specific-quirks", TRUE, + "enable-scripts", FALSE, + NULL); + + /* This property was introduced in WebKitGTK 2.0, + * so check for it and enable it if it's present. */ + class = G_OBJECT_GET_CLASS (web_settings); + pspec = g_object_class_find_property ( + class, "respect-image-orientation"); + if (pspec != NULL) { + g_object_set ( + G_OBJECT (web_settings), + pspec->name, TRUE, NULL); + } + + g_object_bind_property ( + web_settings, "enable-caret-browsing", + web_view, "caret-mode", + G_BINDING_BIDIRECTIONAL | + G_BINDING_SYNC_CREATE); + + webkit_web_view_set_settings (web_view, web_settings); + + g_object_unref (web_settings); +} + static void web_view_menu_item_select_cb (EWebView *web_view, GtkWidget *widget) @@ -1594,7 +1636,6 @@ e_web_view_init (EWebView *web_view) GtkUIManager *ui_manager; GtkActionGroup *action_group; EPopupAction *popup_action; - WebKitWebSettings *web_settings; GSettingsSchema *settings_schema; GSettings *settings; const gchar *domain = GETTEXT_PACKAGE; @@ -1644,9 +1685,7 @@ e_web_view_init (EWebView *web_view) ui_manager, "connect-proxy", G_CALLBACK (web_view_connect_proxy_cb), web_view); - web_settings = e_web_view_get_default_settings (); - e_web_view_set_settings (web_view, web_settings); - g_object_unref (web_settings); + web_view_init_web_settings (WEBKIT_WEB_VIEW (web_view)); e_web_view_install_request_handler (web_view, E_TYPE_FILE_REQUEST); e_web_view_install_request_handler (web_view, E_TYPE_STOCK_REQUEST); @@ -2644,58 +2683,6 @@ e_web_view_get_selection_html (EWebView *web_view) return NULL; } -void -e_web_view_set_settings (EWebView *web_view, - WebKitWebSettings *settings) -{ - g_return_if_fail (E_IS_WEB_VIEW (web_view)); - - if (settings == webkit_web_view_get_settings (WEBKIT_WEB_VIEW (web_view))) - return; - - g_object_bind_property ( - 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), settings); -} - -WebKitWebSettings * -e_web_view_get_default_settings (void) -{ - WebKitWebSettings *settings; - GObjectClass *class; - GParamSpec *pspec; - - settings = webkit_web_settings_new (); - - g_object_set ( - G_OBJECT (settings), - "enable-frame-flattening", TRUE, - "enable-java-applet", FALSE, - "enable-html5-database", FALSE, - "enable-html5-local-storage", FALSE, - "enable-offline-web-application-cache", FALSE, - "enable-site-specific-quirks", TRUE, - "enable-scripts", FALSE, - NULL); - - /* This property was introduced in WebKitGTK 2.0, - * so check for it and enable it if it's present. */ - class = G_OBJECT_GET_CLASS (settings); - pspec = g_object_class_find_property ( - class, "respect-image-orientation"); - if (pspec != NULL) { - g_object_set ( - G_OBJECT (settings), - pspec->name, TRUE, NULL); - } - - return settings; -} - void e_web_view_update_fonts (EWebView *web_view) { diff --git a/e-util/e-web-view.h b/e-util/e-web-view.h index 07e2541e46..62ef1fab6a 100644 --- a/e-util/e-web-view.h +++ b/e-util/e-web-view.h @@ -200,15 +200,8 @@ void e_web_view_status_message (EWebView *web_view, void e_web_view_stop_loading (EWebView *web_view); void e_web_view_update_actions (EWebView *web_view); gchar * e_web_view_get_selection_html (EWebView *web_view); - -void e_web_view_set_settings (EWebView *web_view, - WebKitWebSettings *settings); - void e_web_view_update_fonts (EWebView *web_view); -WebKitWebSettings * - e_web_view_get_default_settings (void); - void e_web_view_install_request_handler (EWebView *web_view, GType handler_type); -- cgit v1.2.3