mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
Add 'uint' convenience functions for GSettings
Without getting into a debate about the reasons why you may or may not want to use unsigned integers, it's sufficient to note that people have been using them and requesting this functionality. Bug #641755.
This commit is contained in:
parent
e9ce8f2374
commit
49fa69e05e
@ -2217,6 +2217,8 @@ g_settings_get_boolean
|
||||
g_settings_set_boolean
|
||||
g_settings_get_int
|
||||
g_settings_set_int
|
||||
g_settings_get_uint
|
||||
g_settings_set_uint
|
||||
g_settings_get_double
|
||||
g_settings_set_double
|
||||
g_settings_get_string
|
||||
|
@ -1592,6 +1592,8 @@ g_settings_set_value
|
||||
g_settings_unbind
|
||||
g_settings_get_int
|
||||
g_settings_set_int
|
||||
g_settings_get_uint
|
||||
g_settings_set_uint
|
||||
g_settings_get_string
|
||||
g_settings_set_string
|
||||
g_settings_get_strv
|
||||
|
@ -1817,6 +1817,62 @@ g_settings_set_int (GSettings *settings,
|
||||
return g_settings_set_value (settings, key, g_variant_new_int32 (value));
|
||||
}
|
||||
|
||||
/**
|
||||
* g_settings_get_uint:
|
||||
* @settings: a #GSettings object
|
||||
* @key: the key to get the value for
|
||||
* @returns: an unsigned integer
|
||||
*
|
||||
* 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: 2.30
|
||||
*/
|
||||
guint
|
||||
g_settings_get_uint (GSettings *settings,
|
||||
const gchar *key)
|
||||
{
|
||||
GVariant *value;
|
||||
guint result;
|
||||
|
||||
value = g_settings_get_value (settings, key);
|
||||
result = g_variant_get_uint32 (value);
|
||||
g_variant_unref (value);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* g_settings_set_uint:
|
||||
* @settings: a #GSettings object
|
||||
* @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
|
||||
*
|
||||
* 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: 2.30
|
||||
*/
|
||||
gboolean
|
||||
g_settings_set_uint (GSettings *settings,
|
||||
const gchar *key,
|
||||
guint value)
|
||||
{
|
||||
return g_settings_set_value (settings, key, g_variant_new_uint32 (value));
|
||||
}
|
||||
|
||||
/**
|
||||
* g_settings_get_double:
|
||||
* @settings: a #GSettings object
|
||||
|
@ -110,6 +110,11 @@ gint g_settings_get_int (GSettin
|
||||
gboolean g_settings_set_int (GSettings *settings,
|
||||
const gchar *key,
|
||||
gint value);
|
||||
guint g_settings_get_uint (GSettings *settings,
|
||||
const gchar *key);
|
||||
gboolean g_settings_set_uint (GSettings *settings,
|
||||
const gchar *key,
|
||||
guint value);
|
||||
gchar * g_settings_get_string (GSettings *settings,
|
||||
const gchar *key);
|
||||
gboolean g_settings_set_string (GSettings *settings,
|
||||
|
Loading…
Reference in New Issue
Block a user