pub trait WebViewExt: 'static {
Show 125 methods 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 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;
}
Expand description

Trait containing all WebView methods.

Implementors

WebView

Required Methods

Asynchronously check if it is possible to execute the given editing command.

When the operation is finished, callback will be called. You can then call webkit_web_view_can_execute_editing_command_finish() to get the result of the operation.

command

the command to check

cancellable

a gio::Cancellable or None to ignore

callback

a GAsyncReadyCallback to call when the request is satisfied

Determines whether self has a previous history item.

Returns

true if able to move back or false otherwise.

Determines whether self has a next history item.

Returns

true if able to move forward or false otherwise.

Whether or not a MIME type can be displayed in self.

mime_type

a MIME type

Returns

true if the MIME type mime_type can be displayed or false otherwise

Requests downloading of the specified URI string for self.

uri

the URI to download

Returns

a new Download representing the download operation.

Request to execute the given command for self.

You can use can_execute_editing_command() to check whether it’s possible to execute the command.

command

the command to execute

Available on crate feature v2_10 only.

Request to execute the given command with argument for self.

You can use can_execute_editing_command() to check whether it’s possible to execute the command.

command

the command to execute

argument

the command argument

Available on crate feature v2_28 only.

Get the presentation type of WebView when created for automation.

Returns

a AutomationBrowsingContextPresentation.

Obtains the BackForwardList associated with the given WebView.

The BackForwardList is owned by the WebView.

Returns

the BackForwardList

Available on crate feature v2_8 only.

Gets the color that is used to draw the self background.

Gets the color that is used to draw the self background before the actual contents are rendered. For more information see also set_background_color()

Returns
rgba

a gdk::RGBA to fill in with the background color

Available on crate feature v2_34 only.

Get the camera capture state of a WebView.

Returns

The MediaCaptureState of the camera device. If property::Settings::enable-mediastream is false, this method will return MediaCaptureState::None.

Gets the web context of self.

Returns

the WebContext of the view

Returns the current custom character encoding name of self.

Returns

the current custom character encoding name or None if no custom character encoding has been set.

Available on crate feature v2_38 only.

Gets the configured default Content-Security-Policy.

Returns

The default policy or None

Available on crate feature v2_34 only.

Get the display capture state of a WebView.

Returns

The MediaCaptureState of the display device. If property::Settings::enable-mediastream is false, this method will return MediaCaptureState::None.

Available on crate feature v2_10 only.

Gets the web editor state of self.

Returns

the EditorState of the view

Gets the value of the property::WebView::estimated-load-progress property.

You can monitor the estimated progress of a load operation by connecting to the notify::estimated-load-progress signal of self.

Returns

an estimate of the of the percent complete for a document load as a range from 0.0 to 1.0.

Returns favicon currently associated to self.

Returns favicon currently associated to self, if any. You can connect to notify::favicon signal of self to be notified when the favicon is available.

Returns

a pointer to a cairo::Surface with the favicon or None if there’s no icon associated with self.

Gets the FindController.

Gets the FindController that will allow the caller to query the WebView for the text to look for.

Returns

the FindController associated to this particular WebView.

Available on crate feature v2_28 only.

Get the InputMethodContext currently in use by self.

Get the InputMethodContext currently in use by self, or None if no input method is being used.

Returns

a InputMethodContext, or None

Get the WebInspector associated to self

Returns

the WebInspector of self

Available on crate feature v2_30 only.

Gets the mute state of self.

Returns

true if self audio is muted or false is audio is not muted.

Available on crate feature v2_34 only.

Get whether the current web process of a WebView is responsive.

Returns

true if the web process attached to self is responsive, or false otherwise.

Return the main resource of self.

Returns

the main WebResource of the view or None if nothing has been loaded.

Available on crate feature v2_34 only.

Get the microphone capture state of a WebView.

Returns

The MediaCaptureState of the microphone device. If property::Settings::enable-mediastream is false, this method will return MediaCaptureState::None.

Get the identifier of the WebKitWebPage corresponding to the WebView

Returns

the page ID of self.

Available on crate feature v2_12 only.

Gets the current session state of self

Returns

a WebViewSessionState

Gets the Settings currently applied to self.

If no other Settings have been explicitly applied to self with set_settings(), the default Settings will be returned. This method always returns a valid Settings object. To modify any of the self settings, you can either create a new Settings object with Settings::new(), setting the desired preferences, and then replace the existing self settings with set_settings() or get the existing self settings and update it directly. Settings objects can be shared by multiple WebViews, so modifying the settings of a WebView would affect other WebViews using the same Settings.

Returns

the Settings attached to self

Asynchronously retrieves a snapshot of self for region.

options specifies how the snapshot should be rendered.

When the operation is finished, callback will be called. You must call webkit_web_view_get_snapshot_finish() to get the result of the operation.

region

the SnapshotRegion for this snapshot

options

SnapshotOptions for the snapshot

cancellable

a gio::Cancellable

callback

a GAsyncReadyCallback

Gets the value of the property::WebView::title property.

You can connect to notify::title signal of self to be notified when the title has been received.

Returns

The main frame document title of self.

Retrieves the gio::TlsCertificate associated with the main resource of self.

Retrieves the gio::TlsCertificate associated with the main resource of self, and the gio::TlsCertificateFlags showing what problems, if any, have been found with that certificate. If the connection is not HTTPS, this function returns false. This function should be called after a response has been received from the server, so you can connect to signal::WebView::load-changed and call this function when it’s emitted with LoadEvent::Committed event.

Note that this function provides no information about the security of the web page if the current TLSErrorsPolicy is TLSErrorsPolicy::Ignore, as subresources of the page may be controlled by an attacker. This function may safely be used to determine the security status of the current page only if the current TLSErrorsPolicy is TLSErrorsPolicy::Fail, in which case subresources that fail certificate verification will be blocked.

Returns

true if the self connection uses HTTPS and a response has been received from the server, or false otherwise.

certificate

return location for a gio::TlsCertificate

errors

return location for a gio::TlsCertificateFlags the verification status of certificate

Returns the current active URI of self.

The active URI might change during a load operation:

<orderedlist> <listitem>``<para> When nothing has been loaded yet on self the active URI is None. </para>``</listitem> <listitem>``<para> When a new load operation starts the active URI is the requested URI: <itemizedlist> <listitem>``<para> If the load operation was started by load_uri(), the requested URI is the given one. </para>``</listitem> <listitem>``<para> If the load operation was started by load_html(), the requested URI is “about:blank”. </para>``</listitem> <listitem>``<para> If the load operation was started by load_alternate_html(), the requested URI is content URI provided. </para>``</listitem> <listitem>``<para> If the load operation was started by go_back() or go_forward(), the requested URI is the original URI of the previous/next item in the BackForwardList of self. </para>``</listitem> <listitem>``<para> If the load operation was started by go_to_back_forward_list_item(), the requested URI is the opriginal URI of the given BackForwardListItem. </para>``</listitem> </itemizedlist> </para>``</listitem> <listitem>``<para> If there is a server redirection during the load operation, the active URI is the redirected URI. When the signal signal::WebView::load-changed is emitted with LoadEvent::Redirected event, the active URI is already updated to the redirected URI. </para>``</listitem> <listitem>``<para> When the signal signal::WebView::load-changed is emitted with LoadEvent::Committed event, the active URI is the final one and it will not change unless a new load operation is started or a navigation action within the same page is performed. </para>``</listitem> </orderedlist>

You can monitor the active URI by connecting to the notify::uri signal of self.

Returns

the current active URI of self or None if nothing has been loaded yet.

Available on crate feature v2_6 only.

Gets the user content manager associated to self.

Returns

the UserContentManager associated with the view

Available on crate feature v2_16 only.

Get the WebsiteDataManager associated to self.

If self is not ephemeral, the returned WebsiteDataManager will be the same as the WebsiteDataManager of self’s WebContext.

Returns

a WebsiteDataManager

Available on crate feature v2_30 only.

Gets the default website policies.

Gets the default website policies set on construction in the self. These can be overridden on a per-origin basis via the signal::WebView::decide-policy signal handler.

See also PolicyDecisionExt::use_with_policies().

Returns

the default WebsitePolicies associated with the view.

Get the WindowProperties object.

Get the WindowProperties object containing the properties that the window containing self should have.

Returns

the WindowProperties of self

Set the zoom level of self.

Get the zoom level of self, i.e. the factor by which the view contents are scaled with respect to their original size.

Returns

the current zoom level of self

Loads the previous history item.

You can monitor the load operation by connecting to signal::WebView::load-changed signal.

Loads the next history item.

You can monitor the load operation by connecting to signal::WebView::load-changed signal.

Loads the specific history item list_item.

