glibmm 2.80.0
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
Gio::Settings Class Reference

A high-level API for application settings. More...

#include <giomm/settings.h>

Inheritance diagram for Gio::Settings:
Inheritance graph
[legend]

Public Types

enum class  BindFlags {
  DEFAULT = 0x0 ,
  GET = (1<<0) ,
  SET = (1<<1) ,
  NO_SENSITIVITY = (1<<2) ,
  GET_NO_CHANGES = (1<<3) ,
  INVERT_BOOLEAN = (1<<4)
}
 
template<typename T_from , typename T_to >
using SlotTypedMapping = sigc::slot< std::optional< T_to >(const T_from &)>
 A slot to be called to map values in a binding.
 
- Public Types inherited from Glib::Object
using DestroyNotify = void(*)(gpointer data)
 

Public Member Functions

 Settings (Settings &&src) noexcept
 
Settingsoperator= (Settings &&src) noexcept
 
 ~Settings () noexcept override
 
GSettingsgobj ()
 Provides access to the underlying C GObject.
 
const GSettingsgobj () const
 Provides access to the underlying C GObject.
 
GSettingsgobj_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
 Gets the value that is stored in the settings for a key.
 
bool get_user_value (const Glib::ustring & key, Glib::VariantBase & value) const
 Checks the "user value" of a key, if there is one.
 
void get_default_value (const Glib::ustring & key, Glib::VariantBase & value) const
 Gets the "default value" of a key.
 
int get_int (const Glib::ustring & key) const
 Gets the value that is stored at key in settings.
 
bool set_int (const Glib::ustring & key, int value)
 Sets key in settings to value.
 
gint64 get_int64 (const Glib::ustring & key) const
 Gets the value that is stored at key in settings.
 
bool set_int64 (const Glib::ustring & key, gint64 value)
 Sets key in settings to value.
 
guint get_uint (const Glib::ustring & key) const
 Gets the value that is stored at key in settings.
 
bool set_uint (const Glib::ustring & key, guint value)
 Sets key in settings to value.
 
guint64 get_uint64 (const Glib::ustring & key) const
 Gets the value that is stored at key in settings.
 
bool set_uint64 (const Glib::ustring & key, guint64 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.
 
bool 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.
 
bool 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.
 
bool set_double (const Glib::ustring & key, double value)
 Sets key in settings to value.
 
std::vector< Glib::ustringget_string_array (const Glib::ustring & key) const
 A convenience variant of g_settings_get() for string arrays.
 
bool set_string_array (const Glib::ustring & key, const std::vector< Glib::ustring > & 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 set_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 set_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, within settings.
 
Glib::RefPtr< Settingsget_child (const Glib::ustring & name)
 Creates a child settings object which has a base path of base-path/ @a name, where base-path is the base path of settings.
 
Glib::RefPtr< const Settingsget_child (const Glib::ustring & name) const
 Creates a child settings object which has a base path of base-path/ @a name, where base-path is the base path of settings.
 
bool is_writable (const Glib::ustring & name) 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.
 
std::vector< Glib::ustringlist_children () const
 Gets the list of children on settings.
 
void bind (const Glib::ustring & key, Glib::ObjectBase *object, const Glib::ustring &property, BindFlags flags=BindFlags::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, BindFlags flags=BindFlags::DEFAULT)
 Create a binding between the key in the settings object and the property_proxy.
 
template<typename T_setting , typename T_property >
void bind (const Glib::ustring & key, Glib::ObjectBase *object, const Glib::ustring &property, BindFlags flags, const SlotTypedMapping< T_setting, T_property > &slot_get_mapping, const SlotTypedMapping< T_property, T_setting > &slot_set_mapping)
 Create a binding between the key in the settings object and the property property of object.
 
template<typename T_setting , typename T_property >
void bind (const Glib::ustring & key, const Glib::PropertyProxy_Base &property_proxy, BindFlags flags, const SlotTypedMapping< T_setting, T_property > &slot_get_mapping, const SlotTypedMapping< T_property, T_setting > &slot_set_mapping)
 Create a binding between the key in the settings object and the property_proxy.
 
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)
 Create a binding between the writability of key in the settings object and the property_proxy.
 
Glib::RefPtr< Actioncreate_action (const Glib::ustring & key)
 Creates a Action corresponding to a given Settings key.
 
Glib::PropertyProxy_ReadOnly< bool > property_delay_apply () const
 Whether the Settings object is in 'delay-apply' mode.
 
Glib::PropertyProxy_ReadOnly< bool > property_has_unapplied () const
 If this property is true, the Settings object has outstanding changes that will be applied when g_settings_apply() is called.
 
Glib::PropertyProxy_ReadOnly< std::stringproperty_path () const
 The path within the backend where the settings are stored.
 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_schema_id () const
 The name of the schema that describes the types of keys for this Settings object.
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SettingsSchema > > property_settings_schema () const
 The SettingsSchema describing the types of keys for this Settings object.
 
Glib::SignalProxyDetailed< void(const Glib::ustring &)> signal_changed (const Glib::ustring & key={})
 
Glib::SignalProxy< bool(GQuark)> signal_writable_change_event ()
 
Glib::SignalProxyDetailed< void(const Glib::ustring &)> signal_writable_changed (const Glib::ustring & key={})
 
- Public Member Functions inherited from Glib::Object
 Object (const Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&src) noexcept
 
Objectoperator= (Object &&src) noexcept
 
voidget_data (const QueryQuark & key)
 
void set_data (const Quark & key, void *data)
 
void set_data_with_c_callback (const Quark & key, void *data, GDestroyNotify notify)
 
void set_data (const Quark & key, void *data, DestroyNotify notify)
 Prefer set_data_with_c_callback() with a callback with C linkage.
 
void remove_data (const QueryQuark &quark)
 
voidsteal_data (const QueryQuark &quark)
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring & property_name, const Glib::ValueBase & value)
 You probably want to use a specific property_*() accessor method instead.
 
