[][src]Trait gio::SettingsExt

pub trait SettingsExt: 'static {
    fn apply(&self);
fn bind<P: IsA<Object>>(
        &self,
        key: &str,
        object: &P,
        property: &str,
        flags: SettingsBindFlags
    );
fn bind_writable<P: IsA<Object>>(
        &self,
        key: &str,
        object: &P,
        property: &str,
        inverted: bool
    );
fn create_action(&self, key: &str) -> Option<Action>;
fn delay(&self);
fn get_boolean(&self, key: &str) -> bool;
fn get_child(&self, name: &str) -> Option<Settings>;
fn get_default_value(&self, key: &str) -> Option<Variant>;
fn get_double(&self, key: &str) -> f64;
fn get_enum(&self, key: &str) -> i32;
fn get_flags(&self, key: &str) -> u32;
fn get_has_unapplied(&self) -> bool;
fn get_int(&self, key: &str) -> i32;
fn get_int64(&self, key: &str) -> i64;
fn get_string(&self, key: &str) -> Option<GString>;
fn get_strv(&self, key: &str) -> Vec<GString>;
fn get_uint(&self, key: &str) -> u32;
fn get_uint64(&self, key: &str) -> u64;
fn get_user_value(&self, key: &str) -> Option<Variant>;
fn get_value(&self, key: &str) -> Variant;
fn is_writable(&self, name: &str) -> bool;
fn list_children(&self) -> Vec<GString>;
fn list_keys(&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 get_property_backend(&self) -> Option<SettingsBackend>;
fn get_property_delay_apply(&self) -> bool;
fn get_property_path(&self) -> Option<GString>;
fn get_property_schema_id(&self) -> Option<GString>;
fn get_property_settings_schema(&self) -> Option<SettingsSchema>;
fn connect_changed<F: Fn(&Self, &str) + 'static>(
        &self,
        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,
        f: F
    ) -> SignalHandlerId;
fn connect_property_delay_apply_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_has_unapplied_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all Settings methods.

Implementors

Settings

Required methods

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 SettingsExt::delay. In the normal case settings are always applied immediately.

fn bind<P: IsA<Object>>(
    &self,
    key: &str,
    object: &P,
    property: &str,
    flags: SettingsBindFlags
)

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

The binding uses the default GIO mapping functions to map between the settings and property values. These functions handle booleans, numeric types and string types in a straightforward way. Use SettingsExt::bind_with_mapping if you need a custom mapping, or map between types that are not supported by the default mapping functions.

Unless the flags include SettingsBindFlags::NoSensitivity, this function also establishes a binding between the writability of key and the "sensitive" property of object (if object has a boolean property by that name). See SettingsExt::bind_writable for more details about writable bindings.

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 gobject::Object

property

the name of the property to bind

flags

flags for the binding

fn bind_writable<P: IsA<Object>>(
    &self,
    key: &str,
    object: &P,
    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 gobject::Object

property

the name of a boolean property to bind

inverted

whether to 'invert' the value

fn create_action(&self, key: &str) -> Option<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

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 SettingsExt::apply is called.

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

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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

fn get_child(&self, name: &str) -> Option<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.

name

the name of the child schema

Returns

a 'child' settings object

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

Gets the "default value" of a key.

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

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

Comparing the return values of SettingsExt::get_default_value and SettingsExt::get_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

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

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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

fn get_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

fn get_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

fn get_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

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

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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

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

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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.

Feature: v2_50

key

the key to get the value for

Returns

a 64-bit integer

fn get_string(&self, key: &str) -> Option<GString>

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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

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

A convenience variant of SettingsExt::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.

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

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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

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

Gets the value that is stored at key in self.

A convenience variant of SettingsExt::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.

Feature: v2_50

key

the key to get the value for

Returns

a 64-bit unsigned integer

fn get_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 SettingsExt::reset this function should always return None (assuming something is not wrong with the system configuration).

It is possible that SettingsExt::get_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

fn get_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

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

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 SettingsExt::get_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

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

Introspects the list of keys on self.

You should probably not be calling this function from "normal" code (since you should already know what keys are in your schema). This function is intended for introspection reasons.

You should free the return value with g_strfreev when you are done with it.

Deprecated since 2.46

Use SettingsSchema::list_keys instead.

Returns

a list of the keys on self, in no defined order

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

fn revert(&self)

Reverts all non-applied changes to the settings. This function does nothing unless self is in 'delay-apply' mode; see SettingsExt::delay. In the normal case settings are always applied immediately.

Change notifications will be emitted for affected keys.

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

Sets key in self to value.

A convenience variant of SettingsExt::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

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

Sets key in self to value.

A convenience variant of SettingsExt::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

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 SettingsExt::get_string will return the 'nick' associated with value.

key

a key, within self

value

an enumerated value

Returns

true, if the set succeeds

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 SettingsExt::get_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

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

Sets key in self to value.

A convenience variant of SettingsExt::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

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

Sets key in self to value.

A convenience variant of SettingsExt::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.

Feature: v2_50

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

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

Sets key in self to value.

A convenience variant of SettingsExt::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

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

Sets key in self to value.

A convenience variant of SettingsExt::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

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

Sets key in self to value.

A convenience variant of SettingsExt::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

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

Sets key in self to value.

A convenience variant of SettingsExt::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.

Feature: v2_50

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

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

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

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

fn get_property_delay_apply(&self) -> bool

Whether the Settings object is in 'delay-apply' mode. See SettingsExt::delay for details.

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

The path within the backend where the settings are stored.

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

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

fn get_property_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.

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

The "changed" signal is emitted when a key has potentially changed. You should call one of the SettingsExt::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

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 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.

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

The "writable-changed" signal is emitted when the writability of a key has potentially changed. You should call SettingsExt::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

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

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

Loading content...

Implementors

impl<O: IsA<Settings>> SettingsExt for O[src]

Loading content...