You can monitor the load operation by connecting to signal::WebView::load-changed signal.

list_item

a BackForwardListItem

Available on crate feature v2_18 only.

Get whether a WebView was created with property::WebView::is-controlled-by-automation property enabled.

Only WebViews controlled by automation can be used in an automation session.

Returns

true if self is controlled by automation, or false otherwise.

Available on crate feature v2_8 only.

Gets whether the user is allowed to edit the HTML document.

When self is not editable an element in the HTML document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default a WebView is not editable.

Returns

true if the user is allowed to edit the HTML document, or false otherwise.

Available on crate feature v2_16 only.

Get whether a WebView is ephemeral.

To create an ephemeral WebView you need to use glib::Object::new() and pass is-ephemeral property with true value. See property::WebView::is-ephemeral for more details. If self was created with a ephemeral property::WebView::related-view or an ephemeral property::WebView::web-context it will also be ephemeral.

Returns

true if self is ephemeral or false otherwise.

Gets the value of the property::WebView::is-loading property.

You can monitor when a WebView is loading a page by connecting to notify::is-loading signal of self. This is useful when you are interesting in knowing when the view is loading something but not in the details about the status of the load operation, for example to start a spinner when the view is loading a page and stop it when it finishes.

Returns

true if self is loading a page or false otherwise.

Available on crate feature v2_8 only.

Gets the value of the property::WebView::is-playing-audio property.

You can monitor when a page in a WebView is playing audio by connecting to the notify::is-playing-audio signal of self. This is useful when the application wants to provide visual feedback when a page is producing sound.

Returns

true if a page in self is playing audio or false otherwise.

Load the given content string for the URI content_uri.

This allows clients to display page-loading errors in the WebView itself. When this method is called from signal::WebView::load-failed signal to show an error page, then the back-forward list is maintained appropriately. For everything else this method works the same way as load_html().

content

the new content to display as the main page of the self

content_uri

the URI for the alternate page content

base_uri

the base URI for relative locations or None

Available on crate feature v2_6 only.

Load the specified bytes into self using the given mime_type and encoding.

When mime_type is None, it defaults to “text/html”. When encoding is None, it defaults to “UTF-8”. When base_uri is None, it defaults to “about:blank”. You can monitor the load operation by connecting to signal::WebView::load-changed signal.

bytes

input data to load

mime_type

the MIME type of bytes, or None

encoding

the character encoding of bytes, or None

base_uri

the base URI for relative locations or None

Load the given content string with the specified base_uri.

If base_uri is not None, relative URLs in the content will be resolved against base_uri and absolute local paths must be children of the base_uri. For security reasons absolute local paths that are not children of base_uri will cause the web process to terminate. If you need to include URLs in content that are local paths in a different directory than base_uri you can build a data URI for them. When base_uri is None, it defaults to “about:blank”. The mime type of the document will be “text/html”. You can monitor the load operation by connecting to signal::WebView::load-changed signal.

content

The HTML string to load

base_uri

The base URI for relative locations or None

Load the specified plain_text string into self.

The mime type of document will be “text/plain”. You can monitor the load operation by connecting to signal::WebView::load-changed signal.

plain_text

The plain text to load

Requests loading of the specified URIRequest.

You can monitor the load operation by connecting to signal::WebView::load-changed signal.

request

a URIRequest to load

Requests loading of the specified URI string.

You can monitor the load operation by connecting to signal::WebView::load-changed signal.

uri

an URI string

Reloads the current contents of self.

See also reload_bypass_cache().

Reloads the current contents of self without using any cached data.

Available on crate feature v2_12 only.

Restore the self session state from state

state

a WebViewSessionState

Asynchronously run script in the context of the current page in self.

If WebKitSettings:enable-javascript is FALSE, this method will do nothing.

When the operation is finished, callback will be called. You can then call webkit_web_view_run_javascript_finish() to get the result of the operation.

script

the script to run

cancellable

a gio::Cancellable or None to ignore

callback

a GAsyncReadyCallback to call when the script finished

Asynchronously run the script from resource.

Asynchronously run the script from resource in the context of the current page in self.

When the operation is finished, callback will be called. You can then call webkit_web_view_run_javascript_from_gresource_finish() to get the result of the operation.

resource

the location of the resource to load

cancellable

a gio::Cancellable or None to ignore

callback

a GAsyncReadyCallback to call when the script finished

Available on crate feature v2_22 only.

