pub trait WebViewExt: IsA<WebView> + 'static {
Show 128 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<Texture> { ... }
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 network_session(&self) -> Option<NetworkSession> { ... }
fn page_id(&self) -> u64 { ... }
fn session_state(&self) -> Option<WebViewSessionState> { ... }
fn settings(&self) -> Option<Settings> { ... }
fn snapshot<P: FnOnce(Result<Texture, 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<Texture, Error>> + 'static>> { ... }
fn theme_color(&self) -> Option<RGBA> { ... }
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 web_extension_mode(&self) -> WebExtensionMode { ... }
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: &BackForwardListItem) { ... }
fn is_controlled_by_automation(&self) -> bool { ... }
fn is_editable(&self) -> bool { ... }
fn is_immersive_mode_enabled(&self) -> bool { ... }
fn is_loading(&self) -> bool { ... }
fn is_playing_audio(&self) -> bool { ... }
fn leave_immersive_mode(&self) { ... }
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: &URIRequest) { ... }
fn load_uri(&self, uri: &str) { ... }
fn reload(&self) { ... }
fn reload_bypass_cache(&self) { ... }
fn restore_session_state(&self, state: &WebViewSessionState) { ... }
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: &UserMessage,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) { ... }
fn send_message_to_page_future(
&self,
message: &UserMessage,
) -> 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: &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, &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_query_permission_state<F: Fn(&Self, &PermissionStateQuery) -> 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, &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_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_immersive_mode_enabled_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_theme_color_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, )
Asynchronously call body with arguments in the script world with name world_name of the main frame current context in self.
The arguments values must be one of the following types, or contain only the following GVariant types: number, string and dictionary.
The result of the operation can be a Promise that will be properly passed to the callback.
If world_name is None, the default world is used. Any value that is not None is a distin ct world.
The source_uri will be shown in exceptions and doesn’t affect the behavior of the script.
When not provided, the document URL is used.
Note that if enable-javascript is false, this method will do nothing.
If you want to use this method but still prevent web content from executing its own
JavaScript, then use enable-javascript-markup.
When the operation is finished, callback will be called. You can then call
webkit_web_view_call_async_javascript_function_finish() to get the result of the operation.
This is an example that shows how to pass arguments to a JS function that returns a Promise that resolves with the passed argument:
⚠️ The following code is in c ⚠️
static void
web_view_javascript_finished (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
JSCValue *value;
GError *error = NULL;
value = webkit_web_view_call_async_javascript_function_finish (WEBKIT_WEB_VIEW (object), result, &error);
if (!value) {
g_warning ("Error running javascript: %s", error->message);
g_error_free (error);
return;
}
if (jsc_value_is_number (value)) {
gint32 int_value = jsc_value_to_string (value);
JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
if (exception)
g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
else
g_print ("Script result: %d\n", int_value);
g_free (str_value);
} else {
g_warning ("Error running javascript: unexpected return value");
}
g_object_unref (value);
}
static void
web_view_evaluate_promise (WebKitWebView *web_view)
{
GVariantDict dict;
g_variant_dict_init (&dict, NULL);
g_variant_dict_insert (&dict, "count", "u", 42);
GVariant *args = g_variant_dict_end (&dict);
const gchar *body = "return new Promise((resolve) => { resolve(count); });";
webkit_web_view_call_async_javascript_function (web_view, body, -1, arguments, NULL, NULL, NULL, web_view_javascript_finished, NULL);
}§body
the function body
§length
length of body, or -1 if body is a nul-terminated string
§arguments
a glib::Variant with format a{sv} storing the function arguments, or None
§world_name
the name of a WebKitScriptWorld or None to use the default
§source_uri
the source URI
§cancellable
a gio::Cancellable or None to ignore
§callback
a GAsyncReadyCallback to call when the script finished
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>>
Sourcefn can_execute_editing_command<P: FnOnce(Result<(), Error>) + 'static>(
&self,
command: &str,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn can_execute_editing_command<P: FnOnce(Result<(), Error>) + 'static>( &self, command: &str, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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
fn can_execute_editing_command_future( &self, command: &str, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
Sourcefn can_go_back(&self) -> bool
fn can_go_back(&self) -> bool
Sourcefn can_go_forward(&self) -> bool
fn can_go_forward(&self) -> bool
Sourcefn can_show_mime_type(&self, mime_type: &str) -> bool
fn can_show_mime_type(&self, mime_type: &str) -> bool
Sourcefn download_uri(&self, uri: &str) -> Option<Download>
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, )
Asynchronously evaluate script in the script world with name world_name of the main frame current context in self.
If world_name is None, the default world is used. Any value that is not None is a distinct world.
The source_uri will be shown in exceptions and doesn’t affect the behavior of the script.
When not provided, the document URL is used.
Note that if enable-javascript is false, this method will do nothing.
If you want to use this method but still prevent web content from executing its own
JavaScript, then use enable-javascript-markup.
When the operation is finished, callback will be called. You can then call
webkit_web_view_evaluate_javascript_finish() to get the result of the operation.
This is an example of using evaluate_javascript() with a script returning
a string:
⚠️ The following code is in c ⚠️
static void
web_view_javascript_finished (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
JSCValue *value;
GError *error = NULL;
value = webkit_web_view_evaluate_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error);
if (!value) {
g_warning ("Error running javascript: %s", error->message);
g_error_free (error);
return;
}
if (jsc_value_is_string (value)) {
gchar *str_value = jsc_value_to_string (value);
JSCException *exception = jsc_context_get_exception (jsc_value_get_context (value));
if (exception)
g_warning ("Error running javascript: %s", jsc_exception_get_message (exception));
else
g_print ("Script result: %s\n", str_value);
g_free (str_value);
} else {
g_warning ("Error running javascript: unexpected return value");
}
g_object_unref (value);
}
static void
web_view_get_link_url (WebKitWebView *web_view,
const gchar *link_id)
{
gchar *script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id);
webkit_web_view_evaluate_javascript (web_view, script, -1, NULL, NULL, NULL, web_view_javascript_finished, NULL);
g_free (script);
}§script
the script to evaluate
§length
length of script, or -1 if script is a nul-terminated string
§world_name
the name of a WebKitScriptWorld or None to use the default
§source_uri
the source URI
§cancellable
a gio::Cancellable or None to ignore
§callback
a GAsyncReadyCallback to call when the script finished
fn evaluate_javascript_future( &self, script: &str, world_name: Option<&str>, source_uri: Option<&str>, ) -> Pin<Box_<dyn Future<Output = Result<Value, Error>> + 'static>>
Sourcefn execute_editing_command(&self, command: &str)
fn execute_editing_command(&self, command: &str)
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
Sourcefn execute_editing_command_with_argument(&self, command: &str, argument: &str)
fn execute_editing_command_with_argument(&self, command: &str, argument: &str)
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
Sourcefn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation
fn automation_presentation_type(&self) -> AutomationBrowsingContextPresentation
Sourcefn back_forward_list(&self) -> Option<BackForwardList>
fn back_forward_list(&self) -> Option<BackForwardList>
Obtains the BackForwardList associated with the given WebView.
The BackForwardList is owned by the WebView.
§Returns
the BackForwardList
Sourcefn background_color(&self) -> RGBA
fn background_color(&self) -> RGBA
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
Sourcefn camera_capture_state(&self) -> MediaCaptureState
fn camera_capture_state(&self) -> MediaCaptureState
Get the camera capture state of a WebView.
§Returns
The MediaCaptureState of the camera device. If enable-mediastream
is false, this method will return MediaCaptureState::None.
Sourcefn context(&self) -> Option<WebContext>
fn context(&self) -> Option<WebContext>
Sourcefn custom_charset(&self) -> Option<GString>
fn custom_charset(&self) -> Option<GString>
Sourcefn default_content_security_policy(&self) -> Option<GString>
fn default_content_security_policy(&self) -> Option<GString>
Sourcefn display_capture_state(&self) -> MediaCaptureState
fn display_capture_state(&self) -> MediaCaptureState
Get the display capture state of a WebView.
§Returns
The MediaCaptureState of the display device. If enable-mediastream
is false, this method will return MediaCaptureState::None.
Sourcefn editor_state(&self) -> Option<EditorState>
fn editor_state(&self) -> Option<EditorState>
Sourcefn estimated_load_progress(&self) -> f64
fn estimated_load_progress(&self) -> f64
Gets the value of the 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.
Sourcefn find_controller(&self) -> Option<FindController>
fn find_controller(&self) -> Option<FindController>
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.
Sourcefn input_method_context(&self) -> Option<InputMethodContext>
fn input_method_context(&self) -> Option<InputMethodContext>
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
Sourcefn inspector(&self) -> Option<WebInspector>
fn inspector(&self) -> Option<WebInspector>
Sourcefn is_web_process_responsive(&self) -> bool
fn is_web_process_responsive(&self) -> bool
Sourcefn main_resource(&self) -> Option<WebResource>
fn main_resource(&self) -> Option<WebResource>
Return the main resource of self.
§Returns
the main WebResource of the view
or None if nothing has been loaded.
Sourcefn microphone_capture_state(&self) -> MediaCaptureState
fn microphone_capture_state(&self) -> MediaCaptureState
Get the microphone capture state of a WebView.
§Returns
The MediaCaptureState of the microphone device. If enable-mediastream
is false, this method will return MediaCaptureState::None.
Sourcefn network_session(&self) -> Option<NetworkSession>
fn network_session(&self) -> Option<NetworkSession>
Sourcefn session_state(&self) -> Option<WebViewSessionState>
fn session_state(&self) -> Option<WebViewSessionState>
Sourcefn settings(&self) -> Option<Settings>
fn settings(&self) -> Option<Settings>
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
Sourcefn snapshot<P: FnOnce(Result<Texture, Error>) + 'static>(
&self,
region: SnapshotRegion,
options: SnapshotOptions,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn snapshot<P: FnOnce(Result<Texture, Error>) + 'static>( &self, region: SnapshotRegion, options: SnapshotOptions, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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
§callback
a GAsyncReadyCallback
fn snapshot_future( &self, region: SnapshotRegion, options: SnapshotOptions, ) -> Pin<Box_<dyn Future<Output = Result<Texture, Error>> + 'static>>
Sourcefn theme_color(&self) -> Option<RGBA>
Available on crate feature v2_50 only.
fn theme_color(&self) -> Option<RGBA>
v2_50 only.Sourcefn tls_info(&self) -> Option<(TlsCertificate, TlsCertificateFlags)>
fn tls_info(&self) -> Option<(TlsCertificate, TlsCertificateFlags)>
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 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
Sourcefn uri(&self) -> Option<GString>
fn uri(&self) -> Option<GString>
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
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 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.
Sourcefn user_content_manager(&self) -> Option<UserContentManager>
fn user_content_manager(&self) -> Option<UserContentManager>
Gets the user content manager associated to self.
§Returns
the UserContentManager associated with the view
Sourcefn web_extension_mode(&self) -> WebExtensionMode
fn web_extension_mode(&self) -> WebExtensionMode
Sourcefn website_policies(&self) -> Option<WebsitePolicies>
fn website_policies(&self) -> Option<WebsitePolicies>
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
decide-policy signal handler.
See also PolicyDecisionExt::use_with_policies().
§Returns
the default WebsitePolicies
associated with the view.
Sourcefn window_properties(&self) -> Option<WindowProperties>
fn window_properties(&self) -> Option<WindowProperties>
Get the WindowProperties object.
Get the WindowProperties object containing the properties
that the window containing self should have.
§Returns
the WindowProperties of self
Sourcefn zoom_level(&self) -> f64
fn zoom_level(&self) -> f64
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
Sourcefn go_back(&self)
fn go_back(&self)
Loads the previous history item.
You can monitor the load operation by connecting to
load-changed signal.
Sourcefn go_forward(&self)
fn go_forward(&self)
Loads the next history item.
You can monitor the load operation by connecting to
load-changed signal.
Sourcefn go_to_back_forward_list_item(&self, list_item: &BackForwardListItem)
fn go_to_back_forward_list_item(&self, list_item: &BackForwardListItem)
Loads the specific history item list_item.
You can monitor the load operation by connecting to
load-changed signal.
§list_item
Sourcefn is_controlled_by_automation(&self) -> bool
fn is_controlled_by_automation(&self) -> bool
Sourcefn is_editable(&self) -> bool
fn is_editable(&self) -> bool
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.
Sourcefn is_immersive_mode_enabled(&self) -> bool
Available on crate feature v2_52 only.
fn is_immersive_mode_enabled(&self) -> bool
v2_52 only.Sourcefn is_loading(&self) -> bool
fn is_loading(&self) -> bool
Gets the value of the 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
Sourcefn is_playing_audio(&self) -> bool
fn is_playing_audio(&self) -> bool
Gets the value of the 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
Sourcefn leave_immersive_mode(&self)
Available on crate feature v2_52 only.
fn leave_immersive_mode(&self)
v2_52 only.Requests to leave the immersive mode this WebView is in.
Users interact with web content to start XR sessions, and can typically end the sessions themselves, but applications might need to end a session on their own based on application or platform logic.
Note that if WebXR is disabled, or if it is enabled but the self is not in
immersive mode, this API does nothing. See also is_immersive_mode_enabled().
Sourcefn load_alternate_html(
&self,
content: &str,
content_uri: &str,
base_uri: Option<&str>,
)
fn load_alternate_html( &self, content: &str, content_uri: &str, base_uri: Option<&str>, )
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 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
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>, )
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 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
Sourcefn load_html(&self, content: &str, base_uri: Option<&str>)
fn load_html(&self, content: &str, base_uri: Option<&str>)
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 load-changed signal.
§content
The HTML string to load
§base_uri
The base URI for relative locations or None
Sourcefn load_plain_text(&self, plain_text: &str)
fn load_plain_text(&self, plain_text: &str)
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 load-changed signal.
§plain_text
The plain text to load
Sourcefn load_request(&self, request: &URIRequest)
fn load_request(&self, request: &URIRequest)
Requests loading of the specified URIRequest.
You can monitor the load operation by connecting to
load-changed signal.
§request
a URIRequest to load
Sourcefn load_uri(&self, uri: &str)
fn load_uri(&self, uri: &str)
Requests loading of the specified URI string.
You can monitor the load operation by connecting to
load-changed signal.
§uri
an URI string
Sourcefn reload(&self)
fn reload(&self)
Reloads the current contents of self.
See also reload_bypass_cache().
Sourcefn reload_bypass_cache(&self)
fn reload_bypass_cache(&self)
Reloads the current contents of self without
using any cached data.
Sourcefn restore_session_state(&self, state: &WebViewSessionState)
fn restore_session_state(&self, state: &WebViewSessionState)
Sourcefn save<P: FnOnce(Result<InputStream, Error>) + 'static>(
&self,
save_mode: SaveMode,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn save<P: FnOnce(Result<InputStream, Error>) + 'static>( &self, save_mode: SaveMode, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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
fn save_future( &self, save_mode: SaveMode, ) -> Pin<Box_<dyn Future<Output = Result<InputStream, Error>> + 'static>>
Sourcefn 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<P: FnOnce(Result<(), Error>) + 'static>( &self, file: &impl IsA<File>, save_mode: SaveMode, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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
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: &UserMessage,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
fn send_message_to_page<P: FnOnce(Result<UserMessage, Error>) + 'static>( &self, message: &UserMessage, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
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
§cancellable
a gio::Cancellable or None to ignore
§callback
(nullable): A GAsyncReadyCallback to call when the request is satisfied or None
fn send_message_to_page_future( &self, message: &UserMessage, ) -> Pin<Box_<dyn Future<Output = Result<UserMessage, Error>> + 'static>>
Sourcefn set_background_color(&self, rgba: &RGBA)
fn set_background_color(&self, rgba: &RGBA)
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.
§rgba
Sourcefn set_camera_capture_state(&self, state: MediaCaptureState)
fn set_camera_capture_state(&self, state: MediaCaptureState)
Set the camera capture state of a WebView.
If 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
Sourcefn set_cors_allowlist(&self, allowlist: &[&str])
fn set_cors_allowlist(&self, allowlist: &[&str])
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
Sourcefn set_custom_charset(&self, charset: Option<&str>)
fn set_custom_charset(&self, charset: Option<&str>)
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
Sourcefn set_display_capture_state(&self, state: MediaCaptureState)
fn set_display_capture_state(&self, state: MediaCaptureState)
Set the display capture state of a WebView.
If 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
Sourcefn set_editable(&self, editable: bool)
fn set_editable(&self, editable: bool)
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
Sourcefn set_input_method_context(
&self,
context: Option<&impl IsA<InputMethodContext>>,
)
fn set_input_method_context( &self, context: Option<&impl IsA<InputMethodContext>>, )
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
Sourcefn set_is_muted(&self, muted: bool)
fn set_is_muted(&self, muted: bool)
Sourcefn set_microphone_capture_state(&self, state: MediaCaptureState)
fn set_microphone_capture_state(&self, state: MediaCaptureState)
Set the microphone capture state of a WebView.
If 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
Sourcefn set_settings(&self, settings: &Settings)
fn set_settings(&self, settings: &Settings)
Sourcefn set_zoom_level(&self, zoom_level: f64)
fn set_zoom_level(&self, zoom_level: f64)
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
Sourcefn stop_loading(&self)
fn stop_loading(&self)
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
load-failed signal will be emitted with
NetworkError::Cancelled error.
Sourcefn terminate_web_process(&self)
fn terminate_web_process(&self)
Terminates the web process associated to self.
When the web process gets terminated
using this method, the web-process-terminated signal is emitted with
WebProcessTerminationReason::TerminatedByApi as the reason for termination.
Sourcefn try_close(&self)
fn try_close(&self)
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 close signal is emitted, otherwise nothing happens.
Sourcefn web_context(&self) -> Option<WebContext>
fn web_context(&self) -> Option<WebContext>
The WebContext of the view.
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
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
§Returns
true to stop other handlers from being invoked for the event.
false to propagate the event further.
Sourcefn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_close<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
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 ContextMenu::prepend(),
ContextMenu::append() or ContextMenu::insert() to add new
ContextMenuItems to context_menu, ContextMenu::move_item()
to reorder existing items, or ContextMenu::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
ContextMenu::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>
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
§hit_test_result
§Returns
true to stop other handlers from being invoked for the event.
false to propagate the event further.
Emitted after context-menu signal, if the context menu is shown,
to notify that the context menu is dismissed.
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
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
related-view for more details.
The new WebView should not be displayed to the user
until the ready-to-show signal is emitted.
For creating views as response to automation tools requests, see the
create-web-view signal.
§navigation_action
§Returns
a newly allocated WebView widget
or None to propagate the event further.
Sourcefn connect_decide_policy<F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_decide_policy<F: Fn(&Self, &PolicyDecision, PolicyDecisionType) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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.
Sourcefn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_enter_fullscreen<F: Fn(&Self) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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.
Sourcefn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>(
&self,
f: F,
) -> SignalHandlerId
👎Deprecated: Since 2.46
fn connect_insecure_content_detected<F: Fn(&Self, InsecureContentEvent) + 'static>( &self, f: F, ) -> SignalHandlerId
Since 2.46
Sourcefn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_leave_fullscreen<F: Fn(&Self) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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
enter-fullscreen stage for instance.
§Returns
true to stop other handlers from being invoked for the event.
false to continue emission of the event.
Sourcefn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_load_changed<F: Fn(&Self, LoadEvent) + 'static>( &self, f: F, ) -> SignalHandlerId
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 load-failed signal is emitted
before 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
Sourcefn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &Error) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_load_failed<F: Fn(&Self, LoadEvent, &str, &Error) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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.
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
Emitted when a TLS error occurs during a load operation.
To allow an exception for this certificate
and the host of failing_uri use webkit_web_context_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, load-failed will be emitted. The load
will finish regardless of the returned value.
§failing_uri
the URI that failed to load
§certificate
§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.
Sourcefn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_mouse_target_changed<F: Fn(&Self, &HitTestResult, u32) + 'static>( &self, f: F, ) -> SignalHandlerId
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
§modifiers
a bitmask of GdkModifierType
Sourcefn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_permission_request<F: Fn(&Self, &PermissionRequest) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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
§Returns
true to stop other handlers from being invoked for the event.
false to propagate the event further.
Sourcefn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_print<F: Fn(&Self, &PrintOperation) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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 PrintOperation::set_print_settings() and
PrintOperation::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.
§print_operation
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.
Sourcefn connect_query_permission_state<F: Fn(&Self, &PermissionStateQuery) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_query_permission_state<F: Fn(&Self, &PermissionStateQuery) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
This signal allows the User-Agent to respond to permission requests for powerful features, as
specified by the Permissions W3C Specification.
You can reply to the query using PermissionStateQuery::finish().
You can handle the query asynchronously by calling webkit_permission_state_query_ref() on
query and returning true. If the last reference of query is removed and the query has not
been handled, the query result will be set to WEBKIT_QUERY_PERMISSION_PROMPT.
§query
§Returns
Sourcefn connect_ready_to_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_ready_to_show<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted after 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().
Sourcefn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_resource_load_started<F: Fn(&Self, &WebResource, &URIRequest) + 'static>( &self, f: F, ) -> SignalHandlerId
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
§request
Sourcefn connect_run_as_modal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_run_as_modal<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
Emitted after 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.
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
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
§Returns
true to stop other handlers from being invoked for the event.
false to propagate the event further.
Sourcefn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_run_file_chooser<F: Fn(&Self, &FileChooserRequest) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId
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
§Returns
true to stop other handlers from being invoked for the event.
false to propagate the event further.
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
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.
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
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
§Returns
true to stop other handlers from being invoked. false otherwise.
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.
To handle this signal asynchronously you should keep a ref of the menu.
The default signal handler will pop up a GtkMenu.
§menu
the OptionMenu
§rectangle
the option element area
§Returns
true to stop other handlers from being invoked for the event.
false to propagate the event further.
Sourcefn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>(
&self,
f: F,
) -> SignalHandlerId
fn connect_submit_form<F: Fn(&Self, &FormSubmissionRequest) + 'static>( &self, f: F, ) -> SignalHandlerId
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 FormSubmissionRequest::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
FormSubmissionRequest::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, FormSubmissionRequest::submit() will be called.
§request
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
This signal is emitted when a UserMessage is received from the
WebKitWebPage corresponding to web_view. You can reply to the message
using UserMessage::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
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
This signal is emitted when the web process terminates abnormally due
to reason.
§reason
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_immersive_mode_enabled_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
v2_52 only.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_theme_color_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
v2_50 only.fn connect_title_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_uri_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_zoom_level_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.