From 53f72632c15261bec26b3ea8e553fc7443725af0 Mon Sep 17 00:00:00 2001 From: Simo Piiroinen Date: Fri, 21 Dec 2018 13:14:39 +0200 Subject: [PATCH] [mce-setting] Add setter for boolean config values Signed-off-by: Simo Piiroinen --- mce-setting.c | 30 ++++++++++++++++++++++++++++++ mce-setting.h | 1 + 2 files changed, 31 insertions(+) diff --git a/mce-setting.c b/mce-setting.c index 4d47b7c6..12d50915 100644 --- a/mce-setting.c +++ b/mce-setting.c @@ -59,6 +59,36 @@ gboolean mce_setting_has_key(const gchar *const key) return res; } +/**Set an boolean GConf key to the specified value + * + * @param key The GConf key to set the value of + * @param value The value to set the key to + * + * @return TRUE on success, FALSE on failure + */ +gboolean mce_setting_set_bool(const gchar *const key, const gboolean value) +{ + gboolean status = FALSE; + + if( gconf_disabled ) { + mce_log(LL_DEBUG, "blocked %s = %d", key, value); + goto EXIT; + } + + if( !gconf_client_set_bool(gconf_client, key, value, NULL) ) { + mce_log(LL_WARN, "Failed to write %s to GConf", key); + goto EXIT; + } + + /* synchronise if possible, ignore errors */ + gconf_client_suggest_sync(gconf_client, NULL); + + status = TRUE; + +EXIT: + return status; +} + /** * Set an integer GConf key to the specified value * diff --git a/mce-setting.h b/mce-setting.h index 2e8ac561..146f810c 100644 --- a/mce-setting.h +++ b/mce-setting.h @@ -77,6 +77,7 @@ typedef enum * ========================================================================= */ gboolean mce_setting_has_key (const gchar *const key); +gboolean mce_setting_set_bool (const gchar *const key, const gboolean value); gboolean mce_setting_set_int (const gchar *const key, const gint value); gboolean mce_setting_set_string (const gchar *const key, const gchar *const value); gboolean mce_setting_get_bool (const gchar *const key, gboolean *value);