Skip to main content

Embedding web pages

taunus-browser is a library too: any app can show a web page in a Slint element. The engine (WebKitGTK) runs in its own process, taunus-webview, as the only client of a small Wayland compositor inside your app; its picture becomes a Slint image and input goes back to it. The engine's storage is encrypted with a key from taunus-keyd that only the engine binary can get.

Build​

// build.rs
fn main() {
taunus_theme::build::compile_with("ui/app.slint", &[("browser", taunus_browser::SLINT_DIR)]).unwrap();
}
# Cargo.toml
taunus-browser = { path = "../browser" } # also under [build-dependencies]

Slint​

import { WebView, WebPage } from "@browser/webview.slint";
export { WebPage }

// anywhere, any size; one WebView per window
WebView { width: 100%; height: 100%; }

WebPage is the page's state and controls:

Property (from Rust)
url, titlewhere the page is
loading, progressload state, 0–1
can-back, can-forwardhistory
editinga text field on the page has focus (the on-screen keyboard comes up)
errorthe engine could not start, or a load failed
Callback
load(text)an address, or search words (DuckDuckGo)
back(), forward(), reload(), stop()

Rust​

let web = taunus_browser::WebView::new("https://example.org")?; // or new_private(url): no cookies kept
taunus_browser::bind!(ui, web); // wires WebPage to the view
web.on_event(|e| { /* title, url, load events */ });

new_private starts logged out and forgets everything when it goes: for signing in to something on behalf of your app (Settings uses it for Google sign-in).

On TV, the D-pad moves an arrow over the page; this is built into WebView.

//2bi: an app that embeds a web page gets its own encrypted storage key instead of sharing the browser's, by declaring it in its manifest.