Trait SettingsExt

Source
pub trait SettingsExt: IsA<Settings> + 'static {
Show 43 methods // Provided methods fn apply(&self) { ... } fn bind_with_mapping_closures( &self, key: &str, object: &impl IsA<Object>, property: &str, flags: SettingsBindFlags, get_mapping: Option<&Closure>, set_mapping: Option<&Closure>, ) { ... } fn bind_writable( &self, key: &str, object: &impl IsA<Object>, property: &str, inverted: bool, ) { ... } fn create_action(&self, key: &str) -> Action { ... } fn delay(&self) { ... } fn boolean(&self, key: &str) -> bool { ... } fn child(&self, name: &str) -> Settings { ... } fn default_value(&self, key: &str) -> Option<Variant> { ... } fn double(&self, key: &str) -> f64 { ... } fn enum_(&self, key: &str) -> i32 { ... } fn flags(&self, key: &str) -> u32 { ... } fn has_unapplied(&self) -> bool { ... } fn int(&self, key: &str) -> i32 { ... } fn int64(&self, key: &str) -> i64 { ... } fn string(&self, key: &str) -> GString { ... } fn uint(&self, key: &str) -> u32 { ... } fn uint64(&self, key: &str) -> u64 { ... } fn user_value(&self, key: &str) -> Option<Variant> { ... } fn value(&self, key: &str) -> Variant { ... } fn is_writable(&self, name: &str) -> bool { ... } fn list_children(&self) -> Vec<GString> { ... } fn reset(&self, key: &str) { ... } fn revert(&self) { ... } fn set_boolean(&self, key: &str, value: bool) -> Result<(), BoolError> { ... } fn set_double(&self, key: &str, value: f64) -> Result<(), BoolError> { ... } fn set_enum(&self, key: &str, value: i32) -> Result<(), BoolError> { ... } fn set_flags(&self, key: &str, value: u32) -> Result<(), BoolError> { ... } fn set_int(&self, key: &str, value: i32) -> Result<(), BoolError> { ... } fn set_int64(&self, key: &str, value: i64) -> Result<(), BoolError> { ... } fn set_string(&self, key: &str, value: &str) -> Result<(), BoolError> { ... } fn set_uint(&self, key: &str, value: u32) -> Result<(), BoolError> { ... } fn set_uint64(&self, key: &str, value: u64) -> Result<(), BoolError> { ... } fn set_value(&self, key: &str, value: &Variant) -> Result<(), BoolError> { ... } fn backend(&self) -> Option<SettingsBackend> { ... } fn is_delay_apply(&self) -> bool { ... } fn path(&self) -> Option<GString> { ... } fn schema_id(&self) -> Option<GString> { ... } fn settings_schema(&self) -> Option<SettingsSchema> { ... } fn connect_changed<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { ... } fn connect_writable_change_event<F: Fn(&Self, u32) -> Propagation + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_writable_changed<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { ... } fn connect_delay_apply_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_has_unapplied_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Settings methods.

§Implementors

Settings

Provided Methods§

Source

fn apply(&self)

Applies any changes that have been made to the settings.

This function does nothing unless @self is in ‘delay-apply’ mode. In the normal case settings are always applied immediately.

Source

fn bind_with_mapping_closures( &self, key: &str, object: &impl IsA<Object>, property: &str, flags: SettingsBindFlags, get_mapping: Option<&Closure>, set_mapping: Option<&Closure>, )

Available on crate feature v2_82 only.

Version of [SettingsExtManual::bind_with_mapping()][crate::prelude::SettingsExtManual::bind_with_mapping()] using closures instead of callbacks for easier binding in other languages.

§key

the key to bind

§object

the object with property to bind

§property

the name of the property to bind

§flags

flags for the binding

§get_mapping

a function that gets called to convert values from @self to @object, or NULL to use the default GIO mapping

§set_mapping