void get_property_value (const Glib::ustring & property_name, Glib::ValueBase & value) const
 You probably want to use a specific property_*() accessor method instead.
 
template<class PropertyType >
void set_property (const Glib::ustring & property_name, const PropertyType & value)
 You probably want to use a specific property_*() accessor method instead.
 
template<class PropertyType >
void get_property (const Glib::ustring & property_name, PropertyType & value) const
 You probably want to use a specific property_*() accessor method instead.
 
template<class PropertyType >
PropertyType get_property (const Glib::ustring & property_name) const
 You probably want to use a specific property_*() accessor method instead.
 
sigc::connection connect_property_changed (const Glib::ustring & property_name, const sigc::slot< void()> &slot)
 You can use the signal_changed() signal of the property proxy instead.
 
sigc::connection connect_property_changed (const Glib::ustring & property_name, sigc::slot< void()> &&slot)
 You can use the signal_changed() signal of the property proxy instead.
 
void freeze_notify ()
 Increases the freeze count on object.
 
void thaw_notify ()
 Reverts the effect of a previous call to freeze_notify().
 
virtual void reference () const
 Increment the reference count for this object.
 
virtual void unreference () const
 Decrement the reference count for this object.
 
GObject * gobj ()
 Provides access to the underlying C GObject.
 
const GObject * gobj () const
 Provides access to the underlying C GObject.
 
GObject * gobj_copy () const
 Give a ref-ed copy to someone. Use for direct struct access.
 

Static Public Member Functions

static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system.
 
static Glib::RefPtr< Settingscreate (const Glib::ustring &schema_id)
 
static Glib::RefPtr< Settingscreate (const Glib::ustring &schema_id, const Glib::ustring & path)
 
static void unbind (Glib::ObjectBase *object, const Glib::ustring &property)
 Removes an existing binding for property on object.
 
static void unbind (const Glib::PropertyProxy_Base &property_proxy)
 Removes an existing binding for property_proxy.
 

Protected Member Functions

 Settings (const Glib::ustring &schema_id)
 
 Settings (const Glib::ustring &schema_id, const Glib::ustring & path)
 
virtual void on_changed (const Glib::ustring & key)
 This is a default handler for the signal signal_changed().
 
virtual bool on_writable_change_event (GQuark key)
 This is a default handler for the signal signal_writable_change_event().
 