Asynchronously run script in the script world.

Asynchronously run script in the script world with name world_name of the current page context in self. If WebKitSettings:enable-javascript is FALSE, this method will do nothing.

When the operation is finished, callback will be called. You can then call webkit_web_view_run_javascript_in_world_finish() to get the result of the operation.

script

the script to run

world_name

the name of a WebKitScriptWorld

cancellable

a gio::Cancellable or None to ignore

callback

a GAsyncReadyCallback to call when the script finished

Available on crate feature v2_22 only.

Asynchronously save the current web page.

Asynchronously save the current web page associated to the WebView into a self-contained format using the mode specified in save_mode.

When the operation is finished, callback will be called. You can then call webkit_web_view_save_finish() to get the result of the operation.

save_mode

the SaveMode specifying how the web page should be saved.

cancellable

a gio::Cancellable or None to ignore

callback

a GAsyncReadyCallback to call when the request is satisfied

Asynchronously save the current web page.

Asynchronously save the current web page associated to the WebView into a self-contained format using the mode specified in save_mode and writing it to file.

When the operation is finished, callback will be called. You can then call webkit_web_view_save_to_file_finish() to get the result of the operation.

file

the gio::File where the current web page should be saved to.

save_mode

the SaveMode specifying how the web page should be saved.

cancellable

a gio::Cancellable or None to ignore

callback

a GAsyncReadyCallback to call when the request is satisfied

Available on crate feature v2_28 only.

Send message to the WebKitWebPage corresponding to self.

If message is floating, it’s consumed. If you don’t expect any reply, or you simply want to ignore it, you can pass None as callback. When the operation is finished, callback will be called. You can then call webkit_web_view_send_message_to_page_finish() to get the message reply.

message

a UserMessage

cancellable

a gio::Cancellable or None to ignore

callback

(nullable): A GAsyncReadyCallback to call when the request is satisfied or None

Available on crate feature v2_28 only.
Available on crate feature v2_8 only.

Sets the color that will be used to draw the self background.

Sets the color that will be used to draw the self background before the actual contents are rendered. Note that if the web page loaded in self specifies a background color, it will take precedence over the rgba color. By default the self background color is opaque white. Note that the parent window must have a RGBA visual and property::gtk::Widget::app-paintable property set to true for backgrounds colors to work.

⚠️ The following code is in c ⚠️

static void browser_window_set_background_color (BrowserWindow *window,
                                                 const GdkRGBA *rgba)
{
    WebKitWebView *web_view;
    GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window));
    GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen);

    if (!rgba_visual)
         return;

    gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual);
    gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);

    web_view = browser_window_get_web_view (window);
    webkit_web_view_set_background_color (web_view, rgba);
}
rgba

a gdk::RGBA

Available on crate feature v2_34 only.

Set the camera capture state of a WebView.

If property::Settings::enable-mediastream is false, this method will have no visible effect. Once the state of the device has been set to MediaCaptureState::None it cannot be changed anymore. The page can however request capture again using the mediaDevices API.

state

a MediaCaptureState

Available on crate feature v2_34 only.

Sets the allowlist for CORS.

Sets the allowlist for which Cross-Origin Resource Sharing checks are disabled in self. URI patterns must be of the form [protocol]://[host]/[path], each component may contain the wildcard character (*) to represent zero or more other characters. All three components are required and must not be omitted from the URI patterns.

Disabling CORS checks permits resources from other origins to load allowlisted resources. It does not permit the allowlisted resources to load resources from other origins.

If this function is called multiple times, only the allowlist set by the most recent call will be effective.

allowlist

an allowlist of URI patterns, or None

Sets the current custom character encoding override of self.

The custom character encoding will override any text encoding detected via HTTP headers or META tags. Calling this method will stop any current load operation and reload the current page. Setting the custom character encoding to None removes the character encoding override.

charset

a character encoding name or None

Available on crate feature v2_34 only.

Set the display capture state of a WebView.

If property::Settings::enable-mediastream is false, this method will have no visible effect. Once the state of the device has been set to MediaCaptureState::None it cannot be changed anymore. The page can however request capture again using the mediaDevices API.

state

a MediaCaptureState

Available on crate feature v2_8 only.

Sets whether the user is allowed to edit the HTML document.

If editable is true, self allows the user to edit the HTML document. If editable is false, an element in self’s document can only be edited if the CONTENTEDITABLE attribute has been set on the element or one of its parent elements. By default a WebView is not editable.

Normally, a HTML document is not editable unless the elements within the document are editable. This function provides a way to make the contents of a WebView editable without altering the document or DOM structure.

editable

a gboolean indicating the editable state

Available on crate feature v2_28 only.

Set the InputMethodContext to be used by self.

Set the InputMethodContext to be used by self, or None to not use any input method. Note that the same InputMethodContext can’t be set on more than one WebView at the same time.

context

the InputMethodContext to set, or None

Available on crate feature v2_30 only.

Sets the mute state of self.

muted

mute flag

Available on crate feature v2_34 only.

Set the microphone capture state of a WebView.

If property::Settings::enable-mediastream is false, this method will have no visible effect. Once the state of the device has been set to MediaCaptureState::None it cannot be changed anymore. The page can however request capture again using the mediaDevices API.

state

a MediaCaptureState

Sets the Settings to be applied to self.

The existing Settings of self will be replaced by settings. New settings are applied immediately on self. The same Settings object can be shared by multiple WebViews.

settings

a Settings

Set the zoom level of self.

Set the zoom level of self, i.e. the factor by which the view contents are scaled with respect to their original size.

zoom_level

the zoom level

Stops any ongoing loading operation in self.

This method does nothing if no content is being loaded. If there is a loading operation in progress, it will be cancelled and signal::WebView::load-failed signal will be emitted with NetworkError::Cancelled error.

Available on crate feature v2_34 only.

Terminates the web process associated to self.

When the web process gets terminated using this method, the signal::WebView::web-process-terminated signal is emitted with WebProcessTerminationReason::TerminatedByApi as the reason for termination.

Available on crate feature v2_12 only.

Tries to close the self.

This will fire the onbeforeunload event to ask the user for confirmation to close the page. If there isn’t an onbeforeunload event handler or the user confirms to close the page, the signal::WebView::close signal is emitted, otherwise nothing happens.

The WebContext of the view.

Available on crate feature v2_2 only.

This signal is emitted when the user is challenged with HTTP authentication. To let the application access or supply the credentials as well as to allow the client application to either cancel the request or perform the authentication, the signal will pass an instance of the AuthenticationRequest in the request argument. To handle this signal asynchronously you should keep a ref of the request and return true. To disable HTTP authentication entirely, connect to this signal and simply return true.

The default signal handler will run a default authentication dialog asynchronously for the user to interact with.

request

a AuthenticationRequest

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Emitted when closing a WebView is requested. This occurs when a call is made from JavaScript’s <function>window.close</function> function or after trying to close the web_view with try_close(). It is the owner’s responsibility to handle this signal to hide or destroy the WebView, if necessary.

Emitted when a context menu is about to be displayed to give the application a chance to customize the proposed menu, prevent the menu from being displayed, or build its own context menu. <itemizedlist> <listitem>``<para> To customize the proposed menu you can use ContextMenuExt::prepend(), ContextMenuExt::append() or ContextMenuExt::insert() to add new ContextMenuItems to context_menu, ContextMenuExt::move_item() to reorder existing items, or ContextMenuExt::remove() to remove an existing item. The signal handler should return false, and the menu represented by context_menu will be shown. </para>``</listitem> <listitem>``<para> To prevent the menu from being displayed you can just connect to this signal and return true so that the proposed menu will not be shown. </para>``</listitem> <listitem>``<para> To build your own menu, you can remove all items from the proposed menu with ContextMenuExt::remove_all(), add your own items and return false so that the menu will be shown. You can also ignore the proposed ContextMenu, build your own GtkMenu and return true to prevent the proposed menu from being shown. </para>``</listitem> <listitem>``<para> If you just want the default menu to be shown always, simply don’t connect to this signal because showing the proposed context menu is the default behaviour. </para>``</listitem> </itemizedlist>

The event is expected to be one of the following types: <itemizedlist> <listitem>``<para> a GdkEventButton of type GDK_BUTTON_PRESS when the context menu was triggered with mouse. </para>``</listitem> <listitem>``<para> a GdkEventKey of type GDK_KEY_PRESS if the keyboard was used to show the menu. </para>``</listitem> <listitem>``<para> a generic gdk::Event of type GDK_NOTHING when the signal::gtk::Widget::popup-menu signal was used to show the context menu. </para>``</listitem> </itemizedlist>

If the signal handler returns false the context menu represented by context_menu will be shown, if it return true the context menu will not be shown.