a function that gets called to convert values from @object to @self, or NULL to use the default GIO mapping

Source

fn bind_writable( &self, key: &str, object: &impl IsA<Object>, property: &str, inverted: bool, )

Create a binding between the writability of @key in the @self object and the property @property of @object.

The property must be boolean; sensitive or visible properties of widgets are the most likely candidates.

Writable bindings are always uni-directional; changes of the writability of the setting will be propagated to the object property, not the other way.

When the @inverted argument is true, the binding inverts the value as it passes from the setting to the object, i.e. @property will be set to true if the key is not writable.

Note that the lifecycle of the binding is tied to @object, and that you can have only one binding per object property. If you bind the same property twice on the same object, the second binding overrides the first one.

§key

the key to bind

§object

the object with property to bind

§property

the name of a boolean property to bind

§inverted

whether to ‘invert’ the value

Source

fn create_action(&self, key: &str) -> Action

Creates a Action corresponding to a given Settings key.

The action has the same name as the key.

The value of the key becomes the state of the action and the action is enabled when the key is writable. Changing the state of the action results in the key being written to. Changes to the value or writability of the key cause appropriate change notifications to be emitted for the action.

For boolean-valued keys, action activations take no parameter and result in the toggling of the value. For all other types, activations take the new value for the key (which must have the correct type).

§key

the name of a key in @self

§Returns

a new Action

Source

fn delay(&self)

Changes the Settings object into ‘delay-apply’ mode.

In this mode, changes to @self are not immediately propagated to the backend, but kept locally until apply() is called.

Source

fn boolean(&self, key: &str) -> bool

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for booleans.

It is a programmer error to give a @key that isn’t specified as having a b type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

a boolean

Source

fn child(&self, name: &str) -> Settings

Creates a child settings object which has a base path of base-path/name, where base-path is the base path of @self and name is as specified by the caller.

The schema for the child settings object must have been declared in the schema of @self using a <child> element.

The created child settings object will inherit the delay-apply mode from @self.

§name

the name of the child schema

§Returns

a ‘child’ settings object

Source

fn default_value(&self, key: &str) -> Option<Variant>

Gets the ‘default value’ of a key.

This is the value that would be read if reset() were to be called on the key.

Note that this may be a different value than returned by SettingsSchemaKey::default_value() if the system administrator has provided a default value.

Comparing the return values of default_value() and value() is not sufficient for determining if a value has been set because the user may have explicitly set the value to something that happens to be equal to the default. The difference here is that if the default changes in the future, the user’s key will still be set.

This function may be useful for adding an indication to a UI of what the default value was before the user set it.

It is a programmer error to give a @key that isn’t contained in the schema for @self.

§key

the key to get the default value for

§Returns

the default value

Source

fn double(&self, key: &str) -> f64

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for doubles.

It is a programmer error to give a @key that isn’t specified as having a d type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

a double

Source

fn enum_(&self, key: &str) -> i32

Gets the value that is stored in @self for @key and converts it to the enum value that it represents.

In order to use this function the type of the value must be a string and it must be marked in the schema file as an enumerated type.

It is a programmer error to give a @key that isn’t contained in the schema for @self or is not marked as an enumerated type.

If the value stored in the configuration database is not a valid value for the enumerated type then this function will return the default value.

§key

the key to get the value for

§Returns

the enum value

Source

fn flags(&self, key: &str) -> u32

Gets the value that is stored in @self for @key and converts it to the flags value that it represents.

In order to use this function the type of the value must be an array of strings and it must be marked in the schema file as a flags type.

It is a programmer error to give a @key that isn’t contained in the schema for @self or is not marked as a flags type.

If the value stored in the configuration database is not a valid value for the flags type then this function will return the default value.

§key

the key to get the value for

§Returns

the flags value

Source

fn has_unapplied(&self) -> bool

Returns whether the Settings object has any unapplied changes.

This can only be the case if it is in ‘delay-apply’ mode.

