Settings#

class Settings(**properties: Any)#

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#

class Settings
classmethod new() Settings#

Creates a new Settings instance with default values.

It must be manually attached to a WebView. See also new_with_settings().

Methods#

class Settings
apply_from_key_file(key_file: KeyFile, group_name: str) bool#

Reads the contents of the given group_name from the given key_file and apply the value of each key/value to the corresponding property on the settings.

Value types have to match with the corresponding setting property type and the group keys have to match existing setting property names. If those conditions are not met, the function will return False.

Supported value types are strings (unquoted), booleans (0, 1, true, false) and unsigned integers.

Added in version 2.46.

Parameters:
  • key_file – a KeyFile

  • group_name – Name of the group to read from key_file

classmethod font_size_to_pixels() 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 of Settings.

Added in version 2.20.

classmethod font_size_to_points() 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 of Settings.

Added in version 2.20.

classmethod 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 with get_feature_enabled.

Note that most applications should use get_development_features and get_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_allow_modal_dialogs() bool#

Get the Settings:allow-modal-dialogs property.

get_allow_top_navigation_to_data_urls() bool#

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_auto_load_images() bool#

Get the Settings:auto-load-images property.

get_cursive_font_family() str#

Gets the Settings:cursive-font-family property.

get_default_charset() str#

Gets the Settings:default-charset property.

get_default_font_family() str#

Gets the Settings:default-font-family property.

get_default_font_size() int#

Gets the Settings:default-font-size property.

get_default_monospace_font_size() int#

Gets the Settings:default-monospace-font-size property.

classmethod 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; see FeatureStatus 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_draw_compositing_indicators() bool#

Get the Settings:draw-compositing-indicators property.

get_enable_2d_canvas_acceleration() bool#

Get the Settings:enable-2d-canvas-acceleration property.

Added in version 2.46.

get_enable_back_forward_navigation_gestures() bool#

Get the Settings:enable-back-forward-navigation-gestures property.

Added in version 2.24.

get_enable_caret_browsing() bool#

Get the Settings:enable-caret-browsing property.

get_enable_developer_extras() bool#

Get the Settings:enable-developer-extras property.

get_enable_dns_prefetching() bool#

Get the Settings:enable-dns-prefetching property.

get_enable_encrypted_media() bool#

Get the Settings:enable-encrypted-media property.

Added in version 2.20.

get_enable_fullscreen() bool#

Get the Settings:enable-fullscreen property.

get_enable_html5_database() bool#

Get the Settings:enable-html5-database property.

get_enable_html5_local_storage() bool#

Get the Settings:enable-html5-local-storage property.

Get the Settings:enable-hyperlink-auditing property.

get_enable_javascript() bool#

Get the Settings:enable-javascript property.

get_enable_javascript_markup() bool#

Get the Settings:enable-javascript-markup property.

Added in version 2.24.

get_enable_media() bool#

Get the Settings:enable-media property.

Added in version 2.26.

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_mediasource() bool#

Get the Settings:enable-mediasource 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_enable_page_cache() bool#

Get the Settings:enable-page-cache property.

get_enable_resizable_text_areas() bool#

Get the Settings:enable-resizable-text-areas property.

get_enable_site_specific_quirks() bool#

Get the Settings:enable-site-specific-quirks property.

get_enable_smooth_scrolling() bool#

Get the Settings:enable-smooth-scrolling property.

get_enable_spatial_navigation() bool#

Get the Settings:enable-spatial-navigation property.

Added in version 2.2.

Get the Settings:enable-tabs-to-links property.

get_enable_webaudio() bool#

Get the Settings:enable-webaudio property.

get_enable_webgl() bool#

Get the Settings:enable-webgl property.

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.

classmethod 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; see FeatureStatus for more details.

Added in version 2.42.

get_fantasy_font_family() str#

Gets the Settings:fantasy-font-family property.

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_allows_inline() bool#

Get the Settings:media-playback-allows-inline property.

get_media_playback_requires_user_gesture() bool#

Get the Settings:media-playback-requires-user-gesture property.

get_minimum_font_size() int#

Gets the Settings:minimum-font-size property.

get_monospace_font_family() str#

Gets the Settings:monospace-font-family property.

get_pictograph_font_family() str#

Gets the Settings:pictograph-font-family property.

get_print_backgrounds() bool#

Get the Settings:print-backgrounds property.

get_sans_serif_font_family() str#

Gets the Settings:sans-serif-font-family property.

get_serif_font_family() str#

Gets the Settings:serif-font-family property.

get_user_agent() str#

Get the Settings:user-agent property.

get_zoom_text_only() bool#

Get the Settings:zoom-text-only 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_allow_top_navigation_to_data_urls(allowed: bool) None#

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_enable_2d_canvas_acceleration(enabled: bool) None#

