Settings
Superclasses: Object
Control the behaviour of a WebView
.
Settings
can be applied to a WebView
to control text charset,
color, font sizes, printing mode, script support, loading of images and various
other things on a WebView
. After creation, a Settings
object
contains default settings.
// Disable JavaScript
WebKitSettings *settings = webkit_web_view_group_get_settings (my_view_group);
webkit_settings_set_enable_javascript (settings, FALSE);
Constructors
Methods
- class Settings
- font_size_to_pixels(points: int) int
Convert
points
to the equivalent value in pixels.Convert
points
to the equivalent value in pixels, based on the current screen DPI. Applications can use this function to convert font size values in points to font size values in pixels when setting the font size properties ofSettings
.Added in version 2.20.
- Parameters:
points – the font size in points to convert to pixels
- font_size_to_points(pixels: int) int
Convert
pixels
to the equivalent value in points.Convert
pixels
to the equivalent value in points, based on the current screen DPI. Applications can use this function to convert font size values in pixels to font size values in points when getting the font size properties ofSettings
.Added in version 2.20.
- Parameters:
pixels – the font size in pixels to convert to points
- get_all_features() FeatureList
Gets the list of all available WebKit features.
Features can be toggled with
set_feature_enabled
, and their current state determined withget_feature_enabled
.Note that most applications should use
get_development_features
andget_experimental_features
instead.Added in version 2.42.
- get_allow_file_access_from_file_urls() bool
Get the
Settings
:allow-file-access-from-file-urls property.Added in version 2.10.
Get the
Settings
:allow-top-navigation-to-data-urls property.Added in version 2.28.
- get_allow_universal_access_from_file_urls() bool
Get the
Settings
:allow-universal-access-from-file-urls property.Added in version 2.14.
- get_development_features() FeatureList
Gets the list of available development WebKit features.
The returned features are a subset of those returned by
get_all_features
, and includes those which web and WebKit developers might find useful, but in general should not be exposed to end users; seeFeatureStatus
for more details.Added in version 2.42.
- get_disable_web_security() bool
Get the
Settings
:disable-web-security property.Added in version 2.40.
Get the
Settings
:enable-back-forward-navigation-gestures property.Added in version 2.24.
- get_enable_encrypted_media() bool
Get the
Settings
:enable-encrypted-media property.Added in version 2.20.
- get_enable_javascript_markup() bool
Get the
Settings
:enable-javascript-markup property.Added in version 2.24.
- get_enable_media_capabilities() bool
Get the
Settings
:enable-media-capabilities property.Added in version 2.22.
- get_enable_media_stream() bool
Get the
Settings
:enable-media-stream property.Added in version 2.4.
- get_enable_mock_capture_devices() bool
Get the
Settings
:enable-mock-capture-devices property.Added in version 2.24.
- get_enable_offline_web_application_cache() bool
Get the
Settings
:enable-offline-web-application-cache property.Deprecated since version 2.44: Please do not use it in newly written code
Get the
Settings
:enable-spatial-navigation property.Added in version 2.2.
- get_enable_webrtc() bool
Get the
enable_webrtc
property.Added in version 2.38.
- get_enable_write_console_messages_to_stdout() bool
Get the
Settings
:enable-write-console-messages-to-stdout property.Added in version 2.2.
- get_experimental_features() FeatureList
Gets the list of available experimental WebKit features.
The returned features are a subset of those returned by
get_all_features
, and includes those which certain applications may want to expose to end users; seeFeatureStatus
for more details.Added in version 2.42.
- get_feature_enabled(feature: Feature) bool
Gets whether a feature is enabled.
Added in version 2.42.
- Parameters:
feature – the feature to toggle.
- get_hardware_acceleration_policy() HardwareAccelerationPolicy
Get the
Settings
:hardware-acceleration-policy property.Added in version 2.16.
- get_javascript_can_access_clipboard() bool
Get the
Settings
:javascript-can-access-clipboard property.
- get_javascript_can_open_windows_automatically() bool
Get the
Settings
:javascript-can-open-windows-automatically property.
- get_load_icons_ignoring_image_load_setting() bool
Setting no longer supported. This function returns
False
.Deprecated since version 2.42: Please do not use it in newly written code
- get_media_content_types_requiring_hardware_support() str
Gets the
Settings
:media-content-types-requiring-hardware-support property.Added in version 2.30.
- get_media_playback_requires_user_gesture() bool
Get the
Settings
:media-playback-requires-user-gesture property.
- set_allow_file_access_from_file_urls(allowed: bool) None
Set the
Settings
:allow-file-access-from-file-urls property.Added in version 2.10.
- Parameters:
allowed – Value to be set
- set_allow_modal_dialogs(allowed: bool) None
Set the
Settings
:allow-modal-dialogs property.- Parameters:
allowed – Value to be set
Set the
Settings
:allow-top-navigation-to-data-urls property.Added in version 2.28.
- Parameters:
allowed – Value to be set
- set_allow_universal_access_from_file_urls(allowed: bool) None
Set the
Settings
:allow-universal-access-from-file-urls property.Added in version 2.14.
- Parameters:
allowed – Value to be set
- set_auto_load_images(enabled: bool) None
Set the
Settings
:auto-load-images property.- Parameters:
enabled – Value to be set
- set_cursive_font_family(cursive_font_family: str) None
Set the
Settings
:cursive-font-family property.- Parameters:
cursive_font_family – the new default cursive font family
- set_default_charset(default_charset: str) None
Set the
Settings
:default-charset property.- Parameters:
default_charset – default charset to be set
- set_default_font_family(default_font_family: str) None
Set the
Settings
:default-font-family property.- Parameters:
default_font_family – the new default font family
- set_default_font_size(font_size: int) None
Set the
Settings
:default-font-size property.- Parameters:
font_size – default font size to be set in pixels
- set_default_monospace_font_size(font_size: int) None
Set the
Settings
:default-monospace-font-size property.- Parameters:
font_size – default monospace font size to be set in pixels
- set_disable_web_security(disabled: bool) None
Set the
Settings
:disable-web-security property.Added in version 2.40.
- Parameters:
disabled – Value to be set
- set_draw_compositing_indicators(enabled: bool) None
Set the
Settings
:draw-compositing-indicators property.- Parameters:
enabled – Value to be set
Set the
Settings
:enable-back-forward-navigation-gestures property.Added in version 2.24.
- Parameters:
enabled – value to be set
- set_enable_caret_browsing(enabled: bool) None
Set the
Settings
:enable-caret-browsing property.- Parameters:
enabled – Value to be set
- set_enable_developer_extras(enabled: bool) None
Set the
Settings
:enable-developer-extras property.- Parameters:
enabled – Value to be set
- set_enable_dns_prefetching(enabled: bool) None
Set the
Settings
:enable-dns-prefetching property.- Parameters:
enabled – Value to be set
- set_enable_encrypted_media(enabled: bool) None
Set the
Settings
:enable-encrypted-media property.Added in version 2.20.
- Parameters:
enabled – Value to be set
- set_enable_fullscreen(enabled: bool) None
Set the
Settings
:enable-fullscreen property.- Parameters:
enabled – Value to be set
- set_enable_html5_database(enabled: bool) None
Set the
Settings
:enable-html5-database property.- Parameters:
enabled – Value to be set
- set_enable_html5_local_storage(enabled: bool) None
Set the
Settings
:enable-html5-local-storage property.- Parameters:
enabled – Value to be set
- set_enable_hyperlink_auditing(enabled: bool) None
Set the
Settings
:enable-hyperlink-auditing property.- Parameters:
enabled – Value to be set
- set_enable_javascript(enabled: bool) None
Set the
Settings
:enable-javascript property.- Parameters:
enabled – Value to be set
- set_enable_javascript_markup(enabled: bool) None
Set the
Settings
:enable-javascript-markup property.Added in version 2.24.
- Parameters:
enabled – Value to be set
- set_enable_media(enabled: bool) None
Set the
Settings
:enable-media property.Added in version 2.26.
- Parameters:
enabled – Value to be set
- set_enable_media_capabilities(enabled: bool) None
Set the
Settings
:enable-media-capabilities property.Added in version 2.22.
- Parameters:
enabled – Value to be set
- set_enable_media_stream(enabled: bool) None
Set the
Settings
:enable-media-stream property.Added in version 2.4.
- Parameters:
enabled – Value to be set
- set_enable_mediasource(enabled: bool) None
Set the
Settings
:enable-mediasource property.Added in version 2.4.
- Parameters:
enabled – Value to be set
- set_enable_mock_capture_devices(enabled: bool) None
Set the
Settings
:enable-mock-capture-devices property.Added in version 2.4.
- Parameters:
enabled – Value to be set
- set_enable_offline_web_application_cache(enabled: bool) None
Setting no longer supported. This function does nothing.
Deprecated since version 2.44: Please do not use it in newly written code
- Parameters:
enabled – Value to be set
- set_enable_page_cache(enabled: bool) None
Set the
Settings
:enable-page-cache property.- Parameters:
enabled – Value to be set
- set_enable_resizable_text_areas(enabled: bool) None
Set the
Settings
:enable-resizable-text-areas property.- Parameters:
enabled – Value to be set
- set_enable_site_specific_quirks(enabled: bool) None
Set the
Settings
:enable-site-specific-quirks property.- Parameters:
enabled – Value to be set
- set_enable_smooth_scrolling(enabled: bool) None
Set the
Settings
:enable-smooth-scrolling property.- Parameters:
enabled – Value to be set
Set the
Settings
:enable-spatial-navigation property.Added in version 2.2.
- Parameters:
enabled – Value to be set
- set_enable_tabs_to_links(enabled: bool) None
Set the
Settings
:enable-tabs-to-links property.- Parameters:
enabled – Value to be set
- set_enable_webaudio(enabled: bool) None
Set the
Settings
:enable-webaudio property.- Parameters:
enabled – Value to be set
- set_enable_webgl(enabled: bool) None
Set the
Settings
:enable-webgl property.- Parameters:
enabled – Value to be set
- set_enable_webrtc(enabled: bool) None
Set the
enable_webrtc
property.Setting this property to
True
implies the media-stream web-setting will also be enabled.Added in version 2.38.
- Parameters:
enabled – Value to be set
- set_enable_write_console_messages_to_stdout(enabled: bool) None
Set the
Settings
:enable-write-console-messages-to-stdout property.Added in version 2.2.
- Parameters:
enabled – Value to be set
- set_fantasy_font_family(fantasy_font_family: str) None
Set the
Settings
:fantasy-font-family property.- Parameters:
fantasy_font_family – the new default fantasy font family
- set_feature_enabled(feature: Feature, enabled: bool) None
Enables or disables a feature.
The current status of the feature can be determined with
webkit_settings_get_feature_enabled
. To reset a feature to its initial status, pass the value returned bywebkit_feature_get_default_value
as theenabled
parameter.Added in version 2.42.
- Parameters:
feature – the feature to toggle.
enabled – whether the feature will be enabled.
- set_hardware_acceleration_policy(policy: HardwareAccelerationPolicy) None
Set the
Settings
:hardware-acceleration-policy property.Added in version 2.16.
- Parameters:
policy – a
HardwareAccelerationPolicy
- set_javascript_can_access_clipboard(enabled: bool) None
Set the
Settings
:javascript-can-access-clipboard property.- Parameters:
enabled – Value to be set
- set_javascript_can_open_windows_automatically(enabled: bool) None
Set the
Settings
:javascript-can-open-windows-automatically property.- Parameters:
enabled – Value to be set
- set_load_icons_ignoring_image_load_setting(enabled: bool) None
Setting no longer supported. This function does nothing.
Deprecated since version 2.42: Please do not use it in newly written code
- Parameters:
enabled – Value to be set
- set_media_content_types_requiring_hardware_support(content_types: str | None = None) None
Set the
Settings
:media-content-types-requiring-hardware-support property.Added in version 2.30.
- Parameters:
content_types – list of media content types requiring hardware support split by semicolons (:) or
None
to use the default value.
- set_media_playback_allows_inline(enabled: bool) None
Set the
Settings
:media-playback-allows-inline property.- Parameters:
enabled – Value to be set
- set_media_playback_requires_user_gesture(enabled: bool) None
Set the
Settings
:media-playback-requires-user-gesture property.- Parameters:
enabled – Value to be set
- set_minimum_font_size(font_size: int) None
Set the
Settings
:minimum-font-size property.- Parameters:
font_size – minimum font size to be set in pixels
- set_monospace_font_family(monospace_font_family: str) None
Set the
Settings
:monospace-font-family property.- Parameters:
monospace_font_family – the new default monospace font family
- set_pictograph_font_family(pictograph_font_family: str) None
Set the
Settings
:pictograph-font-family property.- Parameters:
pictograph_font_family – the new default pictograph font family
- set_print_backgrounds(print_backgrounds: bool) None
Set the
Settings
:print-backgrounds property.- Parameters:
print_backgrounds – Value to be set
- set_sans_serif_font_family(sans_serif_font_family: str) None
Set the
Settings
:sans-serif-font-family property.- Parameters:
sans_serif_font_family – the new default sans-serif font family
- set_serif_font_family(serif_font_family: str) None
Set the
Settings
:serif-font-family property.- Parameters:
serif_font_family – the new default serif font family
- set_user_agent(user_agent: str | None = None) None
Set the
Settings
:user-agent property.- Parameters:
user_agent – The new custom user agent string or
None
to use the default user agent
- set_user_agent_with_application_details(application_name: str | None = None, application_version: str | None = None) None
Set the
Settings
:user-agent property by appending the application details.Set the
Settings
:user-agent property by appending the application details to the default user agent. If no application name or version is given, the default user agent used will be used. If only the version is given, the default engine version is used with the given application name.- Parameters:
application_name – The application name used for the user agent or
None
to use the default user agent.application_version – The application version for the user agent or
None
to user the default version.
Properties
- class Settings
- props.allow_file_access_from_file_urls: bool
Whether file access is allowed from file URLs. By default, when something is loaded in a
WebView
using a file URI, cross origin requests to other file resources are not allowed. This setting allows you to change that behaviour, so that it would be possible to do a XMLHttpRequest of a local file, for example.Added in version 2.10.
- props.allow_modal_dialogs: bool
Determine whether it’s allowed to create and run modal dialogs from a
WebView
through JavaScript with <function>window.showModalDialog</function>. If it’s set toFalse
, the associatedWebView
won’t be able to create new modal dialogs, so not even theWebView
::create signal will be emitted.
Whether or not the top frame is allowed to navigate to data URLs. It is disabled by default due to the risk it poses when loading untrusted URLs, with data URLs being used in scamming and phishing attacks. In contrast, a scenario where it could be enabled could be an app that embeds a WebView and you have control of the pages being show instead of a generic browser.
Added in version 2.28.
- props.allow_universal_access_from_file_urls: bool
Whether or not JavaScript running in the context of a file scheme URL should be allowed to access content from any origin. By default, when something is loaded in a
WebView
using a file scheme URL, access to the local file system and arbitrary local storage is not allowed. This setting allows you to change that behaviour, so that it would be possible to use local storage, for example.Added in version 2.14.
- props.auto_load_images: bool
Determines whether images should be automatically loaded or not. On devices where network bandwidth is of concern, it might be useful to turn this property off.
- props.cursive_font_family: str
The font family used as the default for content using a cursive font.
- props.default_charset: str
The default text charset used when interpreting content with an unspecified charset.
- props.default_font_family: str
The font family to use as the default for content that does not specify a font.
- props.default_font_size: int
The default font size in pixels to use for content displayed if no font size is specified.
- props.default_monospace_font_size: int
The default font size in pixels to use for content displayed in monospace font if no font size is specified.
- props.disable_web_security: bool
Enable or disable support for Web Security on pages.
This setting disables the same-origin policy, allowing every website full control over all other websites. This is for use in special environments where you wish to disable all security and allow websites to hack each other. It is impossible to use this setting securely.
Added in version 2.40.
- props.draw_compositing_indicators: bool
Whether to draw compositing borders and repaint counters on layers drawn with accelerated compositing. This is useful for debugging issues related to web content that is composited with the GPU.
Enable or disable horizontal swipe gesture for back-forward navigation.
Added in version 2.24.
- props.enable_developer_extras: bool
Determines whether or not developer tools, such as the Web Inspector, are enabled.
- props.enable_dns_prefetching: bool
Determines whether or not to prefetch domain names. DNS prefetching attempts to resolve domain names before a user tries to follow a link.
- props.enable_encrypted_media: bool
Enable or disable support for Encrypted Media API on pages. EncryptedMedia is an experimental JavaScript API for playing encrypted media in HTML. This property will only work as intended if the EncryptedMedia feature is enabled at build time with the ENABLE_ENCRYPTED_MEDIA flag.
See https://www.w3.org/TR/encrypted-media/
Added in version 2.20.
- props.enable_fullscreen: bool
Whether to enable the Javascript Fullscreen API. The API allows any HTML element to request fullscreen display. See also the current draft of the spec: http://www.w3.org/TR/fullscreen/
- props.enable_html5_database: bool
Whether to enable HTML5 client-side SQL database support (IndexedDB).
- props.enable_html5_local_storage: bool
Whether to enable HTML5 local storage support. Local storage provides simple synchronous storage access.
HTML5 local storage specification is available at http://dev.w3.org/html5/webstorage/.
- props.enable_hyperlink_auditing: bool
Determines whether or not hyperlink auditing is enabled.
The hyperlink auditing specification is available at http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#hyperlink-auditing.
- props.enable_javascript_markup: bool
Determines whether or not JavaScript markup is allowed in document. When this setting is disabled, all JavaScript-related elements and attributes are removed from the document during parsing. Note that executing JavaScript is still allowed if
Settings
:enable-javascript isTrue
.Added in version 2.24.
- props.enable_media: bool
Enable or disable support for media playback on pages. This setting is enabled by default. Disabling it means
<audio>
,<track>
and<video>
elements will have playback support disabled.Added in version 2.26.
- props.enable_media_capabilities: bool
Enable or disable support for MediaCapabilities on pages. This specification intends to provide APIs to allow websites to make an optimal decision when picking media content for the user. The APIs will expose information about the decoding and encoding capabilities for a given format but also output capabilities to find the best match based on the device’s display.
See also https://wicg.github.io/media-capabilities/
Added in version 2.22.
- props.enable_media_stream: bool
Enable or disable support for MediaStream on pages. MediaStream is an experimental proposal for allowing web pages to access audio and video devices for capture.
See also http://dev.w3.org/2011/webrtc/editor/getusermedia.html
Added in version 2.4.
- props.enable_mediasource: bool
Enable or disable support for MediaSource on pages. MediaSource extends HTMLMediaElement to allow JavaScript to generate media streams for playback.
See also http://www.w3.org/TR/media-source/
Added in version 2.4.
- props.enable_mock_capture_devices: bool
Enable or disable the Mock Capture Devices. Those are fake Microphone and Camera devices to be used as MediaStream sources.
Added in version 2.24.
- props.enable_offline_web_application_cache: bool
Unsupported setting. This property does nothing.
Deprecated since version 2.44: Please do not use it in newly written code
- props.enable_page_cache: bool
Enable or disable the page cache. Disabling the page cache is generally only useful for special circumstances like low-memory scenarios or special purpose applications like static HTML viewers. This setting only controls the Page Cache, this cache is different than the disk-based or memory-based traditional resource caches, its point is to make going back and forth between pages much faster. For details about the different types of caches and their purposes see: http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
- props.enable_site_specific_quirks: bool
Whether to turn on site-specific quirks. Turning this on will tell WebKit to use some site-specific workarounds for better web compatibility. For example, older versions of MediaWiki will incorrectly send to WebKit a CSS file with KHTML workarounds. By turning on site-specific quirks, WebKit will special-case this and other cases to make some specific sites work.
Whether to enable Spatial Navigation. This feature consists in the ability to navigate between focusable elements in a Web page, such as hyperlinks and form controls, by using Left, Right, Up and Down arrow keys. For example, if an user presses the Right key, heuristics determine whether there is an element they might be trying to reach towards the right, and if there are multiple elements, which element they probably wants.
Added in version 2.4.
- props.enable_tabs_to_links: bool
Determines whether the tab key cycles through the elements on the page. When this setting is enabled, users will be able to focus the next element in the page by pressing the tab key. If the selected element is editable, then pressing tab key will insert the tab character.
- props.enable_webaudio: bool
Enable or disable support for WebAudio on pages. WebAudio is an API for processing and synthesizing audio in web applications
- props.enable_webgl: bool
Enable or disable support for WebGL on pages. WebGL enables web content to use an API based on OpenGL ES 2.0.
- props.enable_webrtc: bool
Enable WebRTC support for loaded pages.
Enabling this setting implies that
enable_media_stream
will be enabled as well.See also https://www.w3.org/TR/webrtc/
Added in version 2.38.
- props.enable_write_console_messages_to_stdout: bool
Enable or disable writing console messages to stdout. These are messages sent to the console with console.log and related methods.
Added in version 2.2.
- props.fantasy_font_family: str
The font family used as the default for content using a fantasy font.
- props.hardware_acceleration_policy: HardwareAccelerationPolicy
The
HardwareAccelerationPolicy
to decide how to enable and disable hardware acceleration. Disabling hardware acceleration might cause some websites to not render correctly or consume more CPU.Note that changing this setting might not be possible if hardware acceleration is not supported by the hardware or the system. In that case, you can get the value to know the actual policy being used, but changing the setting will not have any effect.
Added in version 2.16.
- props.javascript_can_access_clipboard: bool
Whether JavaScript can access the clipboard. The default value is
False
. If set toTrue
, document.execCommand() allows cut, copy and paste commands.
- props.javascript_can_open_windows_automatically: bool
Whether JavaScript can open popup windows automatically without user intervention.
- props.load_icons_ignoring_image_load_setting: bool
Unsupported setting. This property does nothing.
Deprecated since version 2.42: Please do not use it in newly written code
- props.media_content_types_requiring_hardware_support: str
List of media content types requiring hardware support, split by semicolons (:). For example: ‘video/webm; codecs=”vp*”:video/mp4; codecs=”avc*”:video/* codecs=”av1*”’.
Added in version 2.30.
- props.media_playback_allows_inline: bool
Whether media playback is full-screen only or inline playback is allowed. This is
True
by default, so media playback can be inline. Setting it toFalse
allows specifying that media playback should be always fullscreen.
- props.media_playback_requires_user_gesture: bool
Whether a user gesture (such as clicking the play button) would be required to start media playback or load media. This is off by default, so media playback could start automatically. Setting it on requires a gesture by the user to start playback, or to load the media.
- props.minimum_font_size: int
The minimum font size in pixels used to display text. This setting controls the absolute smallest size. Values other than 0 can potentially break page layouts.
- props.monospace_font_family: str
The font family used as the default for content using a monospace font.
- props.pictograph_font_family: str
The font family used as the default for content using a pictograph font.
- props.sans_serif_font_family: str
The font family used as the default for content using a sans-serif font.
- props.user_agent: str
The user-agent string used by WebKit. Unusual user-agent strings may cause web content to render incorrectly or fail to run, as many web pages are written to parse the user-agent strings of only the most popular browsers. Therefore, it’s typically better to not completely override the standard user-agent, but to use
set_user_agent_with_application_details()
instead.If this property is set to the empty string or
None
, it will revert to the standard user-agent.