gsettings: add get/set_{,u}int64

https://bugzilla.gnome.org/show_bug.cgi?id=755898

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
This commit is contained in:
Marc-Antoine Perennou
2015-09-21 13:02:45 +02:00
parent 210a9796f7
commit 5cea1c861d
4 changed files with 142 additions and 0 deletions

View File

@@ -1873,6 +1873,62 @@ g_settings_set_int (GSettings *settings,
return g_settings_set_value (settings, key, g_variant_new_int32 (value));
}
/**
* g_settings_get_int64:
* @settings: a #GSettings object
* @key: the key to get the value for
*
* 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.
*
* Returns: a 64-bit integer
*
* Since: 2.50
*/
gint64
g_settings_get_int64 (GSettings *settings,
const gchar *key)
{
GVariant *value;
gint64 result;
value = g_settings_get_value (settings, key);
result = g_variant_get_int64 (value);
g_variant_unref (value);
return result;
}
/**
* g_settings_set_int64:
* @settings: a #GSettings object
* @key: the name of the key to set
* @value: the value to set it to
*
* 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.
*
* Returns: %TRUE if setting the key succeeded,
* %FALSE if the key was not writable
*
* Since: 2.50
*/
gboolean
g_settings_set_int64 (GSettings *settings,
const gchar *key,
gint64 value)
{
return g_settings_set_value (settings, key, g_variant_new_int64 (value));
}
/**
* g_settings_get_uint:
* @settings: a #GSettings object
@@ -1931,6 +1987,64 @@ g_settings_set_uint (GSettings *settings,
return g_settings_set_value (settings, key, g_variant_new_uint32 (value));
}
/**
* g_settings_get_uint64:
* @settings: a #GSettings object
* @key: the key to get the value for
*
* 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.
*
* Returns: a 64-bit unsigned integer
*
* Since: 2.50
*/
guint64
g_settings_get_uint64 (GSettings *settings,
const gchar *key)
{
GVariant *value;
guint64 result;
value = g_settings_get_value (settings, key);
result = g_variant_get_uint64 (value);
g_variant_unref (value);
return result;
}
/**
* g_settings_set_uint64:
* @settings: a #GSettings object
* @key: the name of the key to set
* @value: the value to set it to
*
* 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.
*
* Returns: %TRUE if setting the key succeeded,
* %FALSE if the key was not writable
*
* Since: 2.50
*/
gboolean
g_settings_set_uint64 (GSettings *settings,
const gchar *key,
guint64 value)
{
return g_settings_set_value (settings, key, g_variant_new_uint64 (value));
}
/**
* g_settings_get_double:
* @settings: a #GSettings object