pub trait WebViewExt:
IsA<WebView>
+ Sealed
+ 'static {
Show 129 methods
// Provided methods
fn call_async_javascript_function<P: FnOnce(Result<Value, Error>) + 'static>(
&self,
body: &str,
arguments: Option<&Variant>,
world_name: Option<&str>,
source_uri: Option<&str>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn call_async_javascript_function_future(
&self,
body: &str,
arguments: Option<&Variant>,
world_name: Option<&str>,
source_uri: Option<&str>,
) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>> { ... }
fn can_execute_editing_command<P: FnOnce(Result<(), Error>) + 'static>(
&self,
command: &str,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn can_execute_editing_command_future(
&self,
command: &str,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn can_go_back(&self) -> bool { ... }
fn can_go_forward(&self) -> bool { ... }
fn can_show_mime_type(&self, mime_type: &str) -> bool { ... }
fn download_uri(&self, uri: &str) -> Option<Download> { ... }
fn evaluate_javascript<P: FnOnce(Result<Value, Error>) + 'static>(
&self,
script: &str,
world_name: Option<&str>,
source_uri: Option<&str>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn evaluate_javascript_future(
&self,
script: &str,
world_name: Option<&str>,
source_uri: Option<&str>,
) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>> { ... }
fn execute_editing_command(&self, command: &str) { ... }
fn execute_editing_command_with_argument(
&self,
command: &str,
argument: &str,
) { ... }
fn automation_presentation_type(
&self,
) -> AutomationBrowsingContextPresentation { ... }
fn back_forward_list(&self) -> Option<BackForwardList> { ... }
fn background_color(&self) -> RGBA { ... }
fn camera_capture_state(&self) -> MediaCaptureState { ... }
fn context(&self) -> Option<WebContext> { ... }
fn custom_charset(&self) -> Option<GString> { ... }
fn default_content_security_policy(&self) -> Option<GString> { ... }
fn display_capture_state(&self) -> MediaCaptureState { ... }
fn editor_state(&self) -> Option<EditorState> { ... }
fn estimated_load_progress(&self) -> f64 { ... }
fn favicon(&self) -> Option<Surface> { ... }
fn find_controller(&self) -> Option<FindController> { ... }
fn input_method_context(&self) -> Option<InputMethodContext> { ... }
fn inspector(&self) -> Option<WebInspector> { ... }
fn is_muted(&self) -> bool { ... }
fn is_web_process_responsive(&self) -> bool { ... }
fn main_resource(&self) -> Option<WebResource> { ... }
fn microphone_capture_state(&self) -> MediaCaptureState { ... }
fn page_id(&self) -> u64 { ... }
fn session_state(&self) -> Option<WebViewSessionState> { ... }
fn settings(&self) -> Option<Settings> { ... }
fn snapshot<P: FnOnce(Result<Surface, Error>) + 'static>(
&self,
region: SnapshotRegion,
options: SnapshotOptions,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn snapshot_future(
&self,
region: SnapshotRegion,
options: SnapshotOptions,
) -> Pin<Box_<dyn Future<Output = Result<Surface, Error>> + 'static>> { ... }
fn title(&self) -> Option<GString> { ... }
fn tls_info(&self) -> Option<(TlsCertificate, TlsCertificateFlags)> { ... }
fn uri(&self) -> Option<GString> { ... }
fn user_content_manager(&self) -> Option<UserContentManager> { ... }
fn website_data_manager(&self) -> Option<WebsiteDataManager> { ... }
fn website_policies(&self) -> Option<WebsitePolicies> { ... }
fn window_properties(&self) -> Option<WindowProperties> { ... }
fn zoom_level(&self) -> f64 { ... }
fn go_back(&self) { ... }
fn go_forward(&self) { ... }
fn go_to_back_forward_list_item(
&self,
list_item: &impl IsA<BackForwardListItem>,
) { ... }
fn is_controlled_by_automation(&self) -> bool { ... }
fn is_editable(&self) -> bool { ... }
fn is_ephemeral(&self) -> bool { ... }
fn is_loading(&self) -> bool { ... }
fn is_playing_audio(&self) -> bool { ... }
fn load_alternate_html(
&self,
content: &str,
content_uri: &str,
base_uri: Option<&str>,
) { ... }
fn load_bytes(
&self,
bytes: &Bytes,
mime_type: Option<&str>,
encoding: Option<&str>,
base_uri: Option<&str>,
) { ... }
fn load_html(&self, content: &str, base_uri: Option<&str>) { ... }
fn load_plain_text(&self, plain_text: &str) { ... }
fn load_request(&self, request: &impl IsA<URIRequest>) { ... }
fn load_uri(&self, uri: &str) { ... }
fn reload(&self) { ... }
fn reload_bypass_cache(&self) { ... }
fn restore_session_state(&self, state: &WebViewSessionState) { ... }
fn run_javascript<P: FnOnce(Result<JavascriptResult, Error>) + 'static>(
&self,
script: &str,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn run_javascript_future(
&self,
script: &str,
) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>> { ... }
fn run_javascript_from_gresource<P: FnOnce(Result<JavascriptResult, Error>) + 'static>(
&self,
resource: &str,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn run_javascript_from_gresource_future(
&self,
resource: &str,
) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>> { ... }
fn run_javascript_in_world<P: FnOnce(Result<JavascriptResult, Error>) + 'static>(
&self,
script: &str,
world_name: &str,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn run_javascript_in_world_future(
&self,
script: &str,
world_name: &str,
) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>> { ... }
fn save<P: FnOnce(Result<InputStream, Error>) + 'static>(
&self,
save_mode: SaveMode,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn save_future(
&self,
save_mode: SaveMode,
) -> Pin<Box_<dyn Future<Output = Result<InputStream, Error>> + 'static>> { ... }
fn save_to_file<P: FnOnce(Result<(), Error>) + 'static>(
&self,
file: &impl IsA<File>,
save_mode: SaveMode,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn save_to_file_future(
&self,
file: &(impl IsA<File> + Clone + 'static),
save_mode: SaveMode,
) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>> { ... }
fn send_message_to_page<P: FnOnce(Result<UserMessage, Error>) + 'static>(
&self,
message: &impl IsA<UserMessage>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn send_message_to_page_future(
&self,
message: &(impl IsA<UserMessage> + Clone + 'static),
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>> { ... }
fn set_background_color(&self, rgba: &RGBA) { ... }
fn set_camera_capture_state(&self, state: MediaCaptureState) { ... }
fn set_cors_allowlist(&self, allowlist: &[&str]) { ... }
fn set_custom_charset(&self, charset: Option<&str>) { ... }
fn set_display_capture_state(&self, state: MediaCaptureState) { ... }
fn set_editable(&self, editable: bool) { ... }
fn set_input_method_context(
&self,
context: Option<&impl IsA<InputMethodContext>>,
) { ... }
fn set_is_muted(&self, muted: bool) { ... }
fn set_microphone_capture_state(&self, state: MediaCaptureState) { ... }
fn set_settings(&self, settings: &impl IsA<Settings>) { ... }
fn set_zoom_level(&self, zoom_level: f64) { ... }
fn stop_loading(&self) { ... }
fn terminate_web_process(&self) { ... }
fn try_close(&self) { ... }
fn web_context(&self) -> Option<WebContext> { ... }
fn connect_authenticate<F: Fn(&Self, &AuthenticationRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... }
fn connect_context_menu<F: Fn(&Self, &ContextMenu, &Event, &HitTestResult) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_context_menu_dismissed<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_create<F: Fn(&Self, &NavigationAction) -> Option<Widget> + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_decide_policy<F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &Error) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_load_failed_with_tls_errors<F: Fn(&Self, &str, &TlsCertificate, TlsCertificateFlags) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_ready_to_show<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_run_as_modal<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_run_color_chooser<F: Fn(&Self, &ColorChooserRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_script_dialog<F: Fn(&Self, &ScriptDialog) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_show_notification<F: Fn(&Self, &Notification) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_show_option_menu<F: Fn(&Self, &OptionMenu, &Event, &Rectangle) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_web_process_crashed<F: Fn(&Self) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_display_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_editable_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_estimated_load_progress_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_favicon_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_is_loading_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_is_muted_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_page_id_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_settings_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_title_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_uri_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
fn connect_zoom_level_notify<F: Fn(&Self) + 'static>(
&self,
f: F,
) -> SignalHandlerId { ... }
}
Provided Methodsยง
fn call_async_javascript_function<P: FnOnce(Result<Value, Error>) + 'static>( &self, body: &str, arguments: Option<&Variant>, world_name: Option<&str>, source_uri: Option<&str>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Available on crate feature
v2_40
only.fn call_async_javascript_function_future( &self, body: &str, arguments: Option<&Variant>, world_name: Option<&str>, source_uri: Option<&str>, ) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>>
Available on crate feature
v2_40
only.fn can_execute_editing_command<P: FnOnce(Result<(), Error>) + 'static>( &self, command: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
fn can_execute_editing_command_future( &self, command: &str, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn can_go_back(&self) -> bool
fn can_go_forward(&self) -> bool
fn can_show_mime_type(&self, mime_type: &str) -> bool
fn download_uri(&self, uri: &str) -> Option<Download>
fn evaluate_javascript<P: FnOnce(Result<Value, Error>) + 'static>( &self, script: &str, world_name: Option<&str>, source_uri: Option<&str>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Available on crate feature
v2_40
only.fn evaluate_javascript_future( &self, script: &str, world_name: Option<&str>, source_uri: Option<&str>, ) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>>
Available on crate feature
v2_40
only.fn execute_editing_command(&self, command: &str)
fn execute_editing_command_with_argument(&self, command: &str, argument: &str)
Available on crate feature
v2_10
only.fn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation
Available on crate feature
v2_28
only.fn back_forward_list(&self) -> Option<BackForwardList>
fn background_color(&self) -> RGBA
Available on crate feature
v2_8
only.fn camera_capture_state(&self) -> MediaCaptureState
Available on crate feature
v2_34
only.fn context(&self) -> Option<WebContext>
fn custom_charset(&self) -> Option<GString>
fn default_content_security_policy(&self) -> Option<GString>
Available on crate feature
v2_38
only.fn display_capture_state(&self) -> MediaCaptureState
Available on crate feature
v2_34
only.fn editor_state(&self) -> Option<EditorState>
Available on crate feature
v2_10
only.fn estimated_load_progress(&self) -> f64
fn favicon(&self) -> Option<Surface>
fn find_controller(&self) -> Option<FindController>
fn input_method_context(&self) -> Option<InputMethodContext>
Available on crate feature
v2_28
only.fn inspector(&self) -> Option<WebInspector>
fn is_muted(&self) -> bool
Available on crate feature
v2_30
only.fn is_web_process_responsive(&self) -> bool
Available on crate feature
v2_34
only.fn main_resource(&self) -> Option<WebResource>
fn microphone_capture_state(&self) -> MediaCaptureState
Available on crate feature
v2_34
only.fn page_id(&self) -> u64
fn session_state(&self) -> Option<WebViewSessionState>
Available on crate feature
v2_12
only.Sourcefn settings(&self) -> Option<Settings>
fn settings(&self) -> Option<Settings>
Examples found in repository?
examples/main.rs (line 50)
34fn main() {
35 gtk::init().unwrap();
36
37 let window = Window::new(WindowType::Toplevel);
38 let context = WebContext::default().unwrap();
39 #[cfg(feature = "v2_4")]
40 context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
41 context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
42 #[cfg(feature = "v2_6")]
43 let webview =
44 WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
45 #[cfg(not(feature = "v2_6"))]
46 let webview = WebView::with_context(&context);
47 webview.load_uri("https://crates.io/");
48 window.add(&webview);
49
50 let settings = WebViewExt::settings(&webview).unwrap();
51 settings.set_enable_developer_extras(true);
52
53 /*let inspector = webview.get_inspector().unwrap();
54 inspector.show();*/
55
56 window.show_all();
57
58 webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {});
59 #[cfg(feature = "v2_22")]
60 webview.run_javascript("42", None::<&gio::Cancellable>, |result| match result {
61 Ok(result) => {
62 use java_script_core::ValueExt;
63 let value = result.js_value().unwrap();
64 println!("is_boolean: {}", value.is_boolean());
65 println!("is_number: {}", value.is_number());
66 println!("{:?}", value.to_int32());
67 println!("{:?}", value.to_boolean());
68 }
69 Err(error) => println!("{}", error),
70 });
71
72 window.connect_delete_event(|_, _| {
73 gtk::main_quit();
74 glib::Propagation::Proceed
75 });
76
77 gtk::main();
78}
fn snapshot<P: FnOnce(Result<Surface, Error>) + 'static>( &self, region: SnapshotRegion, options: SnapshotOptions, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
fn snapshot_future( &self, region: SnapshotRegion, options: SnapshotOptions, ) -> Pin<Box_<dyn Future<Output = Result<Surface, Error>> + 'static>>
fn title(&self) -> Option<GString>
fn tls_info(&self) -> Option<(TlsCertificate, TlsCertificateFlags)>
fn uri(&self) -> Option<GString>
fn user_content_manager(&self) -> Option<UserContentManager>
Available on crate feature
v2_6
only.fn website_data_manager(&self) -> Option<WebsiteDataManager>
Available on crate feature
v2_16
only.fn website_policies(&self) -> Option<WebsitePolicies>
Available on crate feature
v2_30
only.fn window_properties(&self) -> Option<WindowProperties>
fn zoom_level(&self) -> f64
fn go_back(&self)
fn go_forward(&self)
fn go_to_back_forward_list_item( &self, list_item: &impl IsA<BackForwardListItem>, )
fn is_controlled_by_automation(&self) -> bool
Available on crate feature
v2_18
only.fn is_editable(&self) -> bool
Available on crate feature
v2_8
only.fn is_ephemeral(&self) -> bool
Available on crate feature
v2_16
only.fn is_loading(&self) -> bool
fn is_playing_audio(&self) -> bool
Available on crate feature
v2_8
only.fn load_alternate_html( &self, content: &str, content_uri: &str, base_uri: Option<&str>, )
fn load_bytes( &self, bytes: &Bytes, mime_type: Option<&str>, encoding: Option<&str>, base_uri: Option<&str>, )
Available on crate feature
v2_6
only.fn load_html(&self, content: &str, base_uri: Option<&str>)
fn load_plain_text(&self, plain_text: &str)
fn load_request(&self, request: &impl IsA<URIRequest>)
Sourcefn load_uri(&self, uri: &str)
fn load_uri(&self, uri: &str)
Examples found in repository?
examples/main.rs (line 47)
34fn main() {
35 gtk::init().unwrap();
36
37 let window = Window::new(WindowType::Toplevel);
38 let context = WebContext::default().unwrap();
39 #[cfg(feature = "v2_4")]
40 context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
41 context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
42 #[cfg(feature = "v2_6")]
43 let webview =
44 WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
45 #[cfg(not(feature = "v2_6"))]
46 let webview = WebView::with_context(&context);
47 webview.load_uri("https://crates.io/");
48 window.add(&webview);
49
50 let settings = WebViewExt::settings(&webview).unwrap();
51 settings.set_enable_developer_extras(true);
52
53 /*let inspector = webview.get_inspector().unwrap();
54 inspector.show();*/
55
56 window.show_all();
57
58 webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {});
59 #[cfg(feature = "v2_22")]
60 webview.run_javascript("42", None::<&gio::Cancellable>, |result| match result {
61 Ok(result) => {
62 use java_script_core::ValueExt;
63 let value = result.js_value().unwrap();
64 println!("is_boolean: {}", value.is_boolean());
65 println!("is_number: {}", value.is_number());
66 println!("{:?}", value.to_int32());
67 println!("{:?}", value.to_boolean());
68 }
69 Err(error) => println!("{}", error),
70 });
71
72 window.connect_delete_event(|_, _| {
73 gtk::main_quit();
74 glib::Propagation::Proceed
75 });
76
77 gtk::main();
78}
fn reload(&self)
fn reload_bypass_cache(&self)
fn restore_session_state(&self, state: &WebViewSessionState)
Available on crate feature
v2_12
only.Sourcefn run_javascript<P: FnOnce(Result<JavascriptResult, Error>) + 'static>(
&self,
script: &str,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
๐Deprecated: Since 2.40
fn run_javascript<P: FnOnce(Result<JavascriptResult, Error>) + 'static>( &self, script: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Examples found in repository?
examples/main.rs (line 58)
34fn main() {
35 gtk::init().unwrap();
36
37 let window = Window::new(WindowType::Toplevel);
38 let context = WebContext::default().unwrap();
39 #[cfg(feature = "v2_4")]
40 context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
41 context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
42 #[cfg(feature = "v2_6")]
43 let webview =
44 WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
45 #[cfg(not(feature = "v2_6"))]
46 let webview = WebView::with_context(&context);
47 webview.load_uri("https://crates.io/");
48 window.add(&webview);
49
50 let settings = WebViewExt::settings(&webview).unwrap();
51 settings.set_enable_developer_extras(true);
52
53 /*let inspector = webview.get_inspector().unwrap();
54 inspector.show();*/
55
56 window.show_all();
57
58 webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {});
59 #[cfg(feature = "v2_22")]
60 webview.run_javascript("42", None::<&gio::Cancellable>, |result| match result {
61 Ok(result) => {
62 use java_script_core::ValueExt;
63 let value = result.js_value().unwrap();
64 println!("is_boolean: {}", value.is_boolean());
65 println!("is_number: {}", value.is_number());
66 println!("{:?}", value.to_int32());
67 println!("{:?}", value.to_boolean());
68 }
69 Err(error) => println!("{}", error),
70 });
71
72 window.connect_delete_event(|_, _| {
73 gtk::main_quit();
74 glib::Propagation::Proceed
75 });
76
77 gtk::main();
78}
fn run_javascript_future( &self, script: &str, ) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
๐Deprecated: Since 2.40
fn run_javascript_from_gresource<P: FnOnce(Result<JavascriptResult, Error>) + 'static>( &self, resource: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
๐Deprecated: Since 2.40
fn run_javascript_from_gresource_future( &self, resource: &str, ) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
๐Deprecated: Since 2.40
fn run_javascript_in_world<P: FnOnce(Result<JavascriptResult, Error>) + 'static>( &self, script: &str, world_name: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
๐Deprecated: Since 2.40
Available on crate feature
v2_22
only.fn run_javascript_in_world_future( &self, script: &str, world_name: &str, ) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
๐Deprecated: Since 2.40
Available on crate feature
v2_22
only.fn save<P: FnOnce(Result<InputStream, Error>) + 'static>( &self, save_mode: SaveMode, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
fn save_future( &self, save_mode: SaveMode, ) -> Pin<Box_<dyn Future<Output = Result<InputStream, Error>> + 'static>>
fn save_to_file<P: FnOnce(Result<(), Error>) + 'static>( &self, file: &impl IsA<File>, save_mode: SaveMode, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
fn save_to_file_future( &self, file: &(impl IsA<File> + Clone + 'static), save_mode: SaveMode, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
fn send_message_to_page<P: FnOnce(Result<UserMessage, Error>) + 'static>( &self, message: &impl IsA<UserMessage>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Available on crate feature
v2_28
only.fn send_message_to_page_future( &self, message: &(impl IsA<UserMessage> + Clone + 'static), ) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
Available on crate feature
v2_28
only.fn set_background_color(&self, rgba: &RGBA)
Available on crate feature
v2_8
only.fn set_camera_capture_state(&self, state: MediaCaptureState)
Available on crate feature
v2_34
only.fn set_cors_allowlist(&self, allowlist: &[&str])
Available on crate feature
v2_34
only.fn set_custom_charset(&self, charset: Option<&str>)
fn set_display_capture_state(&self, state: MediaCaptureState)
Available on crate feature
v2_34
only.fn set_editable(&self, editable: bool)
Available on crate feature
v2_8
only.fn set_input_method_context( &self, context: Option<&impl IsA<InputMethodContext>>, )
Available on crate feature
v2_28
only.fn set_is_muted(&self, muted: bool)
Available on crate feature
v2_30
only.fn set_microphone_capture_state(&self, state: MediaCaptureState)
Available on crate feature
v2_34
only.fn set_settings(&self, settings: &impl IsA<Settings>)
fn set_zoom_level(&self, zoom_level: f64)
fn stop_loading(&self)
fn terminate_web_process(&self)
Available on crate feature
v2_34
only.fn try_close(&self)
Available on crate feature
v2_12
only.fn web_context(&self) -> Option<WebContext>
fn connect_authenticate<F: Fn(&Self, &AuthenticationRequest) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_2
only.fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_create<F: Fn(&Self, &NavigationAction) -> Option<Widget> + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_6
only.fn connect_decide_policy<F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &Error) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_load_failed_with_tls_errors<F: Fn(&Self, &str, &TlsCertificate, TlsCertificateFlags) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_6
only.fn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_ready_to_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_run_as_modal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_run_color_chooser<F: Fn(&Self, &ColorChooserRequest) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_8
only.fn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_script_dialog<F: Fn(&Self, &ScriptDialog) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_24
only.fn connect_show_notification<F: Fn(&Self, &Notification) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_8
only.Available on crate feature
v2_18
only.fn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_28
only.fn connect_web_process_crashed<F: Fn(&Self) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
๐Deprecated: Since 2.20
fn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_20
only.fn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_34
only.fn connect_display_capture_state_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_34
only.fn connect_editable_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_8
only.fn connect_estimated_load_progress_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_favicon_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_is_loading_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
fn connect_is_muted_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_30
only.fn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_8
only.fn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_34
only.fn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_34
only.fn connect_page_id_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_28
only.fn connect_settings_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Available on crate feature
v2_6
only.fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_zoom_level_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Dyn Compatibilityยง
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.