mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
Factor out code from set_print into a function to get a printable
representation of a setting. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4470 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
09f2bf2c05
commit
983ee1db88
@ -148,6 +148,27 @@ int settings_get_size(const char *key)
|
|||||||
return str == NULL ? 0 : bytes;
|
return str == NULL ? 0 : bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *settings_get_print(SETTINGS_REC *rec)
|
||||||
|
{
|
||||||
|
char *value;
|
||||||
|
|
||||||
|
switch(rec->type) {
|
||||||
|
case SETTING_TYPE_BOOLEAN:
|
||||||
|
value = g_strdup(settings_get_bool(rec->key) ? "ON" : "OFF");
|
||||||
|
break;
|
||||||
|
case SETTING_TYPE_INT:
|
||||||
|
value = g_strdup_printf("%d", settings_get_int(rec->key));
|
||||||
|
break;
|
||||||
|
case SETTING_TYPE_STRING:
|
||||||
|
case SETTING_TYPE_TIME:
|
||||||
|
case SETTING_TYPE_LEVEL:
|
||||||
|
case SETTING_TYPE_SIZE:
|
||||||
|
value = g_strdup(settings_get_str(rec->key));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
static void settings_add(const char *module, const char *section,
|
static void settings_add(const char *module, const char *section,
|
||||||
const char *key, SettingType type,
|
const char *key, SettingType type,
|
||||||
const SettingValue *default_value)
|
const SettingValue *default_value)
|
||||||
|
@ -55,6 +55,7 @@ int settings_get_bool(const char *key);
|
|||||||
int settings_get_time(const char *key); /* as milliseconds */
|
int settings_get_time(const char *key); /* as milliseconds */
|
||||||
int settings_get_level(const char *key);
|
int settings_get_level(const char *key);
|
||||||
int settings_get_size(const char *key); /* as bytes */
|
int settings_get_size(const char *key); /* as bytes */
|
||||||
|
char *settings_get_print(SETTINGS_REC *rec);
|
||||||
|
|
||||||
/* Functions to add/remove settings */
|
/* Functions to add/remove settings */
|
||||||
void settings_add_str_module(const char *module, const char *section,
|
void settings_add_str_module(const char *module, const char *section,
|
||||||
|
@ -33,28 +33,12 @@
|
|||||||
|
|
||||||
static void set_print(SETTINGS_REC *rec)
|
static void set_print(SETTINGS_REC *rec)
|
||||||
{
|
{
|
||||||
const char *value;
|
char *value;
|
||||||
char value_int[MAX_INT_STRLEN];
|
|
||||||
|
|
||||||
switch (rec->type) {
|
value = settings_get_print(rec);
|
||||||
case SETTING_TYPE_BOOLEAN:
|
|
||||||
value = settings_get_bool(rec->key) ? "ON" : "OFF";
|
|
||||||
break;
|
|
||||||
case SETTING_TYPE_INT:
|
|
||||||
ltoa(value_int, settings_get_int(rec->key));
|
|
||||||
value = value_int;
|
|
||||||
break;
|
|
||||||
case SETTING_TYPE_STRING:
|
|
||||||
case SETTING_TYPE_TIME:
|
|
||||||
case SETTING_TYPE_LEVEL:
|
|
||||||
case SETTING_TYPE_SIZE:
|
|
||||||
value = settings_get_str(rec->key);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
value = "";
|
|
||||||
}
|
|
||||||
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_ITEM,
|
printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_SET_ITEM,
|
||||||
rec->key, value);
|
rec->key, value);
|
||||||
|
g_free(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_boolean(const char *key, const char *value)
|
static void set_boolean(const char *key, const char *value)
|
||||||
|
Loading…
Reference in New Issue
Block a user