A high-level API for application settings. More...
#include <giomm/settings.h>
Public Member Functions | |
virtual | ~Settings () |
GSettings* | gobj () |
Provides access to the underlying C GObject. | |
const GSettings* | gobj () const |
Provides access to the underlying C GObject. | |
GSettings* | gobj_copy () |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
bool | set_value (const Glib::ustring& key, const Glib::VariantBase&value) |
Sets key in settings to value. | |
void | get_value (const Glib::ustring& key, Glib::VariantBase&value) const |
TODO: Documentation. | |
int | get_int (const Glib::ustring& key) const |
Gets the value that is stored at key in settings. | |
void | set_int (const Glib::ustring& key, int value) |
Sets key in settings to value. | |
bool | get_boolean (const Glib::ustring& key) const |
Gets the value that is stored at key in settings. | |
void | set_boolean (const Glib::ustring& key, bool value) |
Sets key in settings to value. | |
Glib::ustring | get_string (const Glib::ustring& key) const |
Gets the value that is stored at key in settings. | |
void | set_string (const Glib::ustring& key, const Glib::ustring&value) |
Sets key in settings to value. | |
double | get_double (const Glib::ustring& key) const |
Gets the value that is stored at key in settings. | |
void | set_double (const Glib::ustring& key, double value) |
Sets key in settings to value. | |
Glib::StringArrayHandle | get_string_array (const Glib::ustring& key) const |
Gets the value that is stored at key in settings. | |
bool | set_string_array (const Glib::ustring& key, const Glib::StringArrayHandle&value) |
Sets key in settings to value. | |
int | get_enum (const Glib::ustring& key) const |
Gets the value that is stored in settings for key and converts it to the enum value that it represents. | |
bool | get_enum (const Glib::ustring& key, int value) |
Looks up the enumerated type nick for value and writes it to key, within settings. | |
guint | get_flags (const Glib::ustring& key) const |
Gets the value that is stored in settings for key and converts it to the flags value that it represents. | |
bool | get_flags (const Glib::ustring& key, guint value) |
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, withing settings. | |
Glib::RefPtr< Settings > | get_child (const Glib::ustring& name) |
Creates a 'child' settings object which has a base path of <replaceable>base-path</replaceable>/ name", where <replaceable>base-path</replaceable> is the base path of settings. | |
Glib::RefPtr< const Settings > | get_child (const Glib::ustring& name) const |
Creates a 'child' settings object which has a base path of <replaceable>base-path</replaceable>/ name", where <replaceable>base-path</replaceable> is the base path of settings. | |
bool | is_writable (const Glib::ustring& key) const |
Finds out if a key can be written or not. | |
void | delay () |
Changes the Settings object into 'delay-apply' mode. | |
void | apply () |
Applies any changes that have been made to the settings. | |
void | revert () |
Reverts all non-applied changes to the settings. | |
bool | get_has_unapplied () const |
Returns whether the Settings object has any unapplied changes. | |
void | reset (const Glib::ustring& key) |
Resets key to its default value. | |
Glib::StringArrayHandle | list_children () const |
Glib::StringArrayHandle | list_keys () const |
void | bind (const Glib::ustring& key, Glib::ObjectBase* object, const Glib::ustring& property, SettingsBindFlags flags=SETTINGS_BIND_DEFAULT) |
Create a binding between the key in the settings object and the property property of object. | |
void | bind (const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, SettingsBindFlags flags=SETTINGS_BIND_DEFAULT) |
void | bind_writable (const Glib::ustring& key, Glib::ObjectBase* object, const Glib::ustring& property, bool inverted=false) |
Create a binding between the writability of key in the settings object and the property property of object. | |
void | bind_writable (const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, bool inverted=false) |
Glib::SignalProxy1< void, const Glib::ustring& > | signal_changed () |
Glib::SignalProxy1< bool, guint > | signal_writable_change_event () |
Glib::SignalProxy1< void, const Glib::ustring& > | signal_writable_changed () |
Static Public Member Functions | |
static Glib::RefPtr< Settings > | create (const Glib::ustring& schema) |
static Glib::RefPtr< Settings > | create (const Glib::ustring& schema, const Glib::ustring& path) |
static Glib::RefPtr< Settings > | create (const Glib::ustring& schema, const Glib::RefPtr< SettingsBackend >& backend) |
static Glib::RefPtr< Settings > | create (const Glib::ustring& schema, const Glib::RefPtr< SettingsBackend >& backend, const Glib::ustring& path) |
Protected Member Functions | |
Settings (const Glib::ustring& schema) | |
Settings (const Glib::ustring& schema, const Glib::ustring& path) | |
Settings (const Glib::ustring& schema, const Glib::RefPtr< SettingsBackend >& backend) | |
Settings (const Glib::ustring& schema, const Glib::RefPtr< SettingsBackend >& backend, const Glib::ustring& path) | |
virtual void | on_changed (const Glib::ustring& key) |
virtual bool | on_writable_change_event (guint key) |
virtual void | on_writable_changed (const Glib::ustring& key) |
Related Functions | |
(Note that these are not member functions.) | |
Glib::RefPtr< Gio::Settings > | wrap (GSettings* object, bool take_copy=false) |
A Glib::wrap() method for this object. |
A high-level API for application settings.
The Settings class provides a convenient API for storing and retrieving application settings.
virtual Gio::Settings::~Settings | ( | ) | [virtual] |
Gio::Settings::Settings | ( | const Glib::ustring& | schema | ) | [explicit, protected] |
Gio::Settings::Settings | ( | const Glib::ustring& | schema, | |
const Glib::ustring& | path | |||
) | [explicit, protected] |
Gio::Settings::Settings | ( | const Glib::ustring& | schema, | |
const Glib::RefPtr< SettingsBackend >& | backend | |||
) | [explicit, protected] |
Gio::Settings::Settings | ( | const Glib::ustring& | schema, | |
const Glib::RefPtr< SettingsBackend >& | backend, | |||
const Glib::ustring& | path | |||
) | [explicit, protected] |
void Gio::Settings::apply | ( | ) |
Applies any changes that have been made to the settings.
This function does nothing unless settings is in 'delay-apply' mode; see g_settings_delay(). In the normal case settings are always applied immediately.
void Gio::Settings::bind | ( | const Glib::ustring& | key, | |
const Glib::PropertyProxy_Base& | property_proxy, | |||
SettingsBindFlags | flags = SETTINGS_BIND_DEFAULT | |||
) |
void Gio::Settings::bind | ( | const Glib::ustring& | key, | |
Glib::ObjectBase* | object, | |||
const Glib::ustring& | property, | |||
SettingsBindFlags | flags = SETTINGS_BIND_DEFAULT | |||
) |
Create a binding between the key in the settings 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 g_settings_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 SETTINGS_BIND_NO_SENSITIVITY, 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 g_settings_bind_writable() for more details about writable bindings.
Note that the lifecycle of the binding is tied to the 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 Object. | |
property | The name of the property to bind. | |
flags | Flags for the binding. |
void Gio::Settings::bind_writable | ( | const Glib::ustring& | key, | |
const Glib::PropertyProxy_Base& | property_proxy, | |||
bool | inverted = false | |||
) |
void Gio::Settings::bind_writable | ( | const Glib::ustring& | key, | |
Glib::ObjectBase* | object, | |||
const Glib::ustring& | property, | |||
bool | inverted = false | |||
) |
Create a binding between the writability of key in the settings 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 <emphasis>not</emphasis> writable.
Note that the lifecycle of the binding is tied to the 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 Object. | |
property | The name of a boolean property to bind. | |
inverted | Whether to 'invert' the value. |
static Glib::RefPtr<Settings> Gio::Settings::create | ( | const Glib::ustring& | schema, | |
const Glib::RefPtr< SettingsBackend >& | backend, | |||
const Glib::ustring& | path | |||
) | [static] |
static Glib::RefPtr<Settings> Gio::Settings::create | ( | const Glib::ustring& | schema, | |
const Glib::RefPtr< SettingsBackend >& | backend | |||
) | [static] |
static Glib::RefPtr<Settings> Gio::Settings::create | ( | const Glib::ustring& | schema, | |
const Glib::ustring& | path | |||
) | [static] |
static Glib::RefPtr<Settings> Gio::Settings::create | ( | const Glib::ustring& | schema | ) | [static] |
void Gio::Settings::delay | ( | ) |
Changes the Settings object into 'delay-apply' mode.
In this mode, changes to settings are not immediately propagated to the backend, but kept locally until g_settings_apply() is called.
bool Gio::Settings::get_boolean | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored at key in settings.
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 settings.
key | The key to get the value for. |
Glib::RefPtr<const Settings> Gio::Settings::get_child | ( | const Glib::ustring& | name | ) | const |
Creates a 'child' settings object which has a base path of <replaceable>base-path</replaceable>/ name", where <replaceable>base-path</replaceable> is the base path of settings.
The schema for the child settings object must have been declared in the schema of settings using a <tag class="starttag">child</tag> element.
name | The name of the 'child' schema. |
Glib::RefPtr<Settings> Gio::Settings::get_child | ( | const Glib::ustring& | name | ) |
Creates a 'child' settings object which has a base path of <replaceable>base-path</replaceable>/ name", where <replaceable>base-path</replaceable> is the base path of settings.
The schema for the child settings object must have been declared in the schema of settings using a <tag class="starttag">child</tag> element.
name | The name of the 'child' schema. |
double Gio::Settings::get_double | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored at key in settings.
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 settings.
key | The key to get the value for. |
bool Gio::Settings::get_enum | ( | const Glib::ustring& | key, | |
int | value | |||
) |
Looks up the enumerated type nick for value and writes it to key, within settings.
It is a programmer error to give a key that isn't contained in the schema for settings 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 g_settings_get_string() will return the 'nick' associated with value.
key | A key, within settings. | |
value | An enumerated value. |
true
, if the set succeeds. int Gio::Settings::get_enum | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored in settings 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 settings 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. |
bool Gio::Settings::get_flags | ( | const Glib::ustring& | key, | |
guint | value | |||
) |
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, withing settings.
It is a programmer error to give a key that isn't contained in the schema for settings 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 g_settings_get_strv() will return an array of 'nicks'; one for each bit in value.
key | A key, within settings. | |
value | A flags value. |
true
, if the set succeeds. guint Gio::Settings::get_flags | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored in settings 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 an flags type.
It is a programmer error to give a key that isn't contained in the schema for settings 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. |
bool Gio::Settings::get_has_unapplied | ( | ) | const |
Returns whether the Settings object has any unapplied changes.
This can only be the case if it is in 'delayed-apply' mode.
true
if settings has unapplied changes. int Gio::Settings::get_int | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored at key in settings.
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 settings.
key | The key to get the value for. |
Glib::ustring Gio::Settings::get_string | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored at key in settings.
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 settings.
key | The key to get the value for. |
Glib::StringArrayHandle Gio::Settings::get_string_array | ( | const Glib::ustring& | key | ) | const |
Gets the value that is stored at key in settings.
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 settings.
key | The key to get the value for. |
0
-terminated array of strings. void Gio::Settings::get_value | ( | const Glib::ustring& | key, | |
Glib::VariantBase& | value | |||
) | const |
TODO: Documentation.
const GSettings* Gio::Settings::gobj | ( | ) | const [inline] |
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase.
GSettings* Gio::Settings::gobj | ( | ) | [inline] |
Provides access to the underlying C GObject.
Reimplemented from Glib::ObjectBase.
GSettings* Gio::Settings::gobj_copy | ( | ) |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool Gio::Settings::is_writable | ( | const Glib::ustring& | key | ) | const |
Finds out if a key can be written or not.
name | The name of a key. |
true
if the key name is writable. Glib::StringArrayHandle Gio::Settings::list_children | ( | ) | const |
Glib::StringArrayHandle Gio::Settings::list_keys | ( | ) | const |
virtual void Gio::Settings::on_changed | ( | const Glib::ustring& | key | ) | [protected, virtual] |
virtual bool Gio::Settings::on_writable_change_event | ( | guint | key | ) | [protected, virtual] |
virtual void Gio::Settings::on_writable_changed | ( | const Glib::ustring& | key | ) | [protected, virtual] |
void Gio::Settings::reset | ( | const Glib::ustring& | key | ) |
Resets key to its default value.
This call resets the key, as much as possible, to its default value. That might the value specified in the schema or the one set by the administrator.
key | The name of a key. |
void Gio::Settings::revert | ( | ) |
Reverts all non-applied changes to the settings.
This function does nothing unless settings is in 'delay-apply' mode; see g_settings_delay(). In the normal case settings are always applied immediately.
Change notifications will be emitted for affected keys.
void Gio::Settings::set_boolean | ( | const Glib::ustring& | key, | |
bool | value | |||
) |
Sets key in settings 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 settings.
key | The name of the key to set. | |
value | The value to set it to. |
true
if setting the key succeeded, false
if the key was not writable. void Gio::Settings::set_double | ( | const Glib::ustring& | key, | |
double | value | |||
) |
Sets key in settings 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 settings.
key | The name of the key to set. | |
value | The value to set it to. |
true
if setting the key succeeded, false
if the key was not writable. void Gio::Settings::set_int | ( | const Glib::ustring& | key, | |
int | value | |||
) |
Sets key in settings 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 settings.
key | The name of the key to set. | |
value | The value to set it to. |
true
if setting the key succeeded, false
if the key was not writable. void Gio::Settings::set_string | ( | const Glib::ustring& | key, | |
const Glib::ustring& | value | |||
) |
Sets key in settings 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 settings.
key | The name of the key to set. | |
value | The value to set it to. |
true
if setting the key succeeded, false
if the key was not writable. bool Gio::Settings::set_string_array | ( | const Glib::ustring& | key, | |
const Glib::StringArrayHandle& | value | |||
) |
Sets key in settings to value.
A convenience variant of g_settings_set() for string arrays. If value is 0
, 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 settings.
key | The name of the key to set. | |
value | The value to set it to, or 0 . |
true
if setting the key succeeded, false
if the key was not writable. bool Gio::Settings::set_value | ( | const Glib::ustring& | key, | |
const Glib::VariantBase& | value | |||
) |
Sets key in settings to value.
It is a programmer error to give a key that isn't contained in the schema for settings 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 Variant of the correct type. |
true
if setting the key succeeded, false
if the key was not writable. Glib::SignalProxy1< void,const Glib::ustring& > Gio::Settings::signal_changed | ( | ) |
void on_my_changed(const Glib::ustring& key)
Glib::SignalProxy1< bool,guint > Gio::Settings::signal_writable_change_event | ( | ) |
bool on_my_writable_change_event(guint key)
Glib::SignalProxy1< void,const Glib::ustring& > Gio::Settings::signal_writable_changed | ( | ) |
void on_my_writable_changed(const Glib::ustring& key)
Glib::RefPtr< Gio::Settings > wrap | ( | GSettings * | object, | |
bool | take_copy = false | |||
) | [related] |
A Glib::wrap() method for this object.
object | The C instance. | |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |