From 90521e0a18122bd2d1ad46d3f8fcac75f6661604 Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Sat, 20 Jul 2024 18:49:29 -0400 Subject: [PATCH] GTK4: web_context => network_session --- config.h | 1 + rosenrot4.c | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/config.h b/config.h index 4671f87..48802c4 100644 --- a/config.h +++ b/config.h @@ -42,6 +42,7 @@ You could also look into commit afe93518a for an approach using stand-in code. "default-charset", "utf-8" #define DATA_DIR "/home/nuno/.cache/rosenrot" #define DATA_MANAGER_OPTS "base-cache-directory", DATA_DIR, "base-data-directory", DATA_DIR +#define NETWORK_SESSION_OPTS DATA_DIR, DATA_DIR // GTK #define GTK_SETTINGS_CONFIG_H "gtk-application-prefer-dark-theme", false, "gtk-enable-animations", false diff --git a/rosenrot4.c b/rosenrot4.c index 9377b0e..cdae4cc 100644 --- a/rosenrot4.c +++ b/rosenrot4.c @@ -138,8 +138,9 @@ WebKitWebView* create_new_webview() { char* style; WebKitSettings* settings; - WebKitWebContext* web_context; + // WebKitWebContext* web_context; WebKitCookieManager* cookiemanager; + WebKitNetworkSession* network_session; // new WebKitUserContentManager* contentmanager; settings = webkit_settings_new_with_settings(WEBKIT_DEFAULT_SETTINGS, NULL); @@ -150,9 +151,10 @@ WebKitWebView* create_new_webview() "like Gecko) Chrome/120.0.0.0 Safari/537.3"); // https://www.useragents.me } - web_context = webkit_web_context_new_with_website_data_manager(webkit_website_data_manager_new(DATA_MANAGER_OPTS, NULL)); + network_session = webkit_network_session_new(DATA_DIR, DATA_DIR); + // web_context = webkit_web_context_new_with_website_data_manager(webkit_website_data_manager_new(DATA_MANAGER_OPTS, NULL)); contentmanager = webkit_user_content_manager_new(); - cookiemanager = webkit_web_context_get_cookie_manager(web_context); + cookiemanager = webkit_network_session_get_cookie_manager(network_session); webkit_cookie_manager_set_persistent_storage(cookiemanager, DATA_DIR "/cookies.sqlite", WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE); @@ -163,7 +165,7 @@ WebKitWebView* create_new_webview() contentmanager, webkit_user_style_sheet_new(style, WEBKIT_USER_CONTENT_INJECT_ALL_FRAMES, WEBKIT_USER_STYLE_LEVEL_USER, NULL, NULL)); } - return g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "web-context", web_context, "user-content-manager", contentmanager, NULL); + return g_object_new(WEBKIT_TYPE_WEB_VIEW, "settings", settings, "network-session", network_session, "user-content-manager", contentmanager, NULL); } void notebook_create_new_tab(GtkNotebook* notebook, const char* uri) {