GTKWebkitWebView change WebDataDir and WebCacheDir #1471
-
|
Hi, I am just using a normal WebView trying to change the folders where it stores its content (because I will use multiple webviews in my project). The documentation (https://webkitgtk.org/reference/webkitgtk/stable/migrating-to-webkitgtk-6.0.html#network-session-api) here says the following: "[...] WebKitNetworkSession to be used must be passed to the WebKitWebView as a construct parameter." So thats what I am trying, but I dont know how to do this right. I managed to create a new NetworkSession with the pathes which is simple, but is it even possible to pass it using the Heres my code: using GObject;
using WebKit;
internal class Program
{
private static void Main(string[] args)
{
WebKit.Module.Initialize();
var _app = Adw.Application.New("Test.App", Gio.ApplicationFlags.FlagsNone);
_app.OnActivate += (sender, args) =>
{
var _window = Gtk.ApplicationWindow.New(_app);
_window.Title = $"Test";
_window.SetDefaultSize(800, 600);
var webView = CreateWebView("/home/andy/test/data", "/home/andy/test/cache"); // new WebView();
webView.LoadUri("https://www.google.de");
_window.SetChild(webView);
_window.Show();
};
_app.OnShutdown += (sender, args) => { };
_app.Run([]);
WebView CreateWebView(string webDataDir, string webCacheDir)
{
try
{
// "[...] WebKitNetworkSession to be used must be passed to the WebKitWebView as a construct parameter." (https://webkitgtk.org/reference/webkitgtk/stable/migrating-to-webkitgtk-6.0.html#network-session-api)
var networkSession = NetworkSession.New(webDataDir, webCacheDir);
// Problem: The specified structure must be blittable or have layout information. (Parameter 'structure'):
return new WebView(new ConstructArgument("network-session", new Value(networkSession)));
}
catch (Exception ex)
{
return null;
}
}
}
}So here I get the exception that the specified structure must be blittable or have layout information. May I only pass primitive types here? But the property is a |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Thanks for reporting and providing a minimal sample. It looks like you are doing the right thing. I will look at this for the upcoming next release of the 0.8.0 series. I created an issue (#1472) from this discussion. We can continue over there. |
Beta Was this translation helpful? Give feedback.
Thanks for reporting and providing a minimal sample. It looks like you are doing the right thing. I will look at this for the upcoming next release of the 0.8.0 series.
I created an issue (#1472) from this discussion. We can continue over there.