X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-conf.c;h=835d2873abd8ba803274fa1acadfa14034e92dd8;hp=e8fc81892a4f959dec6fe92e2ac3bf52a8b4e238;hb=4d39841513a3a7f7aa9d38ab97cb9fcc9171e80b;hpb=9a50aa1fcb88365c321552e395232846dfe06ea0 diff --git a/src/modest-conf.c b/src/modest-conf.c index e8fc818..835d287 100644 --- a/src/modest-conf.c +++ b/src/modest-conf.c @@ -31,7 +31,9 @@ #include #include #include +#include "modest-defs.h" #include "modest-conf.h" +#include "modest-error.h" #include "modest-marshal.h" #include @@ -134,13 +136,16 @@ modest_conf_init (ModestConf *obj) &error); /* Notify every change under namespace */ - if (!error) + if (!error) { gconf_client_notify_add (priv->gconf_client, "/apps/modest", modest_conf_on_change, obj, NULL, &error); + } else { + g_error_free (error); + } } static void @@ -207,6 +212,18 @@ modest_conf_get_int (ModestConf* self, const gchar* key, GError **err) return gconf_client_get_int (priv->gconf_client, key, err); } +gdouble +modest_conf_get_float (ModestConf* self, const gchar* key, GError **err) +{ + ModestConfPrivate *priv; + + g_return_val_if_fail (self, -1); + g_return_val_if_fail (key, -1); + + priv = MODEST_CONF_GET_PRIVATE(self); + + return gconf_client_get_float (priv->gconf_client, key, err); +} gboolean modest_conf_get_bool (ModestConf* self, const gchar* key, GError **err) @@ -281,6 +298,27 @@ modest_conf_set_int (ModestConf* self, const gchar* key, gint val, return gconf_client_set_int (priv->gconf_client, key, val, err); } +gboolean +modest_conf_set_float (ModestConf* self, + const gchar* key, + gdouble val, + GError **err) +{ + ModestConfPrivate *priv; + + g_return_val_if_fail (self,FALSE); + g_return_val_if_fail (key, FALSE); + + priv = MODEST_CONF_GET_PRIVATE(self); + + if (!gconf_client_key_is_writable(priv->gconf_client,key,err)) { + g_printerr ("modest: '%s' is not writable\n", key); + return FALSE; + } + + return gconf_client_set_float (priv->gconf_client, key, val, err); +} + gboolean modest_conf_set_bool (ModestConf* self, const gchar* key, gboolean val, @@ -438,11 +476,12 @@ modest_conf_type_to_gconf_type (ModestConfValueType value_type, GError **err) gconf_type = GCONF_VALUE_STRING; break; default: - /* FIXME: use MODEST_ERROR, and error code */ gconf_type = GCONF_VALUE_INVALID; g_printerr ("modest: invalid list value type %d\n", value_type); - *err = g_error_new_literal (0, 0, "invalid list value type"); - } + *err = g_error_new_literal (MODEST_CONF_ERROR, + MODEST_CONF_ERROR_INVALID_VALUE, + "invalid list value type"); + } return gconf_type; }