commit: ba55c293c35cd727259f2d40c5e909ee052a7de3
parent: 481263d1730ef0c48a0fe56cf1838f44fe42021a
author: Chris Noxz <chris@noxz.tech>
date: Sun, 19 Mar 2023 15:38:05 +0100
rewrite web view settings
1 file changed, 20 insertions(+), 34 deletions(-)
diff --git a/browser.c b/browser.c
@@ -69,14 +69,26 @@ client_create(const gchar *uri, WebKitWebView *related_wv, gboolean show,
CB(c->wv, "scroll-event", cb_wv_hid, c);
CB(c->wv, "web-process-crashed", cb_wv_crashed, c);
- /* get webkit settings */
- c->settings = webkit_web_view_get_settings(WEBKIT_WEB_VIEW(c->wv));
-
/* load config into webkit settings */
- if (CFG_S(UserAgent) != NULL)
- g_object_set(
- G_OBJECT(c->settings), "user-agent", CFG_S(UserAgent), NULL
- );
+ c->settings = webkit_settings_new_with_settings(
+ "auto-load-images", !CFG_B(DisableAutoLoadImages),
+ "default-font-family", CFG_S(DefaultFont),
+ "default-font-size", CFG_I(DefaultFontSize),
+ "enable-developer-extras", CFG_B(DeveloperExtras),
+ "enable-dns-prefetching", FALSE,
+ "enable-hyperlink-auditing", FALSE,
+ "enable-smooth-scrolling", CFG_B(SmoothScrolling),
+ "enable-webrtc", FALSE,
+ "enable-write-console-messages-to-stdout", CFG_B(ConsoleToStdout),
+ "javascript-can-access-clipboard", FALSE,
+ "javascript-can-open-windows-automatically", FALSE,
+ "monospace-font-family", CFG_S(MonospaceFont),
+ "sans-serif-font-family", CFG_S(SansSerifFont),
+ "serif-font-family", CFG_S(SerifFont),
+ "user-agent", CFG_S(UserAgent),
+ NULL);
+ webkit_web_view_set_settings(WEBKIT_WEB_VIEW(c->wv), c->settings);
+
if (CFG_L(AcceptedLanguages) != NULL)
webkit_web_context_set_preferred_languages(
webkit_web_view_get_context(WEBKIT_WEB_VIEW(c->wv)),
@@ -101,38 +113,12 @@ client_create(const gchar *uri, WebKitWebView *related_wv, gboolean show,
webkit_web_view_set_zoom_level(
WEBKIT_WEB_VIEW(c->wv), CFG_F(ZoomLevel)
);
- webkit_settings_set_auto_load_images(
- c->settings, !CFG_B(DisableAutoLoadImages)
- );
- webkit_settings_set_default_font_family(
- c->settings, CFG_S(DefaultFont)
- );
- webkit_settings_set_default_font_size(
- c->settings, CFG_I(DefaultFontSize)
- );
- webkit_settings_set_enable_developer_extras(
- c->settings, CFG_B(DeveloperExtras)
- );
- webkit_settings_set_enable_smooth_scrolling(
- c->settings, CFG_B(SmoothScrolling)
- );
- webkit_settings_set_enable_write_console_messages_to_stdout(
- c->settings, CFG_B(ConsoleToStdout)
- );
- webkit_settings_set_monospace_font_family(
- c->settings, CFG_S(MonospaceFont)
- );
- webkit_settings_set_sans_serif_font_family(
- c->settings, CFG_S(SansSerifFont)
- );
- webkit_settings_set_serif_font_family(
- c->settings, CFG_S(SerifFont)
- );
/* create entry */
c->entry = gtk_entry_new();
CB(c->entry, "key-press-event", cb_entry_hid, c);
CB(c->entry, "icon-release", cb_entry_icon_hid, c);
+
/* entry must exist before first call */
set_javascript_policy(c, JSP_ENABLE);