§Returns

true if @self has unapplied changes, false otherwise

Source

fn int(&self, key: &str) -> i32

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for 32-bit integers.

It is a programmer error to give a @key that isn’t specified as having an i type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

an integer

Source

fn int64(&self, key: &str) -> i64

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for 64-bit integers.

It is a programmer error to give a @key that isn’t specified as having an x type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

a 64-bit integer

Source

fn string(&self, key: &str) -> GString

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for strings.

It is a programmer error to give a @key that isn’t specified as having an s type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

a newly-allocated string

Source

fn uint(&self, key: &str) -> u32

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for 32-bit unsigned integers.

It is a programmer error to give a @key that isn’t specified as having a u type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

an unsigned integer

Source

fn uint64(&self, key: &str) -> u64

Gets the value that is stored at @key in @self.

A convenience variant of Gio::Settings::get() for 64-bit unsigned integers.

It is a programmer error to give a @key that isn’t specified as having a t type in the schema for @self (see glib::VariantType).

§key

the key to get the value for

§Returns

a 64-bit unsigned integer

Source

fn user_value(&self, key: &str) -> Option<Variant>

Checks the ‘user value’ of a key, if there is one.

The user value of a key is the last value that was set by the user.

After calling reset() this function should always return NULL (assuming something is not wrong with the system configuration).

It is possible that value() will return a different value than this function. This can happen in the case that the user set a value for a key that was subsequently locked down by the system administrator — this function will return the user’s old value.

This function may be useful for adding a ‘reset’ option to a UI or for providing indication that a particular value has been changed.

It is a programmer error to give a @key that isn’t contained in the schema for @self.

§key

the key to get the user value for

§Returns

the user’s value, if set

Source

fn value(&self, key: &str) -> Variant

Gets the value that is stored in @self for @key.

It is a programmer error to give a @key that isn’t contained in the schema for @self.

§key

the key to get the value for

§Returns

a new glib::Variant

Source

fn is_writable(&self, name: &str) -> bool

Finds out if a key can be written.

§name

the name of a key

§Returns

true if the key @name is writable, false otherwise

Source

fn list_children(&self) -> Vec<GString>

Gets the list of children on @self.

The list is exactly the list of strings for which it is not an error to call child().

There is little reason to call this function from ‘normal’ code, since you should already know what children are in your schema. This function may still be useful there for introspection reasons, however.

You should free the return value with strfreev() when you are done with it.

§Returns

a list of the children on @self, in no defined order

Source

fn reset(&self, key: &str)

Resets @key to its default value.

This call resets the key, as much as possible, to its default value. That might be the value specified in the schema or the one set by the administrator.

§key

the name of a key

Source

fn revert(&self)

Reverts all unapplied changes to the settings.

This function does nothing unless @self is in ‘delay-apply’ mode. In the normal case settings are always applied immediately.

Change notifications will be emitted for affected keys.

Source

fn set_boolean(&self, key: &str, value: bool) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for booleans.

It is a programmer error to give a @key that isn’t specified as having a b type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_double(&self, key: &str, value: f64) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for doubles.

It is a programmer error to give a @key that isn’t specified as having a d type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_enum(&self, key: &str, value: i32) -> Result<(), BoolError>

Looks up the enumerated type nick for @value and writes it to @key, within @self.

It is a programmer error to give a @key that isn’t contained in the schema for @self or is not marked as an enumerated type, or for @value not to be a valid value for the named type.

After performing the write, accessing @key directly with string() will return the ‘nick’ associated with @value.

§key

the key to set the value for

§value

an enumerated value

§Returns

true if the set succeeds, false otherwise

Source

fn set_flags(&self, key: &str, value: u32) -> Result<(), BoolError>

Looks up the flags type nicks for the bits specified by @value, puts them in an array of strings and writes the array to @key, within @self.

It is a programmer error to give a @key that isn’t contained in the schema for @self or is not marked as a flags type, or for @value to contain any bits that are not value for the named type.