virtual void on_writable_changed (const Glib::ustring & key)
 This is a default handler for the signal signal_writable_changed().
 
- Protected Member Functions inherited from Glib::Object
 Object ()
 
 Object (const Glib::ConstructParams &construct_params)
 
 Object (GObject *castitem)
 
 ~Object () noexcept override
 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor.
 
 ObjectBase (const char *custom_type_name)
 A derived constructor always overrides this choice.
 
 ObjectBase (const std::type_info &custom_type_info)
 This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually.
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

Additional Inherited Members

Detailed Description

A high-level API for application settings.

The Settings class provides a convenient API for storing and retrieving application settings.

Since glibmm 2.28:

Member Typedef Documentation

◆ SlotTypedMapping

A slot to be called to map values in a binding.

For instance:

std::optional<int> map_ustring_to_int(const Glib::ustring& from_string);
Glib::ustring has much the same interface as std::string, but contains Unicode characters encoded as ...
Definition ustring.h:336
Returns
A value of type T_to if the mapping was successful, and an empty optional with no value (i.e. std::nullopt) otherwise.

Member Enumeration Documentation

◆ BindFlags

Enumerator
DEFAULT 

Equivalent to G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET.

GET 

Update the Object property when the setting changes.

It is an error to use this flag if the property is not writable.

SET 

Update the setting when the Object property changes.

It is an error to use this flag if the property is not readable.

NO_SENSITIVITY 

Do not try to bind a "sensitivity" property to the writability of the setting.

GET_NO_CHANGES 

When set in addition to Gio::Settings::BindFlags::GET, set the Object property value initially from the setting, but do not listen for changes of the setting.

INVERT_BOOLEAN 

When passed to g_settings_bind(), uses a pair of mapping functions that invert the boolean value when mapping between the setting and the property.

The setting and property must both be booleans. You cannot pass this flag to g_settings_bind_with_mapping().

Constructor & Destructor Documentation

◆ Settings() [1/3]

Gio::Settings::Settings ( Settings &&  src)
noexcept

◆ ~Settings()

Gio::Settings::~Settings ( )
overridenoexcept

◆ Settings() [2/3]

Gio::Settings::Settings ( const Glib::ustring schema_id)
explicitprotected

◆ Settings() [3/3]

Gio::Settings::Settings ( const Glib::ustring schema_id,
const Glib::ustring path 
)
explicitprotected

Member Function Documentation

◆ apply()

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.

◆ bind() [1/4]

void Gio::Settings::bind ( const Glib::ustring key,
const Glib::PropertyProxy_Base property_proxy,
BindFlags  flags,
const SlotTypedMapping< T_setting, T_property > &  slot_get_mapping,
const SlotTypedMapping< T_property, T_setting > &  slot_set_mapping 
)
inline

Create a binding between the key in the settings object and the property_proxy.

The binding uses the provided mapping functions to map between settings and property values.

Note that the lifecycle of the binding is tied to property_proxy's 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.

The template parameters T_setting and T_property must be explicitly specified in each call. The compiler can't deduce them. For instance:

m_settings->bind<Glib::ustring, unsigned int>("transition",
m_transition->property_selected(), Gio::Settings::BindFlags::DEFAULT,
sigc::mem_fun(*this, &ExampleAppPrefs::map_from_ustring_to_int),
sigc::mem_fun(*this, &ExampleAppPrefs::map_from_int_to_ustring));
@ DEFAULT
Equivalent to G_SETTINGS_BIND_GET|G_SETTINGS_BIND_SET.
Since glibmm 2.76:
Parameters
keyThe key to bind.
property_proxyThe property to bind.
flagsFlags for the binding.
slot_get_mappingA function that gets called to convert values from setting to parameter, or an empty slot to use the default GIO mapping.
slot_set_mappingA function that gets called to convert values from parameter to setting, or an empty slot to use the default GIO mapping.
Template Parameters
T_settingType of the setting. Must be a type that can be stored in a Glib::Variant<T_setting> object.
T_propertyType of the property. Must be a type that can be stored in a Glib::Value<T_property> object.

◆ bind() [2/4]

