SettingsProtocol

public protocol SettingsProtocol : ObjectProtocol, StyleProviderProtocol

GtkSettings provides a mechanism to share global settings between applications.

On the X window system, this sharing is realized by an XSettings manager that is usually part of the desktop environment, along with utilities that let the user change these settings.

On Wayland, the settings are obtained either via a settings portal, or by reading desktop settings from DConf.

In the absence of these sharing mechanisms, GTK reads default values for settings from settings.ini files in /etc/gtk-4.0, $XDG_CONFIG_DIRS/gtk-4.0 and $XDG_CONFIG_HOME/gtk-4.0. These files must be valid key files (see GKeyFile), and have a section called Settings. Themes can also provide default values for settings by installing a settings.ini file next to their gtk.css file.

Applications can override system-wide settings by setting the property of the GtkSettings object with g_object_set(). This should be restricted to special cases though; GtkSettings are not meant as an application configuration facility.

There is one GtkSettings instance per display. It can be obtained with [funcGtk.Settings.get_for_display], but in many cases, it is more convenient to use [methodGtk.Widget.get_settings].

The SettingsProtocol protocol exposes the methods and properties of an underlying GtkSettings instance. The default implementation of these can be found in the protocol extension below. For a concrete class that implements these methods and properties, see Settings. Alternatively, use SettingsRef as a lighweight, unowned reference if you already have an instance you just want to use.

  • ptr

    Untyped pointer to the underlying GtkSettings instance.

    Declaration

    Swift

    var ptr: UnsafeMutableRawPointer! { get }
  • settings_ptr Default implementation

    Typed pointer to the underlying GtkSettings instance.

    Default Implementation

    Return the stored, untyped pointer as a typed pointer to the GtkSettings instance.

    Declaration

    Swift

    var settings_ptr: UnsafeMutablePointer<GtkSettings>! { get }
  • Required Initialiser for types conforming to SettingsProtocol

    Declaration

    Swift

    init(raw: UnsafeMutableRawPointer)

Settings Class

  • Bind a SettingsPropertyName source property to a given target object.

    Declaration

    Swift

    @discardableResult
    @inlinable
    func bind<Q, T>(property source_property: SettingsPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol

    Parameters

    source_property

    the source property to bind

    target

    the target object to bind to

    target_property

    the target property to bind to

    flags

    the flags to pass to the Binding

    transform_from

    ValueTransformer to use for forward transformation

    transform_to

    ValueTransformer to use for backwards transformation

    Return Value

    binding reference or nil in case of an error

  • get(property:) Extension method

    Get the value of a Settings property

    Declaration

    Swift

    @inlinable
    func get(property: SettingsPropertyName) -> GLibObject.Value

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

  • set(property:value:) Extension method

    Set the value of a Settings property. Note that this will only have an effect on properties that are writable and not construct-only!

    Declaration

    Swift

    @inlinable
    func set(property: SettingsPropertyName, value v: GLibObject.Value)

    Parameters

    property

    the property to get the value for

    Return Value

    the value of the named property

Settings Class: SettingsProtocol extension (methods and fields)

  • resetProperty(name:) Extension method

    Undoes the effect of calling g_object_set() to install an application-specific value for a setting.

    After this call, the setting will again follow the session-wide value for this setting.

    Declaration

    Swift

    @inlinable
    func resetProperty(name: UnsafePointer<CChar>!)