You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In glade, I added a WebKitWebView, then I want to get this object in my code:
let builder = gtk::Builder::new_from_resource("/im/idlesong/handybox/window.ui");
let widget: gtk::ApplicationWindow = builder.get_object("window").expect("Failed to find the window object");
let webview: WebView = builder.get_object("webview").expect("Failed to find label");
It builded success, but when run:
failed to add UI: .:136:1 Invalid object type 'WebKitWebView'
Heyo! I'm using Glade on my GTK-rs web browser, and I've got this working.
Firstly, the get_object() function gets an object by its ID/unique instance name. Have you given your WebView widget a name in Glade?
Additionally, if that doesn't work for whatever reason (though, it should), you can create your own WebView instance in Rust, like this:
let web_view_builder = webkit2gtk::WebViewBuilder::new().is_ephemeral(false).automation_presentation_type(webkit2gtk::AutomationBrowsingContextPresentation::Tab);let web_view = web_view_builder.build();
The webkit2gtk-rs and gtk3-rs documentation books are really useful, so take a look at those on the regular.
In glade, I added a WebKitWebView, then I want to get this object in my code:
It builded success, but when run:
I searched the web, it seems there are only two related answers,
https://stackoverflow.com/questions/51010820/glade-invalid-object-type-webkitwebview-when-loading-from-file-works-on-gla
https://prognotes.net/2019/12/make-a-gtk-web-browser-with-glade/
But one is C, one is Vala. It's too hard to convert to rust for me. Is there any samples or documents about it? Thanks.
The text was updated successfully, but these errors were encountered: