WebKit.WebView¶
- Subclasses:
None
Methods¶
- Inherited:
Gtk.Widget (183), GObject.Object (37), Gtk.Accessible (17), Gtk.Buildable (1)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
- Inherited:
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
r/w/co |
|||
r/w |
|||
r/w/co |
|||
r/w |
|||
r/w |
|||
r |
|||
r |
|||
r/w/co |
|||
r |
|||
r/w |
|||
r |
|||
r |
|||
r/w |
|||
r/w/co |
|||
r |
|||
w/co |
|||
w/c |
|||
r |
|||
r |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w/co |
|||
r/w |
Signals¶
- Inherited:
Name |
Short Description |
|---|---|
This signal is emitted when the user is challenged with HTTP authentication. |
|
Emitted when closing a |
|
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. |
|
Emitted after |
|
Emitted when the creation of a new |
|
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. |
|
Emitted when JavaScript code calls element.webkitRequestFullScreen. |
|
Prior to 2.46, this signal was emitted when insecure content was loaded in a secure content. |
|
Emitted when the |
|
Emitted when a load operation in web_view changes. |
|
Emitted when an error occurs during a load operation. |
|
Emitted when a TLS error occurs during a load operation. |
|
This signal is emitted when the mouse cursor moves over an element such as a link, image or a media element. |
|
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. |
|
Emitted when printing is requested on web_view, usually by a JavaScript call, before the print dialog is shown. |
|
This signal allows the User-Agent to respond to permission requests for powerful features, as specified by the Permissions W3C Specification. |
|
Emitted after |
|
Emitted when a new resource is going to be loaded. |
|
Emitted after |
|
This signal is emitted when the user interacts with a HTML element, requesting from WebKit to show a dialog to select a color. |
|
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. |
|
Emitted when JavaScript code calls window.alert, window.confirm or window.prompt, or when onbeforeunload event is fired. |
|
This signal is emitted when a notification should be presented to the user. |
|
This signal is emitted when a select element in web_view needs to display a dropdown menu. |
|
This signal is emitted when a form is about to be submitted. |
|
This signal is emitted when a |
|
This signal is emitted when the web process terminates abnormally due to reason. |
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent_instance |
r |
Class Details¶
- class WebKit.WebView(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The central class of the WPE WebKit and WebKitGTK APIs.
WebKit.WebViewis the central class of the WPE WebKit and WebKitGTK APIs. It is responsible for managing the drawing of the content and forwarding of events. You can load any URI into theWebKit.WebViewor a data string. WithWebKit.Settingsyou can control various aspects of the rendering and loading of the content.Note that in WebKitGTK,
WebKit.WebViewis scrollable by itself, so you don’t need to embed it in aGtk.ScrolledWindow.- classmethod new()¶
- Returns:
The newly created
WebKit.WebViewwidget- Return type:
Creates a new
WebKit.WebViewwith the defaultWebKit.WebContext.Creates a new
WebKit.WebViewwith the defaultWebKit.WebContextand noWebKit.UserContentManagerassociated with it. See also webkit_web_view_new_with_context(), webkit_web_view_new_with_user_content_manager(), and webkit_web_view_new_with_settings().
- call_async_javascript_function(body, length, arguments, world_name, source_uri, cancellable, callback, *user_data)¶
- Parameters:
body (
str) – the function bodylength (
int) – length of body, or -1 if body is a nul-terminated stringarguments (
GLib.VariantorNone) – aGLib.Variantwith formata{sv}storing the function arguments, orNoneworld_name (
strorNone) – the name of a #WebKitScriptWorld orNoneto use the defaultcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
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
GLib.Varianttypes: number, string and dictionary. The result of the operation can be a Promise that will be properly passed to the callback. If world_name isNone, the default world is used. Any value that is notNoneis 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
WebKit.Settings:enable-javascriptisFalse, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useWebKit.Settings:enable-javascript-markup.When the operation is finished, callback will be called. You can then call
WebKit.WebView.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:
```c static void web_view_javascript_finished (
GObject.Object*object,Gio.AsyncResult*result,objectuser_data) {JavaScriptCore.Value*value;GLib.Error*error =None;value =
WebKit.WebView.call_async_javascript_function_finish(WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning (“Error running javascript: %s”, error->message);GLib.Error.free(error); return; }if (
JavaScriptCore.Value.is_number(value)) { gint32 int_value =JavaScriptCore.Value.to_string(value);JavaScriptCore.Exception*exception =JavaScriptCore.Context.get_exception(JavaScriptCore.Value.get_context(value)); if (exception) g_warning (“Error running javascript: %s”,JavaScriptCore.Exception.get_message(exception)); else g_print (“Script result: %d\n”, int_value);GLib.free(str_value); } else { g_warning (“Error running javascript: unexpected return value”); }GObject.Object.unref(value); }static void web_view_evaluate_promise (
WebKit.WebView*web_view) {GLib.VariantDictdict; g_variant_dict_init (&dict,None); g_variant_dict_insert (&dict, “count”, “u”, 42);GLib.Variant*args =GLib.VariantDict.end(&dict); conststr*body = “return new Promise((resolve) => { resolve(count); });”;WebKit.WebView.call_async_javascript_function(web_view, body, -1, arguments,None,None,None, web_view_javascript_finished,None); } ```New in version 2.40.
- call_async_javascript_function_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
a
JavaScriptCore.Valuewith the return value of the async function orNonein case of error- Return type:
Finish an asynchronous operation started with
WebKit.WebView.call_async_javascript_function().New in version 2.40.
- can_execute_editing_command(command, cancellable, callback, *user_data)¶
- Parameters:
command (
str) – the command to checkcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
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.WebView.can_execute_editing_command_finish() to get the result of the operation.
- can_execute_editing_command_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
Trueif the editing command can be executed orFalseotherwise- Return type:
Finish an asynchronous operation started with
WebKit.WebView.can_execute_editing_command().
- can_go_back()¶
-
Determines whether self has a previous history item.
- can_go_forward()¶
-
Determines whether self has a next history item.
- can_show_mime_type(mime_type)¶
- Parameters:
mime_type (
str) – a MIME type- Returns:
Trueif the MIME type mime_type can be displayed orFalseotherwise- Return type:
Whether or not a MIME type can be displayed in self.
- download_uri(uri)¶
- Parameters:
uri (
str) – the URI to download- Returns:
a new
WebKit.Downloadrepresenting the download operation.- Return type:
Requests downloading of the specified URI string for self.
- evaluate_javascript(script, length, world_name, source_uri, cancellable, callback, *user_data)¶
- Parameters:
script (
str) – the script to evaluatelength (
int) – length of script, or -1 if script is a nul-terminated stringworld_name (
strorNone) – the name of a #WebKitScriptWorld orNoneto use the defaultcancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the script finisheduser_data (
objectorNone) – the data to pass to callback function
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 notNoneis 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
WebKit.Settings:enable-javascriptisFalse, this method will do nothing. If you want to use this method but still prevent web content from executing its own JavaScript, then useWebKit.Settings:enable-javascript-markup.When the operation is finished, callback will be called. You can then call
WebKit.WebView.evaluate_javascript_finish() to get the result of the operation.This is an example of using
WebKit.WebView.evaluate_javascript() with a script returning a string:```c static void web_view_javascript_finished (
GObject.Object*object,Gio.AsyncResult*result,objectuser_data) {JavaScriptCore.Value*value;GLib.Error*error =None;value =
WebKit.WebView.evaluate_javascript_finish(WEBKIT_WEB_VIEW (object), result, &error); if (!value) { g_warning (“Error running javascript: %s”, error->message);GLib.Error.free(error); return; }if (
JavaScriptCore.Value.is_string(value)) {str*str_value =JavaScriptCore.Value.to_string(value);JavaScriptCore.Exception*exception =JavaScriptCore.Context.get_exception(JavaScriptCore.Value.get_context(value)); if (exception) g_warning (“Error running javascript: %s”,JavaScriptCore.Exception.get_message(exception)); else g_print (“Script result: %s\n”, str_value);GLib.free(str_value); } else { g_warning (“Error running javascript: unexpected return value”); }GObject.Object.unref(value); }static void web_view_get_link_url (
WebKit.WebView*web_view, conststr*link_id) {str*script = g_strdup_printf (“window.document.getElementById(‘%s’).href;”, link_id);WebKit.WebView.evaluate_javascript(web_view, script, -1,None,None,None, web_view_javascript_finished,None);GLib.free(script); } ```New in version 2.40.
- evaluate_javascript_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
a
JavaScriptCore.Valuewith the result of the last executed statement in script orNonein case of error- Return type:
Finish an asynchronous operation started with
WebKit.WebView.evaluate_javascript().New in version 2.40.
- execute_editing_command(command)¶
- Parameters:
command (
str) – the command to execute
Request to execute the given command for self.
You can use
WebKit.WebView.can_execute_editing_command() to check whether it’s possible to execute the command.
- execute_editing_command_with_argument(command, argument)¶
-
Request to execute the given command with argument for self.
You can use
WebKit.WebView.can_execute_editing_command() to check whether it’s possible to execute the command.New in version 2.10.
- get_automation_presentation_type()¶
- Returns:
- Return type:
Get the presentation type of
WebKit.WebViewwhen created for automation.New in version 2.28.
- get_back_forward_list()¶
- Returns:
- Return type:
Obtains the
WebKit.BackForwardListassociated with the givenWebKit.WebView.The
WebKit.BackForwardListis owned by theWebKit.WebView.
- get_background_color()¶
-
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
WebKit.WebView.set_background_color()New in version 2.8.
- get_camera_capture_state()¶
- Returns:
The
WebKit.MediaCaptureStateof the camera device. IfWebKit.Settings:enable-mediastreamisFalse, this method will returnWebKit.MediaCaptureState.NONE.- Return type:
Get the camera capture state of a
WebKit.WebView.New in version 2.34.
- get_context()¶
- Returns:
the
WebKit.WebContextof the view- Return type:
Gets the web context of self.
- get_custom_charset()¶
- Returns:
the current custom character encoding name or
Noneif no custom character encoding has been set.- Return type:
Returns the current custom character encoding name of self.
- get_default_content_security_policy()¶
-
Gets the configured default Content-Security-Policy.
New in version 2.38.
- get_display_capture_state()¶
- Returns:
The
WebKit.MediaCaptureStateof the display device. IfWebKit.Settings:enable-mediastreamisFalse, this method will returnWebKit.MediaCaptureState.NONE.- Return type:
Get the display capture state of a
WebKit.WebView.New in version 2.34.
- get_editor_state()¶
- Returns:
the
WebKit.EditorStateof the view- Return type:
Gets the web editor state of self.
New in version 2.10.
- get_estimated_load_progress()¶
- Returns:
an estimate of the of the percent complete for a document load as a range from 0.0 to 1.0.
- Return type:
Gets the value of the
WebKit.WebView:estimated-load-progressproperty.You can monitor the estimated progress of a load operation by connecting to the notify::estimated-load-progress signal of self.
- get_favicon()¶
- Returns:
the favicon image or
Noneif there’s no icon associated with self.- Return type:
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.
- get_find_controller()¶
- Returns:
the
WebKit.FindControllerassociated to this particularWebKit.WebView.- Return type:
Gets the
WebKit.FindController.Gets the
WebKit.FindControllerthat will allow the caller to query theWebKit.WebViewfor the text to look for.
- get_input_method_context()¶
- Returns:
- Return type:
Get the
WebKit.InputMethodContextcurrently in use by self.Get the
WebKit.InputMethodContextcurrently in use by self, orNoneif no input method is being used.New in version 2.28.
- get_inspector()¶
- Returns:
the
WebKit.WebInspectorof self- Return type:
Get the
WebKit.WebInspectorassociated to self
- get_is_muted()¶
-
Gets the mute state of self.
New in version 2.30.
- get_is_web_process_responsive()¶
-
Get whether the current web process of a
WebKit.WebViewis responsive.New in version 2.34.
- get_main_resource()¶
- Returns:
the main
WebKit.WebResourceof the view orNoneif nothing has been loaded.- Return type:
Return the main resource of self.
- get_microphone_capture_state()¶
- Returns:
The
WebKit.MediaCaptureStateof the microphone device. IfWebKit.Settings:enable-mediastreamisFalse, this method will returnWebKit.MediaCaptureState.NONE.- Return type:
Get the microphone capture state of a
WebKit.WebView.New in version 2.34.
- get_network_session()¶
- Returns:
- Return type:
Get the
WebKit.NetworkSessionassociated to self.New in version 2.40.
- get_page_id()¶
- Returns:
the page ID of self.
- Return type:
Get the identifier of the #WebKitWebPage corresponding to the
WebKit.WebView
- get_session_state()¶
- Returns:
- Return type:
Gets the current session state of self
New in version 2.12.
- get_settings()¶
- Returns:
the
WebKit.Settingsattached to self- Return type:
Gets the
WebKit.Settingscurrently applied to self.If no other
WebKit.Settingshave been explicitly applied to self withWebKit.WebView.set_settings(), the defaultWebKit.Settingswill be returned. This method always returns a validWebKit.Settingsobject. To modify any of the self settings, you can either create a newWebKit.Settingsobject withWebKit.Settings.new(), setting the desired preferences, and then replace the existing self settings withWebKit.WebView.set_settings() or get the existing self settings and update it directly.WebKit.Settingsobjects can be shared by multipleWebKit.WebViews, so modifying the settings of aWebKit.WebViewwould affect otherWebKit.WebViews using the sameWebKit.Settings.
- get_snapshot(region, options, cancellable, callback, *user_data)¶
- Parameters:
region (
WebKit.SnapshotRegion) – theWebKit.SnapshotRegionfor this snapshotoptions (
WebKit.SnapshotOptions) –WebKit.SnapshotOptionsfor the snapshotcancellable (
Gio.CancellableorNone) – aGio.Cancellablecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallback
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.WebView.get_snapshot_finish() to get the result of the operation.
- get_snapshot_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
an image with the retrieved snapshot, or
Nonein case of error.- Return type:
Finishes an asynchronous operation started with
WebKit.WebView.get_snapshot().
- get_title()¶
- Returns:
The main frame document title of self.
- Return type:
Gets the value of the
WebKit.WebView:titleproperty.You can connect to notify::title signal of self to be notified when the title has been received.
- get_tls_info()¶
- Returns:
Trueif the self connection uses HTTPS and a response has been received from the server, orFalseotherwise.- certificate:
return location for a
Gio.TlsCertificate- errors:
return location for a
Gio.TlsCertificateFlagsthe verification status of certificate
- Return type:
(
bool, certificate:Gio.TlsCertificate, errors:Gio.TlsCertificateFlags)
Retrieves the
Gio.TlsCertificateassociated with the main resource of self.Retrieves the
Gio.TlsCertificateassociated with the main resource of self, and theGio.TlsCertificateFlagsshowing what problems, if any, have been found with that certificate. If the connection is not HTTPS, this function returnsFalse. This function should be called after a response has been received from the server, so you can connect toWebKit.WebView::load-changedand call this function when it’s emitted withWebKit.LoadEvent.COMMITTEDevent.Note that this function provides no information about the security of the web page if the current
WebKit.TLSErrorsPolicyisWebKit.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 currentWebKit.TLSErrorsPolicyisWebKit.TLSErrorsPolicy.FAIL, in which case subresources that fail certificate verification will be blocked.
- get_uri()¶
-
Returns the current active URI of self.
The active URI might change during a load operation:
When nothing has been loaded yet on self the active URI is
None.When a new load operation starts the active URI is the requested URI:
If the load operation was started by
WebKit.WebView.load_uri(), the requested URI is the given one.If the load operation was started by
WebKit.WebView.load_html(), the requested URI is “about:blank”.If the load operation was started by
WebKit.WebView.load_alternate_html(), the requested URI is content URI provided.If the load operation was started by
WebKit.WebView.go_back() orWebKit.WebView.go_forward(), the requested URI is the original URI of the previous/next item in theWebKit.BackForwardListof self.If the load operation was started by
WebKit.WebView.go_to_back_forward_list_item(), the requested URI is the opriginal URI of the givenWebKit.BackForwardListItem.
If there is a server redirection during the load operation, the active URI is the redirected URI. When the signal
WebKit.WebView::load-changedis emitted withWebKit.LoadEvent.REDIRECTEDevent, the active URI is already updated to the redirected URI.When the signal
WebKit.WebView::load-changedis emitted withWebKit.LoadEvent.COMMITTEDevent, 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.You can monitor the active URI by connecting to the notify::uri signal of self.
- get_user_content_manager()¶
- Returns:
the
WebKit.UserContentManagerassociated with the view- Return type:
Gets the user content manager associated to self.
New in version 2.6.
- get_web_extension_mode()¶
- Returns:
- Return type:
Get the view’s
WebKit.WebExtensionMode.New in version 2.38.
- get_website_policies()¶
- Returns:
the default
WebKit.WebsitePoliciesassociated with the view.- Return type:
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
WebKit.WebView::decide-policysignal handler.See also
WebKit.PolicyDecision.use_with_policies().New in version 2.30.
- get_window_properties()¶
- Returns:
the
WebKit.WindowPropertiesof self- Return type:
Get the
WebKit.WindowPropertiesobject.Get the
WebKit.WindowPropertiesobject containing the properties that the window containing self should have.
- get_zoom_level()¶
- Returns:
the current zoom level of self
- Return type:
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.
- go_back()¶
Loads the previous history item.
You can monitor the load operation by connecting to
WebKit.WebView::load-changedsignal.
- go_forward()¶
Loads the next history item.
You can monitor the load operation by connecting to
WebKit.WebView::load-changedsignal.
- go_to_back_forward_list_item(list_item)¶
- Parameters:
list_item (
WebKit.BackForwardListItem) – aWebKit.BackForwardListItem
Loads the specific history item list_item.
You can monitor the load operation by connecting to
WebKit.WebView::load-changedsignal.
- is_controlled_by_automation()¶
-
Get whether a
WebKit.WebViewwas created withWebKit.WebView:is-controlled-by-automationproperty enabled.Only
WebKit.WebViews controlled by automation can be used in an automation session.New in version 2.18.
- is_editable()¶
-
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
WebKit.WebViewis not editable.New in version 2.8.
- is_loading()¶
-
Gets the value of the
WebKit.WebView:is-loadingproperty.You can monitor when a
WebKit.WebViewis 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.
- is_playing_audio()¶
-
Gets the value of the
WebKit.WebView:is-playing-audioproperty.You can monitor when a page in a
WebKit.WebViewis 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.New in version 2.8.
- load_alternate_html(content, content_uri, base_uri)¶
- Parameters:
Load the given content string for the URI content_uri.
This allows clients to display page-loading errors in the
WebKit.WebViewitself. When this method is called fromWebKit.WebView::load-failedsignal to show an error page, then the back-forward list is maintained appropriately. For everything else this method works the same way asWebKit.WebView.load_html().
- load_bytes(bytes, mime_type, encoding, base_uri)¶
- Parameters:
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 isNone, it defaults to “UTF-8”. When base_uri isNone, it defaults to “about:blank”. You can monitor the load operation by connecting toWebKit.WebView::load-changedsignal.New in version 2.6.
- load_html(content, base_uri)¶
- Parameters:
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 isNone, it defaults to “about:blank”. The mime type of the document will be “text/html”. You can monitor the load operation by connecting toWebKit.WebView::load-changedsignal.
- load_plain_text(plain_text)¶
- Parameters:
plain_text (
str) – The plain text to load
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
WebKit.WebView::load-changedsignal.
- load_request(request)¶
- Parameters:
request (
WebKit.URIRequest) – aWebKit.URIRequestto load
Requests loading of the specified
WebKit.URIRequest.You can monitor the load operation by connecting to
WebKit.WebView::load-changedsignal.
- load_uri(uri)¶
- Parameters:
uri (
str) – an URI string
Requests loading of the specified URI string.
You can monitor the load operation by connecting to
WebKit.WebView::load-changedsignal.
- reload()¶
Reloads the current contents of self.
See also
WebKit.WebView.reload_bypass_cache().
- reload_bypass_cache()¶
Reloads the current contents of self without using any cached data.
- restore_session_state(state)¶
- Parameters:
state (
WebKit.WebViewSessionState) – aWebKit.WebViewSessionState
Restore the self session state from state
New in version 2.12.
- save(save_mode, cancellable, callback, *user_data)¶
- Parameters:
save_mode (
WebKit.SaveMode) – theWebKit.SaveModespecifying how the web page should be saved.cancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
Asynchronously save the current web page.
Asynchronously save the current web page associated to the
WebKit.WebViewinto 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.WebView.save_finish() to get the result of the operation.
- save_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
a
Gio.InputStreamwith the result of saving the current web page orNonein case of error.- Return type:
Finish an asynchronous operation started with
WebKit.WebView.save().
- save_to_file(file, save_mode, cancellable, callback, *user_data)¶
- Parameters:
file (
Gio.File) – theGio.Filewhere the current web page should be saved to.save_mode (
WebKit.SaveMode) – theWebKit.SaveModespecifying how the web page should be saved.cancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – aGio.AsyncReadyCallbackto call when the request is satisfieduser_data (
objectorNone) – the data to pass to callback function
Asynchronously save the current web page.
Asynchronously save the current web page associated to the
WebKit.WebViewinto 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.WebView.save_to_file_finish() to get the result of the operation.
- save_to_file_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
Trueif the web page was successfully saved to a file orFalseotherwise.- Return type:
Finish an asynchronous operation started with
WebKit.WebView.save_to_file().
- send_message_to_page(message, cancellable, callback, *user_data)¶
- Parameters:
message (
WebKit.UserMessage) – aWebKit.UserMessagecancellable (
Gio.CancellableorNone) – aGio.CancellableorNoneto ignorecallback (
Gio.AsyncReadyCallbackorNone) – (nullable): AGio.AsyncReadyCallbackto call when the request is satisfied orNoneuser_data (
objectorNone) – the data to pass to callback function
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
Noneas callback. When the operation is finished, callback will be called. You can then callWebKit.WebView.send_message_to_page_finish() to get the message reply.New in version 2.28.
- send_message_to_page_finish(result)¶
- Parameters:
result (
Gio.AsyncResult) – aGio.AsyncResult- Raises:
- Returns:
a
WebKit.UserMessagewith the reply orNonein case of error.- Return type:
Finish an asynchronous operation started with
WebKit.WebView.send_message_to_page().New in version 2.28.
- set_background_color(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.
New in version 2.8.
- set_camera_capture_state(state)¶
- Parameters:
state (
WebKit.MediaCaptureState) – aWebKit.MediaCaptureState
Set the camera capture state of a
WebKit.WebView.If
WebKit.Settings:enable-mediastreamisFalse, this method will have no visible effect. Once the state of the device has been set toWebKit.MediaCaptureState.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.New in version 2.34.
- set_cors_allowlist(allowlist)¶
-
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.
New in version 2.34.
- set_custom_charset(charset)¶
-
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
Noneremoves the character encoding override.
- set_display_capture_state(state)¶
- Parameters:
state (
WebKit.MediaCaptureState) – aWebKit.MediaCaptureState
Set the display capture state of a
WebKit.WebView.If
WebKit.Settings:enable-mediastreamisFalse, this method will have no visible effect. Once the state of the device has been set toWebKit.MediaCaptureState.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.New in version 2.34.
- set_editable(editable)¶
-
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 isFalse, 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 aWebKit.WebViewis 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
WebKit.WebVieweditable without altering the document or DOM structure.New in version 2.8.
- set_input_method_context(context)¶
- Parameters:
context (
WebKit.InputMethodContextorNone) – theWebKit.InputMethodContextto set, orNone
Set the
WebKit.InputMethodContextto be used by self.Set the
WebKit.InputMethodContextto be used by self, orNoneto not use any input method. Note that the sameWebKit.InputMethodContextcan’t be set on more than oneWebKit.WebViewat the same time.New in version 2.28.
- set_is_muted(muted)¶
- Parameters:
muted (
bool) – mute flag
Sets the mute state of self.
New in version 2.30.
- set_microphone_capture_state(state)¶
- Parameters:
state (
WebKit.MediaCaptureState) – aWebKit.MediaCaptureState
Set the microphone capture state of a
WebKit.WebView.If
WebKit.Settings:enable-mediastreamisFalse, this method will have no visible effect. Once the state of the device has been set toWebKit.MediaCaptureState.NONEit cannot be changed anymore. The page can however request capture again using the mediaDevices API.New in version 2.34.
- set_settings(settings)¶
- Parameters:
settings (
WebKit.Settings) – aWebKit.Settings
Sets the
WebKit.Settingsto be applied to self.The existing
WebKit.Settingsof self will be replaced by settings. New settings are applied immediately on self. The sameWebKit.Settingsobject can be shared by multipleWebKit.WebViews.
- set_zoom_level(zoom_level)¶
- Parameters:
zoom_level (
float) – the zoom level
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.
- stop_loading()¶
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
WebKit.WebView::load-failedsignal will be emitted withWebKit.NetworkError.CANCELLEDerror.
- terminate_web_process()¶
Terminates the web process associated to self.
When the web process gets terminated using this method, the
WebKit.WebView::web-process-terminatedsignal is emitted withWebKit.WebProcessTerminationReason.TERMINATED_BY_APIas the reason for termination.New in version 2.34.
- try_close()¶
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
WebKit.WebView::closesignal is emitted, otherwise nothing happens.New in version 2.12.
- do_authenticate(request) virtual¶
- Parameters:
request (
WebKit.AuthenticationRequest) –- Return type:
- do_close() virtual¶
- Parameters:
context_menu (
WebKit.ContextMenu) –hit_test_result (
WebKit.HitTestResult) –
- Return type:
- do_decide_policy(decision, type) virtual¶
- Parameters:
decision (
WebKit.PolicyDecision) –type (
WebKit.PolicyDecisionType) –
- Return type:
- do_insecure_content_detected(event) virtual¶
- Parameters:
event (
WebKit.InsecureContentEvent) –
- do_load_changed(load_event) virtual¶
- Parameters:
load_event (
WebKit.LoadEvent) –
- do_load_failed(load_event, failing_uri, error) virtual¶
- Parameters:
load_event (
WebKit.LoadEvent) –failing_uri (
str) –error (
GLib.Error) –
- Return type:
- do_load_failed_with_tls_errors(failing_uri, certificate, errors) virtual¶
- Parameters:
failing_uri (
str) –certificate (
Gio.TlsCertificate) –errors (
Gio.TlsCertificateFlags) –
- Return type:
- do_mouse_target_changed(hit_test_result, modifiers) virtual¶
- Parameters:
hit_test_result (
WebKit.HitTestResult) –modifiers (
int) –
- do_permission_request(permission_request) virtual¶
- Parameters:
permission_request (
WebKit.PermissionRequest) –- Return type:
- do_print_(print_operation) virtual¶
- Parameters:
print_operation (
WebKit.PrintOperation) –- Return type:
- do_query_permission_state(query) virtual¶
- Parameters:
query (
WebKit.PermissionStateQuery) –- Return type:
- do_ready_to_show() virtual¶
- do_resource_load_started(resource, request) virtual¶
- Parameters:
resource (
WebKit.WebResource) –request (
WebKit.URIRequest) –
- do_run_as_modal() virtual¶
- do_run_color_chooser(request) virtual¶
- Parameters:
request (
WebKit.ColorChooserRequest) –- Return type:
- do_run_file_chooser(request) virtual¶
- Parameters:
request (
WebKit.FileChooserRequest) –- Return type:
- do_script_dialog(dialog) virtual¶
- Parameters:
dialog (
WebKit.ScriptDialog) –- Return type:
- do_show_notification(notification) virtual¶
- Parameters:
notification (
WebKit.Notification) –- Return type:
- Parameters:
menu (
WebKit.OptionMenu) –rectangle (
Gdk.Rectangle) –
- Return type:
- do_submit_form(request) virtual¶
- Parameters:
request (
WebKit.FormSubmissionRequest) –
- do_user_message_received(message) virtual¶
- Parameters:
message (
WebKit.UserMessage) –- Return type:
- do_web_process_terminated(reason) virtual¶
- Parameters:
reason (
WebKit.WebProcessTerminationReason) –
Signal Details¶
- WebKit.WebView.signals.authenticate(web_view, request)¶
- Signal Name:
authenticate- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalrequest (
WebKit.AuthenticationRequest) – aWebKit.AuthenticationRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.AuthenticationRequestin the request argument. To handle this signal asynchronously you should keep a ref of the request and returnTrue. To disable HTTP authentication entirely, connect to this signal and simply returnTrue.The default signal handler will run a default authentication dialog asynchronously for the user to interact with.
New in version 2.2.
- WebKit.WebView.signals.close(web_view)¶
- Signal Name:
close- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signal
Emitted when closing a
WebKit.WebViewis requested. This occurs when a call is made from JavaScript’s window.close function or after trying to close the web_view withWebKit.WebView.try_close(). It is the owner’s responsibility to handle this signal to hide or destroy theWebKit.WebView, if necessary.
- Signal Name:
context-menu- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalcontext_menu (
WebKit.ContextMenu) – the proposedWebKit.ContextMenuhit_test_result (
WebKit.HitTestResult) – aWebKit.HitTestResult
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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.
To customize the proposed menu you can use
WebKit.ContextMenu.prepend(),WebKit.ContextMenu.append() orWebKit.ContextMenu.insert() to add newWebKit.ContextMenuItems to context_menu,WebKit.ContextMenu.move_item() to reorder existing items, orWebKit.ContextMenu.remove() to remove an existing item. The signal handler should returnFalse, and the menu represented by context_menu will be shown.To prevent the menu from being displayed you can just connect to this signal and return
Trueso that the proposed menu will not be shown.To build your own menu, you can remove all items from the proposed menu with
WebKit.ContextMenu.remove_all(), add your own items and returnFalseso that the menu will be shown. You can also ignore the proposedWebKit.ContextMenu, build your own #GtkMenu and returnTrueto prevent the proposed menu from being shown.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.
If the signal handler returns
Falsethe context menu represented by context_menu will be shown, if it returnTruethe context menu will not be shown.The proposed
WebKit.ContextMenupassed in context_menu argument is only valid during the signal emission.
- Signal Name:
context-menu-dismissed- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signal
Emitted after
WebKit.WebView::context-menusignal, if the context menu is shown, to notify that the context menu is dismissed.
- WebKit.WebView.signals.create(web_view, navigation_action)¶
- Signal Name:
create- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalnavigation_action (
WebKit.NavigationAction) – aWebKit.NavigationAction
- Returns:
a newly allocated
WebKit.WebViewwidget orNoneto propagate the event further.- Return type:
Emitted when the creation of a new
WebKit.WebViewis requested. If this signal is handled the signal handler should return the newly createdWebKit.WebView.The
WebKit.NavigationActionparameter contains information about the navigation action that triggered this signal.The new
WebKit.WebViewmust be related to web_view, seeWebKit.WebView:related-viewfor more details.The new
WebKit.WebViewshould not be displayed to the user until theWebKit.WebView::ready-to-showsignal is emitted.For creating views as response to automation tools requests, see the
WebKit.AutomationSession::create-web-viewsignal.
- WebKit.WebView.signals.decide_policy(web_view, decision, decision_type)¶
- Signal Name:
decide-policy- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signaldecision (
WebKit.PolicyDecision) – theWebKit.PolicyDecisiondecision_type (
WebKit.PolicyDecisionType) – aWebKit.PolicyDecisionTypedenoting the type of decision
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.NavigationPolicyDecisionpassed in the decision argument is a generic type, but should be casted to a more specific type when making the decision. For example:``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
GObject.Object.ref() on the decision argument and returningTrueto block the default signal handler. If the last reference is removed on aWebKit.PolicyDecisionand no decision has been made explicitly,WebKit.PolicyDecision.use() will be the default policy decision. The default signal handler will simply callWebKit.PolicyDecision.use(). Only the first policy decision chosen for a givenWebKit.PolicyDecisionwill have any affect.
- WebKit.WebView.signals.enter_fullscreen(web_view)¶
- Signal Name:
enter-fullscreen- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signal- Returns:
Trueto stop other handlers from being invoked for the event.Falseto continue emission of the event.- Return type:
Emitted when JavaScript code calls element.webkitRequestFullScreen. If the signal is not handled the
WebKit.WebViewwill 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).
- WebKit.WebView.signals.insecure_content_detected(web_view, event)¶
- Signal Name:
insecure-content-detected- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalevent (
WebKit.InsecureContentEvent) – theWebKit.InsecureContentEvent
Prior to 2.46, this signal was emitted when insecure content was loaded in a secure content. Since 2.46, this signal is generally no longer emitted.
Deprecated since version 2.46.
- WebKit.WebView.signals.leave_fullscreen(web_view)¶
- Signal Name:
leave-fullscreen- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signal- Returns:
Trueto stop other handlers from being invoked for the event.Falseto continue emission of the event.- Return type:
Emitted when the
WebKit.WebViewis 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 theWebKit.WebView::enter-fullscreenstage for instance.
- WebKit.WebView.signals.load_changed(web_view, load_event)¶
- Signal Name:
load-changed- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalload_event (
WebKit.LoadEvent) – theWebKit.LoadEvent
Emitted when a load operation in web_view changes. The signal is always emitted with
WebKit.LoadEvent.STARTEDwhen a new load request is made andWebKit.LoadEvent.FINISHEDwhen the load finishes successfully or due to an error. When the ongoing load operation failsWebKit.WebView::load-failedsignal is emitted beforeWebKit.WebView::load-changedis emitted withWebKit.LoadEvent.FINISHED. If a redirection is received from the server, this signal is emitted withWebKit.LoadEvent.REDIRECTEDafter the initial emission withWebKit.LoadEvent.STARTEDand beforeWebKit.LoadEvent.COMMITTED. When the page content starts arriving the signal is emitted withWebKit.LoadEvent.COMMITTEDevent.You can handle this signal and use a switch to track any ongoing load operation.
``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;
}
}¶
- WebKit.WebView.signals.load_failed(web_view, load_event, failing_uri, error)¶
- Signal Name:
load-failed- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalload_event (
WebKit.LoadEvent) – theWebKit.LoadEventof the load operationfailing_uri (
str) – the URI that failed to loaderror (
GLib.Error) – theGLib.Errorthat was triggered
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.LoadEvent.STARTED. If it happened while loading a committed data source load_event will beWebKit.LoadEvent.COMMITTED. Since a load error causes the load operation to finish, the signalWebKit.WebView::load-changedwill always be emitted withWebKit.LoadEvent.FINISHEDevent 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.
- WebKit.WebView.signals.load_failed_with_tls_errors(web_view, failing_uri, certificate, errors)¶
- Signal Name:
load-failed-with-tls-errors- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalfailing_uri (
str) – the URI that failed to loadcertificate (
Gio.TlsCertificate) – aGio.TlsCertificateerrors (
Gio.TlsCertificateFlags) – aGio.TlsCertificateFlagswith the verification status of certificate
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
GObject.Object.ref() on certificate and returnTrue.If
Falseis returned,WebKit.WebView::load-failedwill be emitted. The load will finish regardless of the returned value.New in version 2.6.
- WebKit.WebView.signals.mouse_target_changed(web_view, hit_test_result, modifiers)¶
- Signal Name:
mouse-target-changed- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalhit_test_result (
WebKit.HitTestResult) – aWebKit.HitTestResultmodifiers (
int) – a bitmask ofGdk.ModifierType
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
Gdk.ModifierTypeflags 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.
- WebKit.WebView.signals.permission_request(web_view, request)¶
- Signal Name:
permission-request- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalrequest (
WebKit.PermissionRequest) – theWebKit.PermissionRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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:
```c static
boolpermission_request_cb (WebKit.WebView*web_view,WebKit.PermissionRequest*request,Gtk.Window*parent_window) {Gtk.Widget*dialog = gtk_message_dialog_new (parent_window,Gtk.DialogFlags.MODAL,Gtk.MessageType.QUESTION,Gtk.ButtonsType.YES_NO, “Allow Permission Request?”);Gtk.Widget.show(dialog);intresult = gtk_dialog_run (GTK_DIALOG (dialog));switch (result) { case
Gtk.ResponseType.YES:WebKit.PermissionRequest.allow(request); break; default:WebKit.PermissionRequest.deny(request); break; } gtk_widget_destroy (dialog);return
True; } ```It is possible to handle permission requests asynchronously, by simply calling
GObject.Object.ref() on the request argument and returningTrueto block the default signal handler. If the last reference is removed on aWebKit.PermissionRequestand the request has not been handled,WebKit.PermissionRequest.deny() will be the default action.If the signal is not handled, the request will be completed automatically by the specific
WebKit.PermissionRequestthat could allow or deny it. Check the documentation of classes implementingWebKit.PermissionRequestinterface to know their default action.
- WebKit.WebView.signals.print_(web_view, print_operation)¶
- Signal Name:
print- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalprint_operation (
WebKit.PrintOperation) – theWebKit.PrintOperationthat will handle the print request
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.PrintOperation.set_print_settings() andWebKit.PrintOperation.set_page_setup() and then returnFalseto propagate the event so that the print dialog is shown.You can connect to this signal and return
Trueto cancel the print operation or implement your own print dialog.
- WebKit.WebView.signals.query_permission_state(web_view, query)¶
- Signal Name:
query-permission-state- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalquery (
WebKit.PermissionStateQuery) – theWebKit.PermissionStateQuery
- Returns:
- Return type:
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
WebKit.PermissionStateQuery.finish().You can handle the query asynchronously by calling
WebKit.PermissionStateQuery.ref() on query and returningTrue. 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.New in version 2.40.
- WebKit.WebView.signals.ready_to_show(web_view)¶
- Signal Name:
ready-to-show- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signal
Emitted after
WebKit.WebView::createon the newly createdWebKit.WebViewwhen 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 theWebKit.WindowPropertiesof web_view. See alsoWebKit.WebView.get_window_properties().
- WebKit.WebView.signals.resource_load_started(web_view, resource, request)¶
- Signal Name:
resource-load-started- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalresource (
WebKit.WebResource) – aWebKit.WebResourcerequest (
WebKit.URIRequest) – aWebKit.URIRequest
Emitted when a new resource is going to be loaded. The request parameter contains the
WebKit.URIRequestthat will be sent to the server. You can monitor the load operation by connecting to the different signals of resource.
- WebKit.WebView.signals.run_as_modal(web_view)¶
- Signal Name:
run-as-modal- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signal
Emitted after
WebKit.WebView::ready-to-showon the newly createdWebKit.WebViewwhen JavaScript code calls window.showModalDialog. 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 parentWebKit.WebViewuntil the new dialog is closed.
- WebKit.WebView.signals.run_color_chooser(web_view, request)¶
- Signal Name:
run-color-chooser- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalrequest (
WebKit.ColorChooserRequest) – aWebKit.ColorChooserRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.ColorChooserRequestin 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
Gtk.ColorChooserfor the user to interact with.New in version 2.8.
- WebKit.WebView.signals.run_file_chooser(web_view, request)¶
- Signal Name:
run-file-chooser- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalrequest (
WebKit.FileChooserRequest) – aWebKit.FileChooserRequest
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.FileChooserRequestin the request argument.The default signal handler will asynchronously run a regular
Gtk.FileChooserDialogfor the user to interact with.
- WebKit.WebView.signals.script_dialog(web_view, dialog)¶
- Signal Name:
script-dialog- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signaldialog (
WebKit.ScriptDialog) – theWebKit.ScriptDialogto show
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
Emitted when JavaScript code calls window.alert, window.confirm or window.prompt, or when onbeforeunload 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:
WebKit.ScriptDialogType.ALERT: message dialog with a single Close button.WebKit.ScriptDialogType.CONFIRM: message dialog with OK and Cancel buttons.WebKit.ScriptDialogType.PROMPT: message dialog with OK and Cancel buttons and a text entry with the default text.WebKit.ScriptDialogType.BEFORE_UNLOAD_CONFIRM: message dialog with Stay and Leave buttons.
It is possible to handle the script dialog request asynchronously, by simply caling
WebKit.ScriptDialog.ref() on the dialog argument and callingWebKit.ScriptDialog.close() when done. If the last reference is removed on aWebKit.ScriptDialogand the dialog has not been closed,WebKit.ScriptDialog.close() will be called.
- WebKit.WebView.signals.show_notification(web_view, notification)¶
- Signal Name:
show-notification- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalnotification (
WebKit.Notification) – aWebKit.Notification
- Returns:
Trueto stop other handlers from being invoked.Falseotherwise.- Return type:
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.
New in version 2.8.
- Signal Name:
show-option-menu- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalmenu (
WebKit.OptionMenu) – theWebKit.OptionMenurectangle (
Gdk.Rectangle) – the option element area
- Returns:
Trueto stop other handlers from being invoked for the event.Falseto propagate the event further.- Return type:
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
WebKit.WebViewis 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.
New in version 2.18.
- WebKit.WebView.signals.submit_form(web_view, request)¶
- Signal Name:
submit-form- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalrequest (
WebKit.FormSubmissionRequest) – aWebKit.FormSubmissionRequest
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
WebKit.FormSubmissionRequest.submit() is called.It is possible to handle the form submission request asynchronously, by simply calling
GObject.Object.ref() on the request argument and callingWebKit.FormSubmissionRequest.submit() when done to continue with the form submission. If the last reference is removed on aWebKit.FormSubmissionRequestand the form has not been submitted,WebKit.FormSubmissionRequest.submit() will be called.
- WebKit.WebView.signals.user_message_received(web_view, message)¶
- Signal Name:
user-message-received- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalmessage (
WebKit.UserMessage) – theWebKit.UserMessagereceived
- Returns:
- Return type:
This signal is emitted when a
WebKit.UserMessageis received from the #WebKitWebPage corresponding to web_view. You can reply to the message usingWebKit.UserMessage.send_reply().You can handle the user message asynchronously by calling
GObject.Object.ref() on message and returningTrue. If the last reference of message is removed and the message has not been replied to, the operation in the #WebKitWebPage will finish with errorWebKit.UserMessageError.MESSAGE.New in version 2.28.
- WebKit.WebView.signals.web_process_terminated(web_view, reason)¶
- Signal Name:
web-process-terminated- Flags:
- Parameters:
web_view (
WebKit.WebView) – The object which received the signalreason (
WebKit.WebProcessTerminationReason) – the aWebKit.WebProcessTerminationReason
This signal is emitted when the web process terminates abnormally due to reason.
New in version 2.20.
Property Details¶
- WebKit.WebView.props.automation_presentation_type¶
- Name:
automation-presentation-type- Type:
- Default Value:
- Flags:
The
WebKit.AutomationBrowsingContextPresentationofWebKit.WebView. This should only be used when creating a newWebKit.WebViewas a response toWebKit.AutomationSession::create-web-viewsignal request. If the new WebView was added to a new tab of current browsing context windowWebKit.AutomationBrowsingContextPresentation.TABshould be used.New in version 2.28.
- WebKit.WebView.props.camera_capture_state¶
- Name:
camera-capture-state- Type:
- Default Value:
- Flags:
Capture state of the camera device. Whenever the user grants a media-request sent by the web page, requesting video capture capabilities (
navigator.mediaDevices.getUserMedia({video: true})) this property will be set toWebKit.MediaCaptureState.ACTIVE.The application can monitor this property and provide a visual indicator allowing to optionally deactivate or mute the capture device by setting this property respectively to
WebKit.MediaCaptureState.NONEorWebKit.MediaCaptureState.MUTED.If the capture state of the device is set to
WebKit.MediaCaptureState.NONEthe web-page can still re-request the permission to the user. Permission desision caching is left to the application.New in version 2.34.
- WebKit.WebView.props.default_content_security_policy¶
- Name:
default-content-security-policy- Type:
- Default Value:
- Flags:
The default Content-Security-Policy used by the webview as if it were set by an HTTP header.
This applies to all content loaded including through navigation or via the various webkit_web_view_load_\* APIs. However do note that many WebKit APIs bypass Content-Security-Policy in general such as
WebKit.UserContentManagerand webkit_web_view_run_javascript().Policies are additive so if a website sets its own policy it still applies on top of the policy set here.
New in version 2.38.
- WebKit.WebView.props.display_capture_state¶
- Name:
display-capture-state- Type:
- Default Value:
- Flags:
Capture state of the display device. Whenever the user grants a media-request sent by the web page, requesting screencasting capabilities (`navigator.mediaDevices.getDisplayMedia() this property will be set to
WebKit.MediaCaptureState.ACTIVE.The application can monitor this property and provide a visual indicator allowing to optionally deactivate or mute the capture device by setting this property respectively to
WebKit.MediaCaptureState.NONEorWebKit.MediaCaptureState.MUTED.If the capture state of the device is set to
WebKit.MediaCaptureState.NONEthe web-page can still re-request the permission to the user. Permission desision caching is left to the application.New in version 2.34.
- WebKit.WebView.props.editable¶
-
Whether the pages loaded inside
WebKit.WebVieware editable. For more information seeWebKit.WebView.set_editable().New in version 2.8.
- WebKit.WebView.props.estimated_load_progress¶
-
An estimate of the percent completion for the current loading operation. This value will range from 0.0 to 1.0 and, once a load completes, will remain at 1.0 until a new load starts, at which point it will be reset to 0.0. The value is an estimate based on the total number of bytes expected to be received for a document, including all its possible subresources and child documents.
- WebKit.WebView.props.favicon¶
- Name:
favicon- Type:
- Default Value:
- Flags:
The favicon currently associated to the
WebKit.WebView. SeeWebKit.WebView.get_favicon() for more details.
- WebKit.WebView.props.is_controlled_by_automation¶
- Name:
is-controlled-by-automation- Type:
- Default Value:
- Flags:
Whether the
WebKit.WebViewis controlled by automation tools (e.g. WebDriver, Selenium). This is required for views returned as a response toWebKit.AutomationSession::create-web-viewsignal, alongside any view you want to control during an automation session.As a
GObject.ParamFlags.CONSTRUCT_ONLY, you need to set it during construction and it can’t be modified.If
WebKit.WebView:related-viewis also passed during construction,WebKit.WebView:is-controlled-by-automationignores its own parameter and inherits directly from the related viewWebKit.WebView:is-controlled-by-automationproperty. This is the recommended way when creating new views as a response to theWebKit.WebView::createsignal. For example, as response to JavaScriptwindow.open()calls during an automation session.New in version 2.18.
- WebKit.WebView.props.is_loading¶
-
Whether the
WebKit.WebViewis currently loading a page. This property becomesTrueas soon as a new load operation is requested and before theWebKit.WebView::load-changedsignal is emitted withWebKit.LoadEvent.STARTEDand at that point the active URI is the requested one. When the load operation finishes the property is set toFalsebeforeWebKit.WebView::load-changedis emitted withWebKit.LoadEvent.FINISHED.
- WebKit.WebView.props.is_muted¶
-
Whether the
WebKit.WebViewaudio is muted. WhenTrue, audio is silenced. It may still be playing, i.e.WebKit.WebView:is-playing-audiomay beTrue.New in version 2.30.
- WebKit.WebView.props.is_playing_audio¶
-
Whether the
WebKit.WebViewis currently playing audio from a page. This property becomesTrueas soon as web content starts playing any kind of audio. When a page is no longer playing any kind of sound, the property is set back toFalse.New in version 2.8.
- WebKit.WebView.props.is_web_process_responsive¶
-
Whether the web process currently associated to the
WebKit.WebViewis responsive.New in version 2.34.
- WebKit.WebView.props.microphone_capture_state¶
- Name:
microphone-capture-state- Type:
- Default Value:
- Flags:
Capture state of the microphone device. Whenever the user grants a media-request sent by the web page, requesting audio capture capabilities (
navigator.mediaDevices.getUserMedia({audio: true})) this property will be set toWebKit.MediaCaptureState.ACTIVE.The application can monitor this property and provide a visual indicator allowing to optionally deactivate or mute the capture device by setting this property respectively to
WebKit.MediaCaptureState.NONEorWebKit.MediaCaptureState.MUTED.If the capture state of the device is set to
WebKit.MediaCaptureState.NONEthe web-page can still re-request the permission to the user. Permission desision caching is left to the application.New in version 2.34.
- WebKit.WebView.props.network_session¶
- Name:
network-session- Type:
- Default Value:
- Flags:
The
WebKit.NetworkSessionof the viewNew in version 2.40.
- WebKit.WebView.props.page_id¶
-
The identifier of the #WebKitWebPage corresponding to the
WebKit.WebView.New in version 2.28.
- Name:
related-view- Type:
- Default Value:
- Flags:
The related
WebKit.WebViewused when creating the view to share the same web process and network session. This property is not readable because the related web view is only valid during the object construction.New in version 2.4.
- WebKit.WebView.props.settings¶
- Name:
settings- Type:
- Default Value:
- Flags:
The
WebKit.Settingsof the view.New in version 2.6.
- WebKit.WebView.props.title¶
-
The main frame document title of this
WebKit.WebView. If the title has not been received yet, it will beNone.
- WebKit.WebView.props.uri¶
-
The current active URI of the
WebKit.WebView. SeeWebKit.WebView.get_uri() for more details.
- WebKit.WebView.props.user_content_manager¶
- Name:
user-content-manager- Type:
- Default Value:
- Flags:
The
WebKit.UserContentManagerof the view.New in version 2.6.
- WebKit.WebView.props.web_context¶
- Name:
web-context- Type:
- Default Value:
- Flags:
The
WebKit.WebContextof the view.
- WebKit.WebView.props.web_extension_mode¶
- Name:
web-extension-mode- Type:
- Default Value:
- Flags:
This configures web_view to treat the content as a WebExtension.
Note that this refers to the web standard WebExtensions and not WebKitWebExtensions.
In practice this limits the Content-Security-Policies that are allowed to be set. Some details can be found in Chrome’s documentation.
New in version 2.38.
- WebKit.WebView.props.website_policies¶
- Name:
website-policies- Type:
- Default Value:
- Flags:
The
WebKit.WebsitePoliciesfor the view.New in version 2.30.
- WebKit.WebView.props.zoom_level¶
-
The zoom level of the
WebKit.WebViewcontent. SeeWebKit.WebView.set_zoom_level() for more details.