The proposed ContextMenu passed in context_menu argument is only valid during the signal emission.

context_menu

the proposed ContextMenu

event

the gdk::Event that triggered the context menu

hit_test_result

a HitTestResult

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Emitted after signal::WebView::context-menu signal, if the context menu is shown, to notify that the context menu is dismissed.

Available on crate feature v2_6 only.

Emitted when the creation of a new WebView is requested. If this signal is handled the signal handler should return the newly created WebView.

The NavigationAction parameter contains information about the navigation action that triggered this signal.

The new WebView must be related to web_view, see WebView::with_related_view() for more details.

The new WebView should not be displayed to the user until the signal::WebView::ready-to-show signal is emitted.

a NavigationAction

Returns

a newly allocated WebView widget or None to propagate the event further.

This signal is emitted when WebKit is requesting the client to decide a policy decision, such as whether to navigate to a page, open a new window or whether or not to download a resource. The NavigationPolicyDecision passed in the decision argument is a generic type, but should be casted to a more specific type when making the decision. For example:

⚠️ The following code is in c ⚠️

static gboolean
decide_policy_cb (WebKitWebView *web_view,
                  WebKitPolicyDecision *decision,
                  WebKitPolicyDecisionType type)
{
    switch (type) {
    case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
        WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
        // Make a policy decision here
        break;
    }
    case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {
        WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
        // Make a policy decision here
        break;
    }
    case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
        WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
        // Make a policy decision here
        break;
    default:
        // Making no decision results in webkit_policy_decision_use()
        return FALSE;
    }
    return TRUE;
}

It is possible to make policy decision asynchronously, by simply calling g_object_ref() on the decision argument and returning true to block the default signal handler. If the last reference is removed on a PolicyDecision and no decision has been made explicitly, PolicyDecisionExt::use_() will be the default policy decision. The default signal handler will simply call PolicyDecisionExt::use_(). Only the first policy decision chosen for a given PolicyDecision will have any affect.

decision

the PolicyDecision

decision_type

a PolicyDecisionType denoting the type of decision

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Emitted when JavaScript code calls <function>element.webkitRequestFullScreen</function>. If the signal is not handled the WebView will proceed to full screen its top level window. This signal can be used by client code to request permission to the user prior doing the full screen transition and eventually prepare the top-level window (e.g. hide some widgets that would otherwise be part of the full screen window).

Returns

true to stop other handlers from being invoked for the event. false to continue emission of the event.

This signal is emitted when insecure content has been detected in a page loaded through a secure connection. This typically means that a external resource from an unstrusted source has been run or displayed, resulting in a mix of HTTPS and non-HTTPS content.

You can check the event parameter to know exactly which kind of event has been detected (see InsecureContentEvent).

event

the InsecureContentEvent

Emitted when the WebView is about to restore its top level window out of its full screen state. This signal can be used by client code to restore widgets hidden during the signal::WebView::enter-fullscreen stage for instance.

Returns

true to stop other handlers from being invoked for the event. false to continue emission of the event.

Emitted when a load operation in web_view changes. The signal is always emitted with LoadEvent::Started when a new load request is made and LoadEvent::Finished when the load finishes successfully or due to an error. When the ongoing load operation fails signal::WebView::load-failed signal is emitted before signal::WebView::load-changed is emitted with LoadEvent::Finished. If a redirection is received from the server, this signal is emitted with LoadEvent::Redirected after the initial emission with LoadEvent::Started and before LoadEvent::Committed. When the page content starts arriving the signal is emitted with LoadEvent::Committed event.

You can handle this signal and use a switch to track any ongoing load operation.

⚠️ The following code is in c ⚠️

static void web_view_load_changed (WebKitWebView  *web_view,
                                   WebKitLoadEvent load_event,
                                   gpointer        user_data)
{
    switch (load_event) {
    case WEBKIT_LOAD_STARTED:
        // New load, we have now a provisional URI
        provisional_uri = webkit_web_view_get_uri (web_view);
        // Here we could start a spinner or update the
        // location bar with the provisional URI
        break;
    case WEBKIT_LOAD_REDIRECTED:
        redirected_uri = webkit_web_view_get_uri (web_view);
        break;
    case WEBKIT_LOAD_COMMITTED:
        // The load is being performed. Current URI is
        // the final one and it won't change unless a new
        // load is requested or a navigation within the
        // same page is performed
        uri = webkit_web_view_get_uri (web_view);
        break;
    case WEBKIT_LOAD_FINISHED:
        // Load finished, we can now stop the spinner
        break;
    }
}
load_event

