#How to get access to the native WebView's platform-specific configuration?

9 messages · Page 1 of 1 (latest)

fringe atlas
#

Is there a way to get and set webviewgtk2's platform-specific WebKitWebView and its WebKitSettings object (and the equivalents on other platforms)?

uneven harbor
#

though for some settings this is "too late" in which case tauri/wry have to be modified to support that setting

fringe atlas
#

Thanks! I got that far, and then couldn't get access to the settings.set_enable_emit_console_to_stdout().

Is there some trait or other interface I need to load access?

.setup(|app| {
    if let Some(window) = app.get_window("main") {
        window.with_webview(|webview| {
          #[cfg(target_os = "linux")]
          {
            // see https://docs.rs/webkit2gtk/0.18.2/webkit2gtk/struct.WebView.html
            // and https://docs.rs/webkit2gtk/0.18.2/webkit2gtk/trait.WebViewExt.html
            use webkit2gtk::traits::WebViewExt;
            if let Some(settings) = webview.inner().settings() {
                settings.xxx
            }
          }
        }).expect("with_webview() failed");
uneven harbor
#

Did your ide not suggest to add use webkit2gtk::SettingsExt; ?

#

after that the method should be available

#

ah hmm, looks like it's not available in the webkitgtk bindings tauri v1 uses

#

but in v2 it's there

fringe atlas
#

I just tried again and... it works!!! I can only assume that rebooting VSCode a few times in the meanwhile, for unrelated reasons, shook something loose.

Weirdly, it takes place before the format strings are applied, so console.log('vm: %o', vm); throw { hi: "there" } does not look like it does in the dev tools console, but this is lots faster than having to open the in-browser debugging tools when it goes splat, and it's correctly interleaved with println!(...) output.

tauri://localhost/main.js:169:14: CONSOLE LOG vm: %o [object Object]
tauri://localhost/main.js:170:24: CONSOLE JS ERROR [object Object]