diff options
Diffstat (limited to 'src/fe-common/core/fe-settings.c')
-rw-r--r-- | src/fe-common/core/fe-settings.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/fe-common/core/fe-settings.c b/src/fe-common/core/fe-settings.c index b689cbf9..abbd45a8 100644 --- a/src/fe-common/core/fe-settings.c +++ b/src/fe-common/core/fe-settings.c @@ -67,6 +67,7 @@ static void set_print_pattern(const char *pattern) static void set_boolean(const char *key, const char *value) { char *stripped_value; + stripped_value = g_strdup(value); g_strstrip(stripped_value); @@ -79,7 +80,7 @@ static void set_boolean(const char *key, const char *value) else printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_NOT_TOGGLE); - g_free(stripped_value); + g_free(stripped_value); } static void set_int(const char *key, const char *value) @@ -99,6 +100,24 @@ static void set_int(const char *key, const char *value) settings_set_int(key, (int)longval); } +static void set_choice(const char *key, const char *value) +{ + char *stripped_value; + + stripped_value = g_strdup(value); + g_strstrip(stripped_value); + + if (settings_set_choice(key, stripped_value) == FALSE) { + SETTINGS_REC *rec = settings_get_record(key); + char *msg = g_strjoinv(", ", rec->choices); + + printformat(NULL, NULL, MSGLEVEL_CLIENTERROR, TXT_INVALID_CHOICE, msg); + g_free(msg); + } + + g_free(stripped_value); +} + /* SYNTAX: SET [-clear | -default] [<key> [<value>]] */ static void cmd_set(char *data) { @@ -142,6 +161,12 @@ static void cmd_set(char *data) else set_int(key, value); break; + case SETTING_TYPE_CHOICE: + if (clear || set_default) + settings_set_choice(key, rec->choices[rec->default_value.v_int]); + else + set_choice(key, value); + break; case SETTING_TYPE_STRING: settings_set_str(key, clear ? "" : set_default ? rec->default_value.v_string : |