void Gio::Settings::bind ( const Glib::ustring key,
const Glib::PropertyProxy_Base property_proxy,
BindFlags  flags = BindFlags::DEFAULT 
)

Create a binding between the key in the settings object and the property_proxy.

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 Gio::Settings::BindFlags::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 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.

Parameters
keyThe key to bind.
property_proxyThe property to bind.
flagsFlags for the binding.

◆ bind() [3/4]

void Gio::Settings::bind ( const Glib::ustring key,
Glib::ObjectBase object,
const Glib::ustring property,
BindFlags  flags,
const SlotTypedMapping< T_setting, T_property > &  slot_get_mapping,
const SlotTypedMapping< T_property, T_setting > &  slot_set_mapping 
)
inline

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

The binding uses the provided mapping functions to map between settings and property values.

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.

The template parameters T_setting and T_property must be explicitly specified in each call. The compiler can't deduce them. For instance:

m_settings->bind<Glib::ustring, unsigned int>("transition",
m_transition, "selected", Gio::Settings::BindFlags::DEFAULT,
sigc::mem_fun(*this, &ExampleAppPrefs::map_from_ustring_to_int),
sigc::mem_fun(*this, &ExampleAppPrefs::map_from_int_to_ustring));
Since glibmm 2.76:
Parameters
keyThe key to bind.
objectA Glib::ObjectBase.
propertyThe name of the property to bind.
flagsFlags for the binding.
slot_get_mappingA function that gets called to convert values from setting to parameter, or an empty slot to use the default GIO mapping.
slot_set_mappingA function that gets called to convert values from parameter to setting, or an empty slot to use the default GIO mapping.
Template Parameters
T_settingType of the setting. Must be a type that can be stored in a Glib::Variant<T_setting> object.
T_propertyType of the property. Must be a type that can be stored in a Glib::Value<T_property> object.

◆ bind() [4/4]