the LoadEvent

Emitted when an error occurs during a load operation. If the error happened when starting to load data for a page load_event will be LoadEvent::Started. If it happened while loading a committed data source load_event will be LoadEvent::Committed. Since a load error causes the load operation to finish, the signal WebKitWebView::load-changed will always be emitted with LoadEvent::Finished event right after this one.

By default, if the signal is not handled, a stock error page will be displayed. You need to handle the signal if you want to provide your own error page.

load_event

the LoadEvent of the load operation

failing_uri

the URI that failed to load

error

the glib::Error that was triggered

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Available on crate feature v2_6 only.

Emitted when a TLS error occurs during a load operation. To allow an exception for this certificate and the host of failing_uri use WebContextExt::allow_tls_certificate_for_host().

To handle this signal asynchronously you should call g_object_ref() on certificate and return true.

If false is returned, signal::WebView::load-failed will be emitted. The load will finish regardless of the returned value.

failing_uri

the URI that failed to load

certificate

a gio::TlsCertificate

errors

a gio::TlsCertificateFlags with the verification status of certificate

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element. To determine what type of element the mouse cursor is over, a Hit Test is performed on the current mouse coordinates and the result is passed in the hit_test_result argument. The modifiers argument is a bitmask of GdkModifierType flags indicating the state of modifier keys. The signal is emitted again when the mouse is moved out of the current element with a new hit_test_result.

hit_test_result

a HitTestResult

modifiers

a bitmask of GdkModifierType

This signal is emitted when WebKit is requesting the client to decide about a permission request, such as allowing the browser to switch to fullscreen mode, sharing its location or similar operations.

A possible way to use this signal could be through a dialog allowing the user decide what to do with the request:

⚠️ The following code is in c ⚠️

static gboolean permission_request_cb (WebKitWebView *web_view,
                                       WebKitPermissionRequest *request,
                                       GtkWindow *parent_window)
{
    GtkWidget *dialog = gtk_message_dialog_new (parent_window,
                                                GTK_DIALOG_MODAL,
                                                GTK_MESSAGE_QUESTION,
                                                GTK_BUTTONS_YES_NO,
                                                "Allow Permission Request?");
    gtk_widget_show (dialog);
    gint result = gtk_dialog_run (GTK_DIALOG (dialog));

    switch (result) {
    case GTK_RESPONSE_YES:
        webkit_permission_request_allow (request);
        break;
    default:
        webkit_permission_request_deny (request);
        break;
    }
    gtk_widget_destroy (dialog);

    return TRUE;
}

It is possible to handle permission requests asynchronously, by simply calling g_object_ref() on the request argument and returning true to block the default signal handler. If the last reference is removed on a PermissionRequest and the request has not been handled, PermissionRequestExt::deny() will be the default action.

If the signal is not handled, the request will be completed automatically by the specific PermissionRequest that could allow or deny it. Check the documentation of classes implementing PermissionRequest interface to know their default action.

request

the PermissionRequest

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Emitted when printing is requested on web_view, usually by a JavaScript call, before the print dialog is shown. This signal can be used to set the initial print settings and page setup of print_operation to be used as default values in the print dialog. You can call PrintOperationExt::set_print_settings() and PrintOperationExt::set_page_setup() and then return false to propagate the event so that the print dialog is shown.

You can connect to this signal and return true to cancel the print operation or implement your own print dialog.

the PrintOperation that will handle the print request

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Emitted after signal::WebView::create on the newly created WebView when it should be displayed to the user. When this signal is emitted all the information about how the window should look, including size, position, whether the location, status and scrollbars should be displayed, is already set on the WindowProperties of web_view. See also window_properties().

Emitted when a new resource is going to be loaded. The request parameter contains the URIRequest that will be sent to the server. You can monitor the load operation by connecting to the different signals of resource.

resource

a WebResource

request

a URIRequest

Emitted after signal::WebView::ready-to-show on the newly created WebView when JavaScript code calls <function>window.showModalDialog</function>. The purpose of this signal is to allow the client application to prepare the new view to behave as modal. Once the signal is emitted a new main loop will be run to block user interaction in the parent WebView until the new dialog is closed.

Available on crate feature v2_8 only.

