summaryrefslogtreecommitdiff
path: root/src/core/settings.h
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2016-06-12 15:26:07 +0200
committerLemonBoy <thatlemon@gmail.com>2016-06-12 16:18:33 +0200
commitbf9d9494db89e7de45653e4797e2977c6e185c13 (patch)
treed094d950dc2c94bdaf041e38da063a4ccfd651a1 /src/core/settings.h
parent0fad2cd8427a35f6b2de46fa8bd38437b9695495 (diff)
downloadirssi-bf9d9494db89e7de45653e4797e2977c6e185c13.zip
Add a CHOICE type to the settings system.
This is useful to let the user choose an option between a finite set of valid alternatives.
Diffstat (limited to 'src/core/settings.h')
-rw-r--r--src/core/settings.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/core/settings.h b/src/core/settings.h
index 6f2cf129..d174f250 100644
--- a/src/core/settings.h
+++ b/src/core/settings.h
@@ -8,6 +8,7 @@ typedef enum {
SETTING_TYPE_TIME,
SETTING_TYPE_LEVEL,
SETTING_TYPE_SIZE,
+ SETTING_TYPE_CHOICE,
SETTING_TYPE_ANY
} SettingType;
@@ -26,6 +27,7 @@ typedef struct {
SettingType type;
SettingValue default_value;
+ char **choices;
} SETTINGS_REC;
/* macros for handling the default Irssi configuration */
@@ -58,6 +60,7 @@ int settings_get_bool(const char *key);
int settings_get_time(const char *key); /* as milliseconds */
int settings_get_level(const char *key);
int settings_get_size(const char *key); /* as bytes */
+int settings_get_choice(const char *key);
char *settings_get_print(SETTINGS_REC *rec);
/* Functions to add/remove settings */
@@ -73,6 +76,8 @@ void settings_add_level_module(const char *module, const char *section,
const char *key, const char *def);
void settings_add_size_module(const char *module, const char *section,
const char *key, const char *def);
+void settings_add_choice_module(const char *module, const char *section,
+ const char *key, int def, const char *choices);
void settings_remove(const char *key);
void settings_remove_module(const char *module);
@@ -88,13 +93,16 @@ void settings_remove_module(const char *module);
settings_add_level_module(MODULE_NAME, section, key, def)
#define settings_add_size(section, key, def) \
settings_add_size_module(MODULE_NAME, section, key, def)
+#define settings_add_choice(section, key, def, choices) \
+ settings_add_choice_module(MODULE_NAME, section, key, def, choices)
void settings_set_str(const char *key, const char *value);
void settings_set_int(const char *key, int value);
void settings_set_bool(const char *key, int value);
-int settings_set_time(const char *key, const char *value);
-int settings_set_level(const char *key, const char *value);
-int settings_set_size(const char *key, const char *value);
+gboolean settings_set_time(const char *key, const char *value);
+gboolean settings_set_level(const char *key, const char *value);
+gboolean settings_set_size(const char *key, const char *value);
+gboolean settings_set_choice(const char *key, const char *value);
/* Get the type (SETTING_TYPE_xxx) of `key' */
SettingType settings_get_type(const char *key);