aboutsummaryrefslogtreecommitdiffstats
path: root/mail/mail-composer-prefs.c
diff options
context:
space:
mode:
Diffstat (limited to 'mail/mail-composer-prefs.c')
-rw-r--r--mail/mail-composer-prefs.c39
1 files changed, 21 insertions, 18 deletions
diff --git a/mail/mail-composer-prefs.c b/mail/mail-composer-prefs.c
index cf59aa5fbd..3cf3d6e3b3 100644
--- a/mail/mail-composer-prefs.c
+++ b/mail/mail-composer-prefs.c
@@ -565,6 +565,11 @@ spell_get_ui (MailComposerPrefs *prefs)
prefs->language_str = spell_get_language_str (prefs);
}
+#define GET(t,x,prop,f,c) \
+ val = gconf_client_get_without_default (prefs->gconf, GNOME_SPELL_GCONF_DIR x, NULL); \
+ if (val) { f; prop = c (gconf_value_get_ ## t (val)); \
+ gconf_value_free (val); }
+
static void
spell_save_orig (MailComposerPrefs *prefs)
{
@@ -585,7 +590,6 @@ static void
spell_load_values (MailComposerPrefs *prefs)
{
GConfValue *val;
- gchar *str_color;
char *def_lang;
def_lang = g_strdup (e_iconv_locale_language ());
@@ -594,15 +598,13 @@ spell_load_values (MailComposerPrefs *prefs)
prefs->spell_error_color.red = 0xffff;
prefs->spell_error_color.green = 0;
prefs->spell_error_color.blue = 0;
-
- str_color = gconf_client_get_string (prefs->gconf, "/apps/evolution/mail/composer/spell_error_color", NULL);
- gdk_color_parse (str_color, &prefs->spell_error_color);
-
- val = gconf_client_get_without_default (prefs->gconf, "/apps/evolution/mail/composer/spell_language", NULL);
- if (val) {
- prefs->language_str = g_strdup (gconf_value_get_string (val));
- gconf_value_free (val);
- } else
+
+ GET (int, "/spell_error_color_red", prefs->spell_error_color.red, (void)0, (int));
+ GET (int, "/spell_error_color_green", prefs->spell_error_color.green, (void)0, (int));
+ GET (int, "/spell_error_color_blue", prefs->spell_error_color.blue, (void)0, (int));
+ GET (string, "/language", prefs->language_str, g_free (prefs->language_str), g_strdup);
+
+ if (prefs->language_str == NULL)
prefs->language_str = g_strdup (def_lang);
spell_save_orig (prefs);
@@ -610,22 +612,23 @@ spell_load_values (MailComposerPrefs *prefs)
g_free (def_lang);
}
+#define SET(t,x,prop) \
+ gconf_client_set_ ## t (prefs->gconf, GNOME_SPELL_GCONF_DIR x, prop, NULL);
+
#define STR_EQUAL(str1, str2) ((str1 == NULL && str2 == NULL) || (str1 && str2 && !strcmp (str1, str2)))
static void
spell_save_values (MailComposerPrefs *prefs, gboolean force)
{
if (force || !gdk_color_equal (&prefs->spell_error_color, &prefs->spell_error_color_orig)) {
- gchar *str_color = g_strdup_printf ("#%02x%02x%02x",
- prefs->spell_error_color.red >> 8,
- prefs->spell_error_color.green >> 8,
- prefs->spell_error_color.blue >> 8);
- gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/composer/spell_error_color", str_color, NULL);
- g_free (str_color);
+ SET (int, "/spell_error_color_red", prefs->spell_error_color.red);
+ SET (int, "/spell_error_color_green", prefs->spell_error_color.green);
+ SET (int, "/spell_error_color_blue", prefs->spell_error_color.blue);
}
- if (force || !STR_EQUAL (prefs->language_str, prefs->language_str_orig))
- gconf_client_set_string (prefs->gconf, "/apps/evolution/mail/composer/spell_language", prefs->language_str ? prefs->language_str : "", NULL);
+ if (force || !STR_EQUAL (prefs->language_str, prefs->language_str_orig)) {
+ SET (string, "/language", prefs->language_str ? prefs->language_str : "");
+ }
gconf_client_suggest_sync (prefs->gconf, NULL);
}