void Gio::Settings::bind ( const Glib::ustring key,
Glib::ObjectBase object,
const Glib::ustring property,
BindFlags  flags = BindFlags::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 Gio::Settings::BindFlags::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 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.

Since glibmm 2.26:
Parameters
keyThe key to bind.
objectA Object.
propertyThe name of the property to bind.
flagsFlags for the binding.

◆ bind_writable() [1/2]

void Gio::Settings::bind_writable ( const Glib::ustring key,
const Glib::PropertyProxy_Base property_proxy,
bool  inverted = false 
)

Create a binding between the writability of key in the settings object and the property_proxy.

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

Parameters
keyThe key to bind.
property_proxyThe boolean property to bind.
invertedWhether to 'invert' the value.

◆ bind_writable() [2/2]

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

Since glibmm 2.26:
Parameters
keyThe key to bind.
objectA Object.
propertyThe name of a boolean property to bind.
invertedWhether to 'invert' the value.

◆ create() [1/2]

static Glib::RefPtr< Settings > Gio::Settings::create ( const Glib::ustring schema_id)
static

◆ create() [2/2]

static Glib::RefPtr< Settings > Gio::Settings::create ( const Glib::ustring schema_id,
const Glib::ustring path 
)
static

◆ create_action()

Glib::RefPtr< Action > Gio::Settings::create_action ( const Glib::ustring key)

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

Since glibmm 2.32:
Parameters
keyThe name of a key in settings.
Returns
A new Action.

◆ delay()

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.

Since glibmm 2.26:

◆ get_boolean()

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.

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
A boolean.

◆ get_child() [1/2]

Glib::RefPtr< Settings > Gio::Settings::get_child ( const Glib::ustring name)

Creates a child settings object which has a base path of base-path/ @a name, where base-path is the base path of settings.

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

The created child settings object will inherit the Settings::property_delay_apply() mode from settings.

Since glibmm 2.26:
Parameters
nameThe name of the child schema.
Returns
A 'child' settings object.

◆ get_child() [2/2]

Glib::RefPtr< const Settings > Gio::Settings::get_child ( const Glib::ustring name) const

Creates a child settings object which has a base path of base-path/ @a name, where base-path is the base path of settings.

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

The created child settings object will inherit the Settings::property_delay_apply() mode from settings.

Since glibmm 2.26:
Parameters
nameThe name of the child schema.
Returns
A 'child' settings object.

◆ get_default_value()

void Gio::Settings::get_default_value ( const Glib::ustring key,
Glib::VariantBase value 
) const

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 get_default_value() if the system administrator has provided a default value.

Comparing the return values of get_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 method 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 the settings.

Parameters
keyThe key to get the default value for.
valueA Variant of the expected type.
Since glibmm 2.40:

◆ get_double()

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.

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
A double.

◆ get_enum()

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.

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
The enum value.

◆ get_flags()

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

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
The flags value.

◆ get_has_unapplied()

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.

Since glibmm 2.26:
Returns
true if settings has unapplied changes.

◆ get_int()

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.

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
An integer.

◆ get_int64()

gint64 Gio::Settings::get_int64 ( const Glib::ustring key) const

Gets the value that is stored at key in settings.

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

Since glibmm 2.50:
Parameters
keyThe key to get the value for.
Returns
A 64-bit integer.

◆ get_string()

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.

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
A newly-allocated string.

◆ get_string_array()

std::vector< Glib::ustring > Gio::Settings::get_string_array ( const Glib::ustring key) const

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.

Since glibmm 2.26:
Parameters
keyThe key to get the value for.
Returns
A newly-allocated, nullptr-terminated array of strings, the value that is stored at key in settings.

◆ get_type()

static GType Gio::Settings::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ get_uint()

guint Gio::Settings::get_uint ( 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 unsigned integers.

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

Since glibmm 2.30:
Parameters
keyThe key to get the value for.
Returns
An unsigned integer.

◆ get_uint64()

guint64 Gio::Settings::get_uint64 ( const Glib::ustring key) const

Gets the value that is stored at key in settings.

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

Since glibmm 2.50:
Parameters
keyThe key to get the value for.
Returns
A 64-bit unsigned integer.

◆ get_user_value()

bool Gio::Settings::get_user_value ( const Glib::ustring key,
Glib::VariantBase value 
) const

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 false (assuming something is not wrong with the system configuration).

It is possible that get_value() will return a different value than this method. 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 method will return the user's old value.

This method 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 the settings.

Parameters
keyThe key to get the user value for.
valueA Variant of the expected type.
Returns
true if a user value was found.
Since glibmm 2.40:

◆ get_value()

void Gio::Settings::get_value ( const Glib::ustring key,
Glib::VariantBase value 
) const

Gets the value that is stored in the settings for a key.

It is a programmer error to give a key that isn't contained in the schema for the settings.

Parameters
keyThe key to get the value for.
valueA Variant of the expected type.
Since glibmm 2.28:

◆ gobj() [1/2]

GSettings * Gio::Settings::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GSettings * Gio::Settings::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ gobj_copy()

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.

◆ is_writable()

bool Gio::Settings::is_writable ( const Glib::ustring name) const

Finds out if a key can be written or not.

Since glibmm 2.26:
Parameters
nameThe name of a key.
Returns
true if the key name is writable.

◆ list_children()

std::vector< Glib::ustring > Gio::Settings::list_children ( ) const

Gets the list of children on settings.

The list is exactly the list of strings for which it is not an error to call g_settings_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.

Returns
A list of the children on settings, in no defined order.

◆ on_changed()

virtual void Gio::Settings::on_changed ( const Glib::ustring key)
protectedvirtual

This is a default handler for the signal signal_changed().

◆ on_writable_change_event()

virtual bool Gio::Settings::on_writable_change_event ( GQuark  key)
protectedvirtual

This is a default handler for the signal signal_writable_change_event().

◆ on_writable_changed()

virtual void Gio::Settings::on_writable_changed ( const Glib::ustring key)
protectedvirtual

This is a default handler for the signal signal_writable_changed().

◆ operator=()

Settings & Gio::Settings::operator= ( Settings &&  src)
noexcept

◆ property_delay_apply()

Glib::PropertyProxy_ReadOnly< bool > Gio::Settings::property_delay_apply ( ) const

Whether the Settings object is in 'delay-apply' mode.

See g_settings_delay() for details.

Since glibmm 2.28:

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_has_unapplied()

Glib::PropertyProxy_ReadOnly< bool > Gio::Settings::property_has_unapplied ( ) const

If this property is true, the Settings object has outstanding changes that will be applied when g_settings_apply() is called.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_path()

Glib::PropertyProxy_ReadOnly< std::string > Gio::Settings::property_path ( ) const

The path within the backend where the settings are stored.

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_schema_id()

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gio::Settings::property_schema_id ( ) const

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

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_settings_schema()

Glib::PropertyProxy_ReadOnly< Glib::RefPtr< SettingsSchema > > Gio::Settings::property_settings_schema ( ) const

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.

Since glibmm 2.58:
Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ reset()

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 be the value specified in the schema or the one set by the administrator.

Parameters
keyThe name of a key.

◆ revert()

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.

◆ set_boolean()

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

Since glibmm 2.26:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_double()

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

Since glibmm 2.26:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_enum()

bool Gio::Settings::set_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.

Parameters
keyA key, within settings.
valueAn enumerated value.
Returns
true, if the set succeeds.

◆ set_flags()

bool Gio::Settings::set_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, 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 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.

Parameters
keyA key, within settings.
valueA flags value.
Returns
true, if the set succeeds.

◆ set_int()

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

Since glibmm 2.26:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_int64()

bool Gio::Settings::set_int64 ( const Glib::ustring key,
gint64  value 
)

Sets key in settings 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 settings.

Since glibmm 2.50:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_string()

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

Since glibmm 2.26:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_string_array()

bool Gio::Settings::set_string_array ( const Glib::ustring key,
const std::vector< Glib::ustring > &  value 
)

Sets key in settings to value.

A convenience variant of g_settings_set() for string arrays. If value is nullptr, 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.

Since glibmm 2.26:
Parameters
keyThe name of the key to set.
valueThe value to set it to, or nullptr.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_uint()

bool Gio::Settings::set_uint ( const Glib::ustring key,
guint  value 
)

Sets key in settings 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 settings.

Since glibmm 2.30:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_uint64()

bool Gio::Settings::set_uint64 ( const Glib::ustring key,
guint64  value 
)

Sets key in settings 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 settings.

Since glibmm 2.50:
Parameters
keyThe name of the key to set.
valueThe value to set it to.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ set_value()

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.

Since glibmm 2.26:
Parameters
keyThe name of the key to set.
valueA Variant of the correct type.
Returns
true if setting the key succeeded, false if the key was not writable.

◆ signal_changed()

Glib::SignalProxyDetailed< void(const Glib::ustring &)> Gio::Settings::signal_changed ( const Glib::ustring key = {})
Slot Prototype:
void on_my_changed(const Glib::ustring& key)

Flags: Run Last

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.

Parameters
keyThe name of the key that changed.

◆ signal_writable_change_event()

Glib::SignalProxy< bool(GQuark)> Gio::Settings::signal_writable_change_event ( )
Slot Prototype:
bool on_my_writable_change_event(GQuark key)

Flags: Run Last

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

Parameters
keyThe quark of the key, or 0.
Returns
true to stop other handlers from being invoked for the event. false to propagate the event further.

◆ signal_writable_changed()

Glib::SignalProxyDetailed< void(const Glib::ustring &)> Gio::Settings::signal_writable_changed ( const Glib::ustring key = {})
Slot Prototype:
void on_my_writable_changed(const Glib::ustring& key)

Flags: Run Last

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

Parameters
keyThe key.

◆ unbind() [1/2]

static void Gio::Settings::unbind ( const Glib::PropertyProxy_Base property_proxy)
static

Removes an existing binding for property_proxy.

Note that bindings are automatically removed when the object is finalized, so it is rarely necessary to call this function.

Since glibmm 2.76:
Parameters
property_proxyThe property whose binding is removed.

◆ unbind() [2/2]

static void Gio::Settings::unbind ( Glib::ObjectBase object,
const Glib::ustring property 
)
static

Removes an existing binding for property on object.

Note that bindings are automatically removed when the object is finalized, so it is rarely necessary to call this function.

Since glibmm 2.76:
Parameters
objectThe object.
propertyThe property whose binding is removed.