Trait webkit2gtk::WebViewExt
source · 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§
sourcefn 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<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.sourcefn 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 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>
sourcefn 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<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.sourcefn evaluate_javascript_future(
&self,
script: &str,
world_name: Option<&str>,
source_uri: Option<&str>
) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>>
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)
sourcefn execute_editing_command_with_argument(&self, command: &str, argument: &str)
fn execute_editing_command_with_argument(&self, command: &str, argument: &str)
Available on crate feature
v2_10
only.sourcefn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation
fn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation
Available on crate feature
v2_28
only.fn back_forward_list(&self) -> Option<BackForwardList>
sourcefn background_color(&self) -> RGBA
fn background_color(&self) -> RGBA
Available on crate feature
v2_8
only.sourcefn camera_capture_state(&self) -> MediaCaptureState
fn camera_capture_state(&self) -> MediaCaptureState
Available on crate feature
v2_34
only.fn context(&self) -> Option<WebContext>
fn custom_charset(&self) -> Option<GString>
sourcefn default_content_security_policy(&self) -> Option<GString>
fn default_content_security_policy(&self) -> Option<GString>
Available on crate feature
v2_38
only.sourcefn display_capture_state(&self) -> MediaCaptureState
fn display_capture_state(&self) -> MediaCaptureState
Available on crate feature
v2_34
only.sourcefn editor_state(&self) -> Option<EditorState>
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>
sourcefn input_method_context(&self) -> Option<InputMethodContext>
fn input_method_context(&self) -> Option<InputMethodContext>
Available on crate feature
v2_28
only.fn inspector(&self) -> Option<WebInspector>
sourcefn is_web_process_responsive(&self) -> bool
fn is_web_process_responsive(&self) -> bool
Available on crate feature
v2_34
only.fn main_resource(&self) -> Option<WebResource>
sourcefn microphone_capture_state(&self) -> MediaCaptureState
fn microphone_capture_state(&self) -> MediaCaptureState
Available on crate feature
v2_34
only.fn page_id(&self) -> u64
sourcefn session_state(&self) -> Option<WebViewSessionState>
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)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
fn main() {
gtk::init().unwrap();
let window = Window::new(WindowType::Toplevel);
let context = WebContext::default().unwrap();
#[cfg(feature = "v2_4")]
context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
#[cfg(feature = "v2_6")]
let webview =
WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
#[cfg(not(feature = "v2_6"))]
let webview = WebView::with_context(&context);
webview.load_uri("https://crates.io/");
window.add(&webview);
let settings = WebViewExt::settings(&webview).unwrap();
settings.set_enable_developer_extras(true);
/*let inspector = webview.get_inspector().unwrap();
inspector.show();*/
window.show_all();
webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {});
#[cfg(feature = "v2_22")]
webview.run_javascript("42", None::<&gio::Cancellable>, |result| match result {
Ok(result) => {
use java_script_core::ValueExt;
let value = result.js_value().unwrap();
println!("is_boolean: {}", value.is_boolean());
println!("is_number: {}", value.is_number());
println!("{:?}", value.to_int32());
println!("{:?}", value.to_boolean());
}
Err(error) => println!("{}", error),
});
window.connect_delete_event(|_, _| {
gtk::main_quit();
glib::Propagation::Proceed
});
gtk::main();
}
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>
sourcefn user_content_manager(&self) -> Option<UserContentManager>
fn user_content_manager(&self) -> Option<UserContentManager>
Available on crate feature
v2_6
only.sourcefn website_data_manager(&self) -> Option<WebsiteDataManager>
fn website_data_manager(&self) -> Option<WebsiteDataManager>
Available on crate feature
v2_16
only.sourcefn website_policies(&self) -> Option<WebsitePolicies>
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> )
sourcefn is_controlled_by_automation(&self) -> bool
fn is_controlled_by_automation(&self) -> bool
Available on crate feature
v2_18
only.sourcefn is_editable(&self) -> bool
fn is_editable(&self) -> bool
Available on crate feature
v2_8
only.sourcefn is_ephemeral(&self) -> bool
fn is_ephemeral(&self) -> bool
Available on crate feature
v2_16
only.fn is_loading(&self) -> bool
sourcefn is_playing_audio(&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> )
sourcefn load_bytes(
&self,
bytes: &Bytes,
mime_type: Option<&str>,
encoding: Option<&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)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
fn main() {
gtk::init().unwrap();
let window = Window::new(WindowType::Toplevel);
let context = WebContext::default().unwrap();
#[cfg(feature = "v2_4")]
context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
#[cfg(feature = "v2_6")]
let webview =
WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
#[cfg(not(feature = "v2_6"))]
let webview = WebView::with_context(&context);
webview.load_uri("https://crates.io/");
window.add(&webview);
let settings = WebViewExt::settings(&webview).unwrap();
settings.set_enable_developer_extras(true);
/*let inspector = webview.get_inspector().unwrap();
inspector.show();*/
window.show_all();
webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {});
#[cfg(feature = "v2_22")]
webview.run_javascript("42", None::<&gio::Cancellable>, |result| match result {
Ok(result) => {
use java_script_core::ValueExt;
let value = result.js_value().unwrap();
println!("is_boolean: {}", value.is_boolean());
println!("is_number: {}", value.is_number());
println!("{:?}", value.to_int32());
println!("{:?}", value.to_boolean());
}
Err(error) => println!("{}", error),
});
window.connect_delete_event(|_, _| {
gtk::main_quit();
glib::Propagation::Proceed
});
gtk::main();
}
fn reload(&self)
fn reload_bypass_cache(&self)
sourcefn restore_session_state(&self, state: &WebViewSessionState)
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
)
fn run_javascript<P: FnOnce(Result<JavascriptResult, Error>) + 'static>( &self, script: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
👎Deprecated: Since 2.40
Examples found in repository?
examples/main.rs (line 58)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
fn main() {
gtk::init().unwrap();
let window = Window::new(WindowType::Toplevel);
let context = WebContext::default().unwrap();
#[cfg(feature = "v2_4")]
context.set_web_extensions_initialization_user_data(&"webkit".to_variant());
context.set_web_extensions_directory("../webkit2gtk-webextension-rs/example/target/debug/");
#[cfg(feature = "v2_6")]
let webview =
WebView::new_with_context_and_user_content_manager(&context, &UserContentManager::new());
#[cfg(not(feature = "v2_6"))]
let webview = WebView::with_context(&context);
webview.load_uri("https://crates.io/");
window.add(&webview);
let settings = WebViewExt::settings(&webview).unwrap();
settings.set_enable_developer_extras(true);
/*let inspector = webview.get_inspector().unwrap();
inspector.show();*/
window.show_all();
webview.run_javascript("alert('Hello');", None::<&gio::Cancellable>, |_result| {});
#[cfg(feature = "v2_22")]
webview.run_javascript("42", None::<&gio::Cancellable>, |result| match result {
Ok(result) => {
use java_script_core::ValueExt;
let value = result.js_value().unwrap();
println!("is_boolean: {}", value.is_boolean());
println!("is_number: {}", value.is_number());
println!("{:?}", value.to_int32());
println!("{:?}", value.to_boolean());
}
Err(error) => println!("{}", error),
});
window.connect_delete_event(|_, _| {
gtk::main_quit();
glib::Propagation::Proceed
});
gtk::main();
}
sourcefn run_javascript_future(
&self,
script: &str
) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
fn run_javascript_future( &self, script: &str ) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
👎Deprecated: Since 2.40
sourcefn 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<P: FnOnce(Result<JavascriptResult, Error>) + 'static>( &self, resource: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P )
👎Deprecated: Since 2.40
sourcefn run_javascript_from_gresource_future(
&self,
resource: &str
) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
fn run_javascript_from_gresource_future( &self, resource: &str ) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
👎Deprecated: Since 2.40
sourcefn 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<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.sourcefn run_javascript_in_world_future(
&self,
script: &str,
world_name: &str
) -> Pin<Box_<dyn Future<Output = Result<JavascriptResult, Error>> + 'static>>
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>>
sourcefn 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<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.sourcefn send_message_to_page_future(
&self,
message: &(impl IsA<UserMessage> + Clone + 'static)
) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
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.sourcefn set_background_color(&self, rgba: &RGBA)
fn set_background_color(&self, rgba: &RGBA)
Available on crate feature
v2_8
only.sourcefn set_camera_capture_state(&self, state: MediaCaptureState)
fn set_camera_capture_state(&self, state: MediaCaptureState)
Available on crate feature
v2_34
only.sourcefn set_cors_allowlist(&self, allowlist: &[&str])
fn set_cors_allowlist(&self, allowlist: &[&str])
Available on crate feature
v2_34
only.fn set_custom_charset(&self, charset: Option<&str>)
sourcefn set_display_capture_state(&self, state: MediaCaptureState)
fn set_display_capture_state(&self, state: MediaCaptureState)
Available on crate feature
v2_34
only.sourcefn set_editable(&self, editable: bool)
fn set_editable(&self, editable: bool)
Available on crate feature
v2_8
only.sourcefn set_input_method_context(
&self,
context: Option<&impl IsA<InputMethodContext>>
)
fn set_input_method_context( &self, context: Option<&impl IsA<InputMethodContext>> )
Available on crate feature
v2_28
only.sourcefn set_is_muted(&self, muted: bool)
fn set_is_muted(&self, muted: bool)
Available on crate feature
v2_30
only.sourcefn set_microphone_capture_state(&self, state: MediaCaptureState)
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)
sourcefn terminate_web_process(&self)
fn terminate_web_process(&self)
Available on crate feature
v2_34
only.fn web_context(&self) -> Option<WebContext>
sourcefn connect_authenticate<F: Fn(&Self, &AuthenticationRequest) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
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
sourcefn connect_create<F: Fn(&Self, &NavigationAction) -> Option<Widget> + '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
sourcefn connect_load_failed_with_tls_errors<F: Fn(&Self, &str, &TlsCertificate, TlsCertificateFlags) -> 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
sourcefn connect_run_color_chooser<F: Fn(&Self, &ColorChooserRequest) -> bool + '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
sourcefn connect_script_dialog<F: Fn(&Self, &ScriptDialog) -> 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.sourcefn connect_show_notification<F: Fn(&Self, &Notification) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
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
sourcefn connect_user_message_received<F: Fn(&Self, &UserMessage) -> bool + '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.sourcefn connect_web_process_crashed<F: Fn(&Self) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_web_process_crashed<F: Fn(&Self) -> bool + 'static>( &self, f: F ) -> SignalHandlerId
👎Deprecated: Since 2.20
sourcefn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_web_process_terminated<F: Fn(&Self, WebProcessTerminationReason) + 'static>( &self, f: F ) -> SignalHandlerId
Available on crate feature
v2_20
only.sourcefn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_camera_capture_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Available on crate feature
v2_34
only.sourcefn connect_display_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
Available on crate feature
v2_34
only.sourcefn connect_editable_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
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
sourcefn connect_is_muted_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.sourcefn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_is_playing_audio_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Available on crate feature
v2_8
only.sourcefn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_is_web_process_responsive_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Available on crate feature
v2_34
only.sourcefn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_microphone_capture_state_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Available on crate feature
v2_34
only.sourcefn connect_page_id_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_page_id_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId
Available on crate feature
v2_28
only.sourcefn connect_settings_notify<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
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
Object Safety§
This trait is not object safe.