Trait gio::prelude::SettingsExt

source ·
pub trait SettingsExt: 'static {
Show 44 methods // Required methods fn apply(&self); 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 strv(&self, key: &str) -> Vec<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_strv(&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) -> Inhibit + '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

Required 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; see delay(). In the normal case settings are always applied immediately.

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

a glib::Object

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 g_settings_get() for booleans.

It is a programmer error to give a key that isn’t specified as having a boolean type in the schema for self.

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.

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 property::Settings::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 g_settings_get() for doubles.

It is a programmer error to give a key that isn’t specified as having a ‘double’ type in the schema for self.

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 ‘delayed-apply’ mode.

Returns

true if self has unapplied changes

source

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

Gets the value that is stored at key in self.

A convenience variant of g_settings_get() for 32-bit integers.

It is a programmer error to give a key that isn’t specified as having a int32 type in the schema for self.

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 g_settings_get() for 64-bit integers.

It is a programmer error to give a key that isn’t specified as having a int64 type in the schema for self.

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 g_settings_get() for strings.

It is a programmer error to give a key that isn’t specified as having a string type in the schema for self.

key

the key to get the value for

Returns

a newly-allocated string

source

fn strv(&self, key: &str) -> Vec<GString>

A convenience variant of g_settings_get() for string arrays.

It is a programmer error to give a key that isn’t specified as having an array of strings type in the schema for self.

key

the key to get the value for

Returns

a newly-allocated, None-terminated array of strings, the value that is stored at key in self.

source

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

Gets the value that is stored at key in self.

A convenience variant of g_settings_get() for 32-bit unsigned integers.

It is a programmer error to give a key that isn’t specified as having a uint32 type in the schema for self.

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 g_settings_get() for 64-bit unsigned integers.

It is a programmer error to give a key that isn’t specified as having a uint64 type in the schema for self.

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 None (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 or not

name

the name of a key

Returns

true if the key name is writable

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 g_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 non-applied changes to the settings. This function does nothing unless self is in ‘delay-apply’ mode; see delay(). 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 g_settings_set() for booleans.

It is a programmer error to give a key that isn’t specified as having a boolean type in the schema for self.

key

the name of the key to set

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 g_settings_set() for doubles.

It is a programmer error to give a key that isn’t specified as having a ‘double’ type in the schema for self.

key

the name of the key to set

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

a key, within self

value

an enumerated value

Returns

true, if the set succeeds

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 strv() will return an array of ‘nicks’; one for each bit in value.

key

a key, within self

value

a flags value

Returns

true, if the set succeeds

source

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

Sets key in self to value.

A convenience variant of g_settings_set() for 32-bit integers.

It is a programmer error to give a key that isn’t specified as having a int32 type in the schema for self.

key

the name of the key to set

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 g_settings_set() for 64-bit integers.

It is a programmer error to give a key that isn’t specified as having a int64 type in the schema for self.

key

the name of the key to set

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 g_settings_set() for strings.

It is a programmer error to give a key that isn’t specified as having a string type in the schema for self.

key

the name of the key to set

value

the value to set it to

Returns

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

source

fn set_strv(&self, key: &str, value: &[&str]) -> Result<(), BoolError>

Sets key in self to value.

A convenience variant of g_settings_set() for string arrays. If value is None, then key is set to be the empty array.

It is a programmer error to give a key that isn’t specified as having an array of strings type in the schema for self.

key

the name of the key to set

value

the value to set it to, or None

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 g_settings_set() for 32-bit unsigned integers.

It is a programmer error to give a key that isn’t specified as having a uint32 type in the schema for self.

key

the name of the key to set

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 g_settings_set() for 64-bit unsigned integers.

It is a programmer error to give a key that isn’t specified as having a uint64 type in the schema for self.

key

the name of the key to set

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 name of the key to set

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. See delay() for details.

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

The “changed” signal is emitted when a key has potentially changed. You should call one of the g_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) -> Inhibit + 'static>( &self, f: F ) -> SignalHandlerId

The “writable-change-event” signal is 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 GQuark 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

The “writable-changed” signal is 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

Implementors§