After performing the write, accessing @key directly with SettingsExtManual::strv() will return an array of ‘nicks’; one for each bit in @value.

§key

the key to set the value for

§value

a flags value

§Returns

true if the set succeeds, false otherwise

Source

fn set_int(&self, key: &str, value: i32) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for 32-bit integers.

It is a programmer error to give a @key that isn’t specified as having an i type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_int64(&self, key: &str, value: i64) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for 64-bit integers.

It is a programmer error to give a @key that isn’t specified as having an x type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_string(&self, key: &str, value: &str) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for strings.

It is a programmer error to give a @key that isn’t specified as having an s type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_uint(&self, key: &str, value: u32) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for 32-bit unsigned integers.

It is a programmer error to give a @key that isn’t specified as having a u type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_uint64(&self, key: &str, value: u64) -> Result<(), BoolError>

Sets @key in @self to @value.

A convenience variant of Gio::Settings::set() for 64-bit unsigned integers.

It is a programmer error to give a @key that isn’t specified as having a t type in the schema for @self (see glib::VariantType).

§key

the key to set the value for

§value

the value to set it to

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn set_value(&self, key: &str, value: &Variant) -> Result<(), BoolError>

Sets @key in @self to @value.

It is a programmer error to give a @key that isn’t contained in the schema for @self or for @value to have the incorrect type, per the schema.

If @value is floating then this function consumes the reference.

§key

the key to set the value for

§value

a glib::Variant of the correct type

§Returns

true if setting the key succeeded, false if the key was not writable

Source

fn backend(&self) -> Option<SettingsBackend>

The name of the context that the settings are stored in.

Source

fn is_delay_apply(&self) -> bool

Whether the Settings object is in ‘delay-apply’ mode.

Source

fn path(&self) -> Option<GString>

The path within the backend where the settings are stored.

Source

fn schema_id(&self) -> Option<GString>

The name of the schema that describes the types of keys for this Settings object.

Source

fn settings_schema(&self) -> Option<SettingsSchema>

The SettingsSchema describing the types of keys for this Settings object.

Ideally, this property would be called schema. SettingsSchema has only existed since version 2.32, however, and before then the schema property was used to refer to the ID of the schema rather than the schema itself. Take care.

Source

fn connect_changed<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId

Emitted when a key has potentially changed.

You should call one of the Gio::Settings::get() calls to check the new value.

This signal supports detailed connections. You can connect to the detailed signal changed::x in order to only receive callbacks when key x changes.

Note that @settings only emits this signal if you have read @key at least once while a signal handler was already connected for @key.

§key

the name of the key that changed

Source

fn connect_writable_change_event<F: Fn(&Self, u32) -> Propagation + 'static>( &self, f: F, ) -> SignalHandlerId

Emitted once per writability change event that affects this settings object.

You should connect to this signal if you are interested in viewing groups of changes before they are split out into multiple emissions of the writable-changed signal. For most use cases it is more appropriate to use the writable-changed signal.

In the event that the writability change applies only to a single key, @key will be set to the alias::GLib.Quark for that key. In the event that the writability change affects the entire settings object, @key will be 0.

The default handler for this signal invokes the writable-changed and changed signals for each affected key. This is done because changes in writability might also imply changes in value (if for example, a new mandatory setting is introduced). If any other connected handler returns true then this default functionality will be suppressed.

§key

the quark of the key, or 0

§Returns

true to stop other handlers from being invoked for the event, false to propagate the event further

Source

fn connect_writable_changed<F: Fn(&Self, &str) + 'static>( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId

Emitted when the writability of a key has potentially changed.

You should call is_writable() in order to determine the new status.

This signal supports detailed connections. You can connect to the detailed signal writable-changed::x in order to only receive callbacks when the writability of x changes.

§key

the key

Source

fn connect_delay_apply_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_has_unapplied_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§