Added some config options.

This commit is contained in:
Håvard Pettersson 2014-10-12 12:24:49 +02:00
parent a437931e41
commit e6e4fd568e
5 changed files with 62 additions and 11 deletions

View file

@ -31,9 +31,13 @@
#include "twc-config.h"
struct t_config_file *twc_config_file = NULL;
struct t_config_section *twc_config_section_look = NULL;
struct t_config_section *twc_config_section_profile = NULL;
struct t_config_section *twc_config_section_profile_default = NULL;
struct t_config_option *twc_config_friend_request_message;
struct t_config_option *twc_config_short_id_size;
char *twc_profile_option_names[TWC_PROFILE_NUM_OPTIONS] =
{
"save_file",
@ -175,6 +179,23 @@ twc_config_profile_write_callback(void *data,
return WEECHAT_CONFIG_WRITE_OK;
}
/**
* Callback for checking an option value being set.
*/
int
twc_config_check_value_callback(void *data,
struct t_config_option *option,
const char *value)
{
int int_value = atoi(value);
// must be multiple of two
if (option == twc_config_short_id_size && int_value % 2)
return 0;
return 1;
}
/**
* Callback for checking an option value being set for a profile.
*/
@ -307,6 +328,32 @@ twc_config_init()
twc_config_init_option(twc_config_section_profile_default,
i, twc_profile_option_names[i], true);
}
twc_config_section_look =
weechat_config_new_section(twc_config_file, "look",
0, 0,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL, NULL);
twc_config_friend_request_message = weechat_config_new_option(
twc_config_file, twc_config_section_look,
"friend_request_message", "string",
"message sent with friend requests if no other message is specified",
NULL, 0, 0,
"Hi! Please add me on Tox!", NULL, 0,
twc_config_check_value_callback, NULL,
NULL, NULL, NULL, NULL);
twc_config_short_id_size = weechat_config_new_option(
twc_config_file, twc_config_section_look,
"short_id_size", "integer",
"length of Tox IDs shown in short format; must be a multiple of two",
NULL, 2, TOX_CLIENT_ID_SIZE * 2,
"8", NULL, 0,
twc_config_check_value_callback, NULL,
NULL, NULL, NULL, NULL);
}
/**