commit: fff048592a5d1046e277e25f76c566928007d386
parent: 273d6cb15efc711f12d318e564b99f6589684139
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 28 Mar 2019 21:18:20 +0100
Merge branch 'develop'
Diffstat:
M | badwolf.c | 86 | +++++++++++++++++++++++++++++++++++++++++++++---------------------------------- |
1 file changed, 49 insertions(+), 37 deletions(-)
diff --git a/badwolf.c b/badwolf.c
@@ -298,6 +298,7 @@ struct Client *
new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web_view)
{
struct Client *browser = g_malloc(sizeof(struct Client));
+ if(target_url == NULL) target_url = "about:blank";
browser->window = window;
browser->box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
@@ -307,24 +308,41 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
browser->javascript = gtk_check_button_new();
browser->statusbar = gtk_label_new(NULL);
- if(related_web_view == NULL)
- {
- WebKitWebContext *web_context = webkit_web_context_new_ephemeral();
-
- webkit_web_context_set_process_model(web_context,
- WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
-
- browser->webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_context(web_context));
-
- if(target_url == NULL)
- {
- target_url = "about:blank";
- }
- }
- else
- {
- browser->webView = WEBKIT_WEB_VIEW(webkit_web_view_new_with_related_view(related_web_view));
- }
+ WebKitWebContext *web_context = webkit_web_context_new_ephemeral();
+ webkit_web_context_set_process_model(web_context,
+ WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+
+ WebKitSettings *settings =
+ webkit_settings_new_with_settings("default-charset",
+ "utf-8",
+ "enable-caret-browsing",
+ TRUE,
+ "enable-developer-extras",
+ TRUE,
+ "enable-java",
+ FALSE,
+ "enable-javascript",
+ FALSE,
+ "enable-plugins",
+ FALSE,
+ "javascript-can-access-clipboard",
+ FALSE,
+ "javascript-can-open-windows-automatically",
+ FALSE,
+ "media-playback-requires-user-gesture",
+ TRUE,
+ "minimum-font-size",
+ 9,
+ NULL);
+
+ browser->webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
+ "web-context",
+ webkit_web_context_new_ephemeral(),
+ "related-view",
+ related_web_view,
+ "settings",
+ settings,
+ NULL));
gtk_widget_set_tooltip_text(browser->javascript, "Toggle javascript");
@@ -354,7 +372,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
gtk_widget_set_halign(browser->statusbar, GTK_ALIGN_START);
gtk_label_set_single_line_mode(GTK_LABEL(browser->statusbar), TRUE);
- if(target_url != NULL) gtk_entry_set_text(GTK_ENTRY(browser->location), target_url);
+ gtk_entry_set_text(GTK_ENTRY(browser->location), target_url);
gtk_entry_set_has_frame(GTK_ENTRY(browser->location), FALSE);
gtk_entry_set_input_purpose(GTK_ENTRY(browser->location), GTK_INPUT_PURPOSE_URL);
@@ -393,24 +411,7 @@ new_browser(struct Window *window, gchar *target_url, WebKitWebView *related_web
browser->search, "search-changed", G_CALLBACK(SearchEntryCb_search__changed), browser);
g_signal_connect(browser->search, "stop-search", G_CALLBACK(SearchEntryCb_stop__search), browser);
- WebKitSettings *settings = webkit_web_view_get_settings(browser->webView);
-
- webkit_settings_set_default_charset(settings, "utf-8");
- webkit_settings_set_enable_caret_browsing(settings, TRUE);
- webkit_settings_set_enable_developer_extras(settings, TRUE);
- webkit_settings_set_enable_java(settings, FALSE); /* dangerous */
- webkit_settings_set_enable_javascript(settings, FALSE); /* sane default 😏 */
- webkit_settings_set_enable_plugins(settings, FALSE); /* dangerous */
- webkit_settings_set_javascript_can_access_clipboard(settings, FALSE); /* dangerous */
- webkit_settings_set_javascript_can_open_windows_automatically(settings, FALSE); /* dangerous */
- webkit_settings_set_media_playback_requires_user_gesture(
- settings, TRUE); /* typically breaks notification sounds */
- webkit_settings_set_minimum_font_size(settings,
- 9); /* text needs to be readable; screw broken pages */
-
- webkit_web_view_set_settings(browser->webView, settings);
-
- if(target_url != NULL) webkit_web_view_load_uri(browser->webView, target_url);
+ if(related_web_view == NULL) webkit_web_view_load_uri(browser->webView, target_url);
return browser;
}
@@ -463,6 +464,17 @@ int main(int argc, char *argv[])
struct Window *window = g_malloc(sizeof(struct Client));
gchar *target_url = NULL;
+ g_fprintf(stderr,
+ "Buildtime WebKit version: %d.%d.%d\n",
+ WEBKIT_MAJOR_VERSION,
+ WEBKIT_MINOR_VERSION,
+ WEBKIT_MICRO_VERSION);
+ g_fprintf(stderr,
+ "Runtime WebKit version: %d.%d.%d\n",
+ webkit_get_major_version(),
+ webkit_get_minor_version(),
+ webkit_get_micro_version());
+
gtk_init(&argc, &argv);
if(argv[1]) target_url = argv[1];