This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select a color. To let the application know the details of the color chooser, as well as to allow the client application to either cancel the request or perform an actual color selection, the signal will pass an instance of the ColorChooserRequest in the request argument.

It is possible to handle this request asynchronously by increasing the reference count of the request.

The default signal handler will asynchronously run a regular GtkColorChooser for the user to interact with.

request

a ColorChooserRequest

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select one or more files to be uploaded. To let the application know the details of the file chooser, as well as to allow the client application to either cancel the request or perform an actual selection of files, the signal will pass an instance of the FileChooserRequest in the request argument.

The default signal handler will asynchronously run a regular GtkFileChooserDialog for the user to interact with.

request

a FileChooserRequest

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Available on crate feature v2_24 only.

Emitted when JavaScript code calls <function>window.alert</function>, <function>window.confirm</function> or <function>window.prompt</function>, or when <function>onbeforeunload</function> event is fired. The dialog parameter should be used to build the dialog. If the signal is not handled a different dialog will be built and shown depending on the dialog type: <itemizedlist> <listitem>``<para> ScriptDialogType::Alert: message dialog with a single Close button. </para>``</listitem> <listitem>``<para> ScriptDialogType::Confirm: message dialog with OK and Cancel buttons. </para>``</listitem> <listitem>``<para> ScriptDialogType::Prompt: message dialog with OK and Cancel buttons and a text entry with the default text. </para>``</listitem> <listitem>``<para> ScriptDialogType::BeforeUnloadConfirm: message dialog with Stay and Leave buttons. </para>``</listitem> </itemizedlist>

It is possible to handle the script dialog request asynchronously, by simply caling webkit_script_dialog_ref() on the dialog argument and calling ScriptDialog::close() when done. If the last reference is removed on a ScriptDialog and the dialog has not been closed, ScriptDialog::close() will be called.

dialog

the ScriptDialog to show

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Available on crate feature v2_8 only.

This signal is emitted when a notification should be presented to the user. The notification is kept alive until either: 1) the web page cancels it or 2) a navigation happens.

The default handler will emit a notification using libnotify, if built with support for it.

notification

a Notification

Returns

true to stop other handlers from being invoked. false otherwise.

Available on crate feature v2_18 only.

This signal is emitted when a select element in web_view needs to display a dropdown menu. This signal can be used to show a custom menu, using menu to get the details of all items that should be displayed. The area of the element in the WebView is given as rectangle parameter, it can be used to position the menu. If this was triggered by a user interaction, like a mouse click, event parameter provides the gdk::Event. To handle this signal asynchronously you should keep a ref of the menu.

The default signal handler will pop up a GtkMenu.

the OptionMenu

event

the gdk::Event that triggered the menu, or None

rectangle

the option element area

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

This signal is emitted when a form is about to be submitted. The request argument passed contains information about the text fields of the form. This is typically used to store login information that can be used later to pre-fill the form. The form will not be submitted until FormSubmissionRequestExt::submit() is called.

It is possible to handle the form submission request asynchronously, by simply calling g_object_ref() on the request argument and calling FormSubmissionRequestExt::submit() when done to continue with the form submission. If the last reference is removed on a FormSubmissionRequest and the form has not been submitted, FormSubmissionRequestExt::submit() will be called.

request

a FormSubmissionRequest

Available on crate feature v2_28 only.

This signal is emitted when a UserMessage is received from the WebKitWebPage corresponding to web_view. You can reply to the message using UserMessageExt::send_reply().

You can handle the user message asynchronously by calling g_object_ref() on message and returning true. If the last reference of message is removed and the message has not been replied to, the operation in the WebKitWebPage will finish with error UserMessageError::Message.

message

the UserMessage received

Returns

true if the message was handled, or false otherwise.

👎Deprecated: Since 2.20

This signal is emitted when the web process crashes.

Deprecated since 2.20

Use WebKitWebView::web-process-terminated instead.

Returns

true to stop other handlers from being invoked for the event. false to propagate the event further.

Available on crate feature v2_20 only.

This signal is emitted when the web process terminates abnormally due to reason.

reason

the a WebProcessTerminationReason

Available on crate feature v2_34 only.
Available on crate feature v2_34 only.
Available on crate feature v2_8 only.
Available on crate feature v2_30 only.
Available on crate feature v2_8 only.
Available on crate feature v2_34 only.
Available on crate feature v2_34 only.
Available on crate feature v2_28 only.
Available on crate feature v2_6 only.

Implementors