Skip to content

Commit

Permalink
[mce-setting] Add setter for boolean config values
Browse files Browse the repository at this point in the history
Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Dec 21, 2018
1 parent 76ce391 commit 53f7263
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions mce-setting.c
Expand Up @@ -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
*
Expand Down
1 change: 1 addition & 0 deletions mce-setting.h
Expand Up @@ -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);
Expand Down

0 comments on commit 53f7263

Please sign in to comment.