Set the Settings:enable-2d-canvas-acceleration property.

Added in version 2.46.

Parameters:

enabled – Value to be set

set_enable_back_forward_navigation_gestures(enabled: bool) None#

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 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_enable_spatial_navigation(enabled: bool) None#

Set the Settings:enable-spatial-navigation property.

Added in version 2.2.

Parameters:

enabled – Value to be set

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 by webkit_feature_get_default_value as the enabled 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.

set_zoom_text_only(zoom_text_only: bool) None#

Set the Settings:zoom-text-only property.

Parameters:

zoom_text_only – Value to be set

Properties#

class Settings
props.allow_file_access_from_file_urls: bool#

The type of the None singleton.

Added in version 2.10.

props.allow_modal_dialogs: bool#

The type of the None singleton.

props.allow_top_navigation_to_data_urls: bool#

The type of the None singleton.

Added in version 2.28.

props.allow_universal_access_from_file_urls: bool#

The type of the None singleton.

Added in version 2.14.

props.auto_load_images: bool#

The type of the None singleton.

props.cursive_font_family: str#

The type of the None singleton.

props.default_charset: str#

The type of the None singleton.

props.default_font_family: str#

The type of the None singleton.

props.default_font_size: int#

The type of the None singleton.

props.default_monospace_font_size: int#

The type of the None singleton.

props.disable_web_security: bool#

The type of the None singleton.

Added in version 2.40.

props.draw_compositing_indicators: bool#

The type of the None singleton.

props.enable_2d_canvas_acceleration: bool#

The type of the None singleton.

Added in version 2.46.

props.enable_back_forward_navigation_gestures: bool#

The type of the None singleton.

Added in version 2.24.

props.enable_caret_browsing: bool#

The type of the None singleton.

props.enable_developer_extras: bool#

The type of the None singleton.

props.enable_dns_prefetching: bool#

The type of the None singleton.

props.enable_encrypted_media: bool#

The type of the None singleton.

Added in version 2.20.

props.enable_fullscreen: bool#

The type of the None singleton.

props.enable_html5_database: bool#

The type of the None singleton.

props.enable_html5_local_storage: bool#

The type of the None singleton.

The type of the None singleton.

props.enable_javascript: bool#

The type of the None singleton.

props.enable_javascript_markup: bool#

The type of the None singleton.

Added in version 2.24.

props.enable_media: bool#

The type of the None singleton.

Added in version 2.26.

props.enable_media_capabilities: bool#

The type of the None singleton.

Added in version 2.22.

props.enable_media_stream: bool#

The type of the None singleton.

Added in version 2.4.

props.enable_mediasource: bool#

The type of the None singleton.

Added in version 2.4.

props.enable_mock_capture_devices: bool#

The type of the None singleton.

Added in version 2.24.

props.enable_offline_web_application_cache: bool#

The type of the None singleton.

Deprecated since version 2.44: Please do not use it in newly written code

props.enable_page_cache: bool#

The type of the None singleton.

props.enable_resizable_text_areas: bool#

The type of the None singleton.

props.enable_site_specific_quirks: bool#

The type of the None singleton.

props.enable_smooth_scrolling: bool#

The type of the None singleton.

props.enable_spatial_navigation: bool#

The type of the None singleton.

Added in version 2.4.

The type of the None singleton.

props.enable_webaudio: bool#

The type of the None singleton.

props.enable_webgl: bool#

The type of the None singleton.

props.enable_webrtc: bool#

The type of the None singleton.

Added in version 2.38.

props.enable_write_console_messages_to_stdout: bool#

The type of the None singleton.

Added in version 2.2.

props.fantasy_font_family: str#

The type of the None singleton.

props.hardware_acceleration_policy: HardwareAccelerationPolicy#

The type of the None singleton.

Added in version 2.16.

props.javascript_can_access_clipboard: bool#

The type of the None singleton.

props.javascript_can_open_windows_automatically: bool#

The type of the None singleton.

props.load_icons_ignoring_image_load_setting: bool#

The type of the None singleton.

Deprecated since version 2.42: Please do not use it in newly written code

props.media_content_types_requiring_hardware_support: str#

The type of the None singleton.

Added in version 2.30.

props.media_playback_allows_inline: bool#

The type of the None singleton.

props.media_playback_requires_user_gesture: bool#

The type of the None singleton.

props.minimum_font_size: int#

The type of the None singleton.

props.monospace_font_family: str#

The type of the None singleton.

props.pictograph_font_family: str#

The type of the None singleton.

props.print_backgrounds: bool#

The type of the None singleton.

props.sans_serif_font_family: str#

The type of the None singleton.

props.serif_font_family: str#

The type of the None singleton.

props.user_agent: str#

The type of the None singleton.

props.zoom_text_only: bool#

The type of the None singleton.