1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 16:53:14 +02:00

New format for [bar] section in weechat.conf file, bar options can be set with /set command

This commit is contained in:
Sebastien Helleu
2008-04-15 13:50:01 +02:00
parent 362ce3eca8
commit b87d709a70
34 changed files with 1657 additions and 474 deletions
+2 -1
View File
@@ -615,6 +615,7 @@ alias_config_init ()
return 0;
ptr_section = weechat_config_new_section (alias_config_file, "cmd",
1, 1,
NULL, NULL,
NULL, NULL,
&alias_config_write_default, NULL,
@@ -775,7 +776,7 @@ unalias_command_cb (void *data, struct t_gui_buffer *buffer, int argc,
alias_config_section_cmd,
alias_name);
if (ptr_option)
weechat_config_option_free (alias_config_section_cmd, ptr_option);
weechat_config_option_free (ptr_option);
weechat_printf (NULL,
_("Alias \"%s\" removed"),
+4 -1
View File
@@ -124,7 +124,7 @@ charset_config_create_option (void *data, struct t_config_file *config_file,
rc = weechat_config_option_set (ptr_option, value, 1);
else
{
weechat_config_option_free (section, ptr_option);
weechat_config_option_free (ptr_option);
rc = 1;
}
}
@@ -170,6 +170,7 @@ charset_config_init ()
return 0;
ptr_section = weechat_config_new_section (charset_config_file, "default",
0, 0,
NULL, NULL,
NULL, NULL,
NULL, NULL,
@@ -198,6 +199,7 @@ charset_config_init ()
NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (charset_config_file, "decode",
1, 1,
NULL, NULL,
NULL, NULL,
NULL, NULL,
@@ -211,6 +213,7 @@ charset_config_init ()
charset_config_section_decode = ptr_section;
ptr_section = weechat_config_new_section (charset_config_file, "encode",
1, 1,
NULL, NULL,
NULL, NULL,
NULL, NULL,
+49 -49
View File
@@ -2553,6 +2553,55 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_OK;
}
if (weechat_strcasecmp (argv[1], "rename") == 0)
{
if (argc < 4)
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
}
/* look for server by name */
server_found = irc_server_search (argv[2]);
if (!server_found)
{
weechat_printf (NULL,
_("%s%s: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"), "irc",
argv[2], "server rename");
return WEECHAT_RC_ERROR;
}
/* check if target name already exists */
if (irc_server_search (argv[3]))
{
weechat_printf (NULL,
_("%s%s: server \"%s\" already exists for "
"\"%s\" command"),
weechat_prefix ("error"), "irc",
argv[3], "server rename");
return WEECHAT_RC_ERROR;
}
/* rename server */
if (irc_server_rename (server_found, argv[3]))
{
weechat_printf (NULL,
_("%s: server %s%s%s has been renamed to "
"%s%s"),
"irc",
IRC_COLOR_CHAT_SERVER,
argv[2],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
argv[3]);
//gui_window_redraw_all_buffers ();
return WEECHAT_RC_OK;
}
return WEECHAT_RC_ERROR;
}
/* TODO: fix server command */
weechat_printf (NULL,
"%sSome server options are temporarirly disabled in "
@@ -2765,55 +2814,6 @@ irc_command_server (void *data, struct t_gui_buffer *buffer, int argc,
return WEECHAT_RC_ERROR;
}
if (weechat_strcasecmp (argv[1], "rename") == 0)
{
if (argc < 4)
{
IRC_COMMAND_TOO_FEW_ARGUMENTS(NULL, "server rename");
}
/* look for server by name */
server_found = irc_server_search (argv[2]);
if (!server_found)
{
weechat_printf (NULL,
_("%s%s: server \"%s\" not found for "
"\"%s\" command"),
weechat_prefix ("error"), "irc",
argv[2], "server rename");
return WEECHAT_RC_ERROR;
}
/* check if target name already exists */
if (irc_server_search (argv[3]))
{
weechat_printf (NULL,
_("%s%s: server \"%s\" already exists for "
"\"%s\" command"),
weechat_prefix ("error"), "irc",
argv[3], "server rename");
return WEECHAT_RC_ERROR;
}
/* rename server */
if (irc_server_rename (server_found, argv[3]))
{
weechat_printf (NULL,
_("%s: server %s%s%s has been renamed to "
"%s%s"),
"irc",
IRC_COLOR_CHAT_SERVER,
argv[2],
IRC_COLOR_CHAT,
IRC_COLOR_CHAT_SERVER,
argv[3]);
//gui_window_redraw_all_buffers ();
return WEECHAT_RC_OK;
}
return WEECHAT_RC_ERROR;
}
if (weechat_strcasecmp (argv[1], "keep") == 0)
{
if (argc < 3)
+6
View File
@@ -859,6 +859,7 @@ irc_config_init ()
return 0;
ptr_section = weechat_config_new_section (irc_config_file, "look",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
if (!ptr_section)
@@ -915,6 +916,7 @@ irc_config_init ()
NULL, 0, 0, "", NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "network",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
if (!ptr_section)
@@ -989,6 +991,7 @@ irc_config_init ()
NULL, 0, 0, "off", NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "dcc",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
if (!ptr_section)
@@ -1065,6 +1068,7 @@ irc_config_init ()
NULL, 0, 0, "on", NULL, NULL, NULL, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "log",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
if (!ptr_section)
@@ -1095,6 +1099,7 @@ irc_config_init ()
NULL, 0, 0, "on", NULL, NULL, &irc_config_change_log, NULL, NULL, NULL);
ptr_section = weechat_config_new_section (irc_config_file, "server_default",
0, 0,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
if (!ptr_section)
@@ -1108,6 +1113,7 @@ irc_config_init ()
irc_config_server_create_default_options (ptr_section);
ptr_section = weechat_config_new_section (irc_config_file, "server",
1, 1,
NULL, NULL,
NULL, NULL,
&irc_config_server_write_default, NULL,
+18 -10
View File
@@ -994,6 +994,7 @@ irc_server_rename (struct t_irc_server *server, char *new_name)
int length;
char *option_name, *name, *pos_option;
struct t_plugin_infolist *infolist;
struct t_config_option *ptr_option;
/* check if another server exists with this name */
if (irc_server_search (new_name))
@@ -1009,18 +1010,25 @@ irc_server_rename (struct t_irc_server *server, char *new_name)
free (option_name);
while (weechat_infolist_next (infolist))
{
name = weechat_infolist_string (infolist, "name");
pos_option = strchr (name, '.');
if (pos_option)
weechat_config_search_with_string (weechat_infolist_string (infolist,
"full_name"),
NULL, NULL, &ptr_option,
NULL);
if (ptr_option)
{
pos_option++;
length = strlen (new_name) + 1 + strlen (pos_option) + 1;
option_name = malloc (length);
if (option_name)
name = weechat_infolist_string (infolist, "name");
pos_option = strchr (name, '.');
if (pos_option)
{
snprintf (option_name, length, "%s.%s", new_name, pos_option);
/* TODO: complete this function */
free (option_name);
pos_option++;
length = strlen (new_name) + 1 + strlen (pos_option) + 1;
option_name = malloc (length);
if (option_name)
{
snprintf (option_name, length, "%s.%s", new_name, pos_option);
weechat_config_option_rename (ptr_option, option_name);
free (option_name);
}
}
}
}
+1 -1
View File
@@ -185,7 +185,7 @@ plugin_config_init ()
if (plugin_config_file)
{
plugin_config_section_var = config_file_new_section (
plugin_config_file, "var",
plugin_config_file, "var", 0, 0,
NULL, NULL,
NULL, NULL,
NULL, NULL,
+2 -1
View File
@@ -327,10 +327,11 @@ plugin_load (char *filename)
new_plugin->config_search_option = &config_file_search_option;
new_plugin->config_search_section_option = &config_file_search_section_option;
new_plugin->config_search_with_string = &config_file_search_with_string;
new_plugin->config_string_to_boolean = &config_file_string_to_boolean;
new_plugin->config_option_reset = &config_file_option_reset;
new_plugin->config_option_set = &config_file_option_set;
new_plugin->config_option_rename = &config_file_option_rename;
new_plugin->config_option_get_pointer = &config_file_option_get_pointer;
new_plugin->config_string_to_boolean = &config_file_string_to_boolean;
new_plugin->config_boolean = &config_file_option_boolean;
new_plugin->config_integer = &config_file_option_integer;
new_plugin->config_string = &config_file_option_string;
+98 -12
View File
@@ -1128,7 +1128,7 @@ weechat_lua_api_config_new_section (lua_State *L)
const char *config_file, *name, *function_read, *function_write;
const char *function_write_default, *function_create_option;
char *result;
int n;
int n, user_can_add_options, user_can_delete_options;
/* make C compiler happy */
(void) L;
@@ -1141,6 +1141,8 @@ weechat_lua_api_config_new_section (lua_State *L)
config_file = NULL;
name = NULL;
user_can_add_options = 0;
user_can_delete_options = 0;
function_read = NULL;
function_write = NULL;
function_write_default = NULL;
@@ -1148,14 +1150,16 @@ weechat_lua_api_config_new_section (lua_State *L)
n = lua_gettop (lua_current_interpreter);
if (n < 6)
if (n < 8)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
LUA_RETURN_EMPTY;
}
config_file = lua_tostring (lua_current_interpreter, -6);
name = lua_tostring (lua_current_interpreter, -5);
config_file = lua_tostring (lua_current_interpreter, -8);
name = lua_tostring (lua_current_interpreter, -7);
user_can_add_options = lua_tonumber (lua_current_interpreter, -6);
user_can_delete_options = lua_tonumber (lua_current_interpreter, -5);
function_read = lua_tostring (lua_current_interpreter, -4);
function_write = lua_tostring (lua_current_interpreter, -3);
function_write_default = lua_tostring (lua_current_interpreter, -2);
@@ -1165,6 +1169,8 @@ weechat_lua_api_config_new_section (lua_State *L)
lua_current_script,
script_str2ptr ((char *)config_file),
(char *)name,
user_can_add_options,
user_can_delete_options,
&weechat_lua_api_config_read_cb,
(char *)function_read,
&weechat_lua_api_config_section_write_cb,
@@ -1391,6 +1397,45 @@ weechat_lua_api_config_string_to_boolean (lua_State *L)
LUA_RETURN_INT(value);
}
/*
* weechat_lua_api_config_option_reset: reset option with default value
*/
static int
weechat_lua_api_config_option_reset (lua_State *L)
{
const char *option;
int n, run_callback, rc;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset");
LUA_RETURN_INT(0);
}
option = NULL;
run_callback = 0;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset");
LUA_RETURN_INT(0);
}
option = lua_tostring (lua_current_interpreter, -2);
run_callback = lua_tonumber (lua_current_interpreter, -1);
rc = weechat_config_option_reset (script_str2ptr ((char *)option),
run_callback);
LUA_RETURN_INT(rc);
}
/*
* weechat_lua_api_config_option_set: set new value for option
*/
@@ -1433,6 +1478,45 @@ weechat_lua_api_config_option_set (lua_State *L)
LUA_RETURN_INT(rc);
}
/*
* weechat_lua_api_config_option_rename: rename an option
*/
static int
weechat_lua_api_config_option_rename (lua_State *L)
{
const char *option, *new_name;
int n;
/* make C compiler happy */
(void) L;
if (!lua_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");;
LUA_RETURN_ERROR;
}
option = NULL;
new_name = NULL;
n = lua_gettop (lua_current_interpreter);
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename");
LUA_RETURN_ERROR;
}
option = lua_tostring (lua_current_interpreter, -2);
new_name = lua_tostring (lua_current_interpreter, -1);
weechat_config_option_rename (script_str2ptr ((char *)option),
(char *)new_name);
LUA_RETURN_OK;
}
/*
* weechat_lua_api_config_boolean: return boolean value of option
*/
@@ -3794,9 +3878,9 @@ weechat_lua_api_bar_search (lua_State *L)
static int
weechat_lua_api_bar_new (lua_State *L)
{
const char *name, *type, *position, *items;
const char *name, *type, *position, *items, *size, *separator;
char *result;
int n, size, separator;
int n;
/* make C compiler happy */
(void) L;
@@ -3810,8 +3894,8 @@ weechat_lua_api_bar_new (lua_State *L)
name = NULL;
type = NULL;
position = NULL;
size = 0;
separator = 0;
size = NULL;
separator = NULL;
items = NULL;
n = lua_gettop (lua_current_interpreter);
@@ -3825,15 +3909,15 @@ weechat_lua_api_bar_new (lua_State *L)
name = lua_tostring (lua_current_interpreter, -6);
type = lua_tostring (lua_current_interpreter, -5);
position = lua_tostring (lua_current_interpreter, -4);
size = lua_tonumber (lua_current_interpreter, -3);
separator = lua_tonumber (lua_current_interpreter, -2);
size = lua_tostring (lua_current_interpreter, -3);
separator = lua_tostring (lua_current_interpreter, -2);
items = lua_tostring (lua_current_interpreter, -1);
result = script_ptr2str (weechat_bar_new ((char *)name,
(char *)type,
(char *)position,
size,
separator,
(char *)size,
(char *)separator,
(char *)items));
LUA_RETURN_STRING_FREE(result);
@@ -4533,7 +4617,9 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "config_new_option", &weechat_lua_api_config_new_option },
{ "config_search_option", &weechat_lua_api_config_search_option },
{ "config_string_to_boolean", &weechat_lua_api_config_string_to_boolean },
{ "config_option_reset", &weechat_lua_api_config_option_reset },
{ "config_option_set", &weechat_lua_api_config_option_set },
{ "config_option_rename", &weechat_lua_api_config_option_rename },
{ "config_boolean", &weechat_lua_api_config_boolean },
{ "config_integer", &weechat_lua_api_config_integer },
{ "config_string", &weechat_lua_api_config_string },
+78 -8
View File
@@ -964,7 +964,7 @@ static XS (XS_weechat_config_new_section)
PERL_RETURN_EMPTY;
}
if (items < 6)
if (items < 8)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_new_section");
PERL_RETURN_EMPTY;
@@ -972,14 +972,16 @@ static XS (XS_weechat_config_new_section)
cfg_file = SvPV (ST (0), PL_na);
name = SvPV (ST (1), PL_na);
function_read = SvPV (ST (2), PL_na);
function_write = SvPV (ST (3), PL_na);
function_write_default = SvPV (ST (4), PL_na);
function_create_option = SvPV (ST (5), PL_na);
function_read = SvPV (ST (4), PL_na);
function_write = SvPV (ST (5), PL_na);
function_write_default = SvPV (ST (6), PL_na);
function_create_option = SvPV (ST (7), PL_na);
result = script_ptr2str (script_api_config_new_section (weechat_perl_plugin,
perl_current_script,
script_str2ptr (cfg_file),
name,
SvIV (ST (2)), /* user_can_add_options */
SvIV (ST (3)), /* user_can_delete_options */
&weechat_perl_api_config_section_read_cb,
function_read,
&weechat_perl_api_config_section_write_cb,
@@ -1164,6 +1166,38 @@ static XS (XS_weechat_config_string_to_boolean)
PERL_RETURN_INT(value);
}
/*
* weechat::config_option_reset: reset an option with default value
*/
static XS (XS_weechat_config_option_reset)
{
int rc;
char *option;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset");
PERL_RETURN_INT(0);
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset");
PERL_RETURN_INT(0);
}
option = SvPV (ST (0), PL_na);
rc = weechat_config_option_reset (script_str2ptr (option),
SvIV (ST (1))); /* run_callback */
PERL_RETURN_INT(rc);
}
/*
* weechat::config_option_set: set new value for option
*/
@@ -1198,6 +1232,38 @@ static XS (XS_weechat_config_option_set)
PERL_RETURN_INT(rc);
}
/*
* weechat::config_option_rename: rename an option
*/
static XS (XS_weechat_config_option_rename)
{
char *option, *new_name;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");
PERL_RETURN_ERROR;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename");
PERL_RETURN_ERROR;
}
option = SvPV (ST (0), PL_na);
new_name = SvPV (ST (1), PL_na);
weechat_config_option_rename (script_str2ptr (option),
new_name);
PERL_RETURN_OK;
}
/*
* weechat::config_boolean: return boolean value of option
*/
@@ -3153,7 +3219,7 @@ static XS (XS_weechat_bar_search)
static XS (XS_weechat_bar_new)
{
char *result, *name, *type, *position, *bar_items;
char *result, *name, *type, *position, *size, *separator, *bar_items;
dXSARGS;
/* make C compiler happy */
@@ -3174,12 +3240,14 @@ static XS (XS_weechat_bar_new)
name = SvPV (ST (0), PL_na);
type = SvPV (ST (1), PL_na);
position = SvPV (ST (2), PL_na);
size = SvPV (ST (3), PL_na);
separator = SvPV (ST (4), PL_na);
bar_items = SvPV (ST (5), PL_na);
result = script_ptr2str (weechat_bar_new (name,
type,
position,
SvIV (ST (3)), /* size */
SvIV (ST (4)), /* separator */
size,
separator,
bar_items));
PERL_RETURN_STRING_FREE(result);
@@ -3651,7 +3719,9 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::config_new_option", XS_weechat_config_new_option, "weechat");
newXS ("weechat::config_search_option", XS_weechat_config_search_option, "weechat");
newXS ("weechat::config_string_to_boolean", XS_weechat_config_string_to_boolean, "weechat");
newXS ("weechat::config_option_reset", XS_weechat_config_option_reset, "weechat");
newXS ("weechat::config_option_set", XS_weechat_config_option_set, "weechat");
newXS ("weechat::config_option_rename", XS_weechat_config_option_rename, "weechat");
newXS ("weechat::config_boolean", XS_weechat_config_boolean, "weechat");
newXS ("weechat::config_integer", XS_weechat_config_integer, "weechat");
newXS ("weechat::config_string", XS_weechat_config_string, "weechat");
@@ -999,6 +999,7 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
char *config_file, *name, *function_read, *function_write;
char *function_write_default, *function_create_option;
char *result;
int user_can_add_options, user_can_delete_options;
PyObject *object;
/* make C compiler happy */
@@ -1012,12 +1013,15 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
config_file = NULL;
name = NULL;
user_can_add_options = 0;
user_can_delete_options = 0;
function_read = NULL;
function_write = NULL;
function_write_default = NULL;
function_create_option = NULL;
if (!PyArg_ParseTuple (args, "ssssss", &config_file, &name,
if (!PyArg_ParseTuple (args, "ssiissss", &config_file, &name,
&user_can_add_options, &user_can_delete_options,
&function_read, &function_write,
&function_write_default, &function_create_option))
{
@@ -1029,6 +1033,8 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
python_current_script,
script_str2ptr (config_file),
name,
user_can_add_options,
user_can_delete_options,
&weechat_python_api_config_read_cb,
function_read,
&weechat_python_api_config_section_write_cb,
@@ -1225,6 +1231,40 @@ weechat_python_api_config_string_to_boolean (PyObject *self, PyObject *args)
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_config_option_reset: reset an option with default value
*/
static PyObject *
weechat_python_api_config_option_reset (PyObject *self, PyObject *args)
{
char *option;
int run_callback, rc;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset");
PYTHON_RETURN_INT(0);
}
option = NULL;
run_callback = 0;
if (!PyArg_ParseTuple (args, "si", &option, &run_callback))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset");
PYTHON_RETURN_INT(0);
}
rc = weechat_config_option_reset (script_str2ptr (option),
run_callback);
PYTHON_RETURN_INT(rc);
}
/*
* weechat_python_api_config_option_set: set new value for option
*/
@@ -1261,6 +1301,39 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
PYTHON_RETURN_INT(rc);
}
/*
* weechat_python_api_config_option_rename: rename an option
*/
static PyObject *
weechat_python_api_config_option_rename (PyObject *self, PyObject *args)
{
char *option, *new_name;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");
PYTHON_RETURN_ERROR;
}
option = NULL;
new_name = NULL;
if (!PyArg_ParseTuple (args, "ss", &option, &new_name))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename");
PYTHON_RETURN_ERROR;
}
weechat_config_option_rename (script_str2ptr (option),
new_name);
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_config_boolean: return boolean value of option
*/
@@ -3353,8 +3426,7 @@ weechat_python_api_bar_search (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_bar_new (PyObject *self, PyObject *args)
{
char *name, *type, *position, *items, *result;
int size, separator;
char *name, *type, *position, *size, *separator, *items, *result;
PyObject *object;
/* make C compiler happy */
@@ -3369,11 +3441,11 @@ weechat_python_api_bar_new (PyObject *self, PyObject *args)
name = NULL;
type = NULL;
position = NULL;
size = 0;
separator = 0;
size = NULL;
separator = NULL;
items = NULL;
if (!PyArg_ParseTuple (args, "sssiis", &name, &type, &position, &size,
if (!PyArg_ParseTuple (args, "ssssss", &name, &type, &position, &size,
&separator, &items))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
@@ -3704,7 +3776,7 @@ weechat_python_api_infolist_integer (PyObject *self, PyObject *args)
infolist = NULL;
variable = NULL;
if (!PyArg_ParseTuple (args, "s&", &infolist, &variable))
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer");
PYTHON_RETURN_INT(0);
@@ -3884,7 +3956,9 @@ PyMethodDef weechat_python_funcs[] =
{ "config_new_option", &weechat_python_api_config_new_option, METH_VARARGS, "" },
{ "config_search_option", &weechat_python_api_config_search_option, METH_VARARGS, "" },
{ "config_string_to_boolean", &weechat_python_api_config_string_to_boolean, METH_VARARGS, "" },
{ "config_option_reset", &weechat_python_api_config_option_reset, METH_VARARGS, "" },
{ "config_option_set", &weechat_python_api_config_option_set, METH_VARARGS, "" },
{ "config_option_rename", &weechat_python_api_config_option_rename, METH_VARARGS, "" },
{ "config_boolean", &weechat_python_api_config_boolean, METH_VARARGS, "" },
{ "config_integer", &weechat_python_api_config_integer, METH_VARARGS, "" },
{ "config_string", &weechat_python_api_config_string, METH_VARARGS, "" },
+106 -11
View File
@@ -1114,7 +1114,9 @@ weechat_ruby_api_config_section_create_option_cb (void *data,
static VALUE
weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
VALUE name, VALUE function_read,
VALUE name, VALUE user_can_add_options,
VALUE user_can_delete_options,
VALUE function_read,
VALUE function_write,
VALUE function_write_default,
VALUE function_create_option)
@@ -1122,6 +1124,7 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
char *c_config_file, *c_name, *c_function_read, *c_function_write;
char *c_function_write_default, *c_function_create_option;
char *result;
int c_user_can_add_options, c_user_can_delete_options;
VALUE return_value;
/* make C compiler happy */
@@ -1135,12 +1138,15 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
c_config_file = NULL;
c_name = NULL;
c_user_can_add_options = 0;
c_user_can_delete_options = 0;
c_function_read = NULL;
c_function_write = NULL;
c_function_write_default = NULL;
c_function_create_option = NULL;
if (NIL_P (config_file) || NIL_P (name) || NIL_P (function_read)
if (NIL_P (config_file) || NIL_P (name) || NIL_P (user_can_add_options)
|| NIL_P (user_can_delete_options) || NIL_P (function_read)
|| NIL_P (function_write) || NIL_P (function_write_default)
|| NIL_P (function_create_option))
{
@@ -1150,6 +1156,8 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
Check_Type (config_file, T_STRING);
Check_Type (name, T_STRING);
Check_Type (user_can_add_options, T_FIXNUM);
Check_Type (user_can_delete_options, T_FIXNUM);
Check_Type (function_read, T_STRING);
Check_Type (function_write, T_STRING);
Check_Type (function_write_default, T_STRING);
@@ -1157,6 +1165,8 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
c_config_file = STR2CSTR (config_file);
c_name = STR2CSTR (name);
c_user_can_add_options = FIX2INT (user_can_add_options);
c_user_can_delete_options = FIX2INT (user_can_delete_options);
c_function_read = STR2CSTR (function_read);
c_function_write = STR2CSTR (function_write);
c_function_write_default = STR2CSTR (function_write_default);
@@ -1166,6 +1176,8 @@ weechat_ruby_api_config_new_section (VALUE class, VALUE config_file,
ruby_current_script,
script_str2ptr (c_config_file),
c_name,
c_user_can_add_options,
c_user_can_delete_options,
&weechat_ruby_api_config_read_cb,
c_function_read,
&weechat_ruby_api_config_section_write_cb,
@@ -1410,6 +1422,47 @@ weechat_ruby_api_config_string_to_boolean (VALUE class, VALUE text)
RUBY_RETURN_INT(value);
}
/*
* weechat_ruby_api_config_option_reset: reset option with default value
*/
static VALUE
weechat_ruby_api_config_option_reset (VALUE class, VALUE option,
VALUE run_callback)
{
char *c_option;
int c_run_callback, rc;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_reset");
RUBY_RETURN_INT(0);
}
c_option = NULL;
c_run_callback = 0;
if (NIL_P (option) || NIL_P (run_callback))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_reset");
RUBY_RETURN_INT(0);
}
Check_Type (option, T_STRING);
Check_Type (run_callback, T_FIXNUM);
c_option = STR2CSTR (option);
c_run_callback = FIX2INT (run_callback);
rc = weechat_config_option_reset (script_str2ptr (c_option),
c_run_callback);
RUBY_RETURN_INT(rc);
}
/*
* weechat_ruby_api_config_option_set: set new value for option
*/
@@ -1455,6 +1508,46 @@ weechat_ruby_api_config_option_set (VALUE class, VALUE option, VALUE new_value,
RUBY_RETURN_INT(rc);
}
/*
* weechat_ruby_api_config_option_rename: rename an option
*/
static VALUE
weechat_ruby_api_config_option_rename (VALUE class, VALUE option,
VALUE new_name)
{
char *c_option, *c_new_name;
/* make C compiler happy */
(void) class;
if (!ruby_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("config_option_rename");
RUBY_RETURN_ERROR;
}
c_option = NULL;
c_new_name = NULL;
if (NIL_P (option) || NIL_P (new_name))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("config_option_rename");
RUBY_RETURN_ERROR;
}
Check_Type (option, T_STRING);
Check_Type (new_name, T_STRING);
c_option = STR2CSTR (option);
c_new_name = STR2CSTR (new_name);
weechat_config_option_rename (script_str2ptr (c_option),
c_new_name);
RUBY_RETURN_OK;
}
/*
* weechat_ruby_api_config_boolean: return boolean value of option
*/
@@ -3852,8 +3945,8 @@ static VALUE
weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE position,
VALUE size, VALUE separator, VALUE items)
{
char *c_name, *c_type, *c_position, *c_items, *result;
int c_size, c_separator;
char *c_name, *c_type, *c_position, *c_size, *c_separator, *c_items;
char *result;
VALUE return_value;
/* make C compiler happy */
@@ -3868,8 +3961,8 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE position,
c_name = NULL;
c_type = NULL;
c_position = NULL;
c_size = 0;
c_separator = 0;
c_size = NULL;
c_separator = NULL;
c_items = NULL;
if (NIL_P (name) || NIL_P (type) || NIL_P (position) || NIL_P (size)
@@ -3882,15 +3975,15 @@ weechat_ruby_api_bar_new (VALUE class, VALUE name, VALUE type, VALUE position,
Check_Type (name, T_STRING);
Check_Type (type, T_STRING);
Check_Type (position, T_STRING);
Check_Type (size, T_FIXNUM);
Check_Type (separator, T_FIXNUM);
Check_Type (size, T_STRING);
Check_Type (separator, T_STRING);
Check_Type (items, T_STRING);
c_name = STR2CSTR (name);
c_type = STR2CSTR (type);
c_position = STR2CSTR (position);
c_size = FIX2INT (size);
c_separator = FIX2INT (separator);
c_size = STR2CSTR (size);
c_separator = STR2CSTR (separator);
c_items = STR2CSTR (items);
result = script_ptr2str (weechat_bar_new (c_name,
@@ -4436,12 +4529,14 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "list_remove_all", &weechat_ruby_api_list_remove_all, 1);
rb_define_module_function (ruby_mWeechat, "list_free", &weechat_ruby_api_list_free, 1);
rb_define_module_function (ruby_mWeechat, "config_new", &weechat_ruby_api_config_new, 2);
rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 6);
rb_define_module_function (ruby_mWeechat, "config_new_section", &weechat_ruby_api_config_new_section, 8);
rb_define_module_function (ruby_mWeechat, "config_search_section", &weechat_ruby_api_config_search_section, 2);
rb_define_module_function (ruby_mWeechat, "config_new_option", &weechat_ruby_api_config_new_option, 10);
rb_define_module_function (ruby_mWeechat, "config_search_option", &weechat_ruby_api_config_search_option, 3);
rb_define_module_function (ruby_mWeechat, "config_string_to_boolean", &weechat_ruby_api_config_string_to_boolean, 1);
rb_define_module_function (ruby_mWeechat, "config_option_reset", &weechat_ruby_api_config_option_reset, 2);
rb_define_module_function (ruby_mWeechat, "config_option_set", &weechat_ruby_api_config_option_set, 3);
rb_define_module_function (ruby_mWeechat, "config_option_rename", &weechat_ruby_api_config_option_rename, 2);
rb_define_module_function (ruby_mWeechat, "config_boolean", &weechat_ruby_api_config_boolean, 1);
rb_define_module_function (ruby_mWeechat, "config_integer", &weechat_ruby_api_config_integer, 1);
rb_define_module_function (ruby_mWeechat, "config_string", &weechat_ruby_api_config_string, 1);
+4
View File
@@ -98,6 +98,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_config_file *config_file,
char *name,
int user_can_add_options,
int user_can_delete_options,
void (*callback_read)(void *data,
struct t_config_file *config_file,
char *option_name,
@@ -202,6 +204,8 @@ script_api_config_new_section (struct t_weechat_plugin *weechat_plugin,
new_section = weechat_config_new_section (config_file,
name,
user_can_add_options,
user_can_delete_options,
callback1,
new_script_callback1,
callback2,
+2
View File
@@ -31,6 +31,8 @@ extern struct t_config_section *script_api_config_new_section (struct t_weechat_
struct t_plugin_script *script,
struct t_config_file *config_file,
char *name,
int user_can_add_options,
int user_can_delete_options,
void (*callback_read)(void *data,
struct t_config_file *config_file,
char *option_name,
+17 -6
View File
@@ -165,6 +165,8 @@ struct t_weechat_plugin
void *callback_reload_data);
struct t_config_section *(*config_new_section) (struct t_config_file *config_file,
char *name,
int user_can_add_options,
int user_can_delete_options,
int (*callback_read)(void *data,
struct t_config_file *config_file,
struct t_config_section *section,
@@ -222,6 +224,8 @@ struct t_weechat_plugin
int run_callback);
int (*config_option_set) (struct t_config_option *option, char *value,
int run_callback);
void (*config_option_rename) (struct t_config_option *option,
char *new_name);
void *(*config_option_get_pointer) (struct t_config_option *option,
char *property);
int (*config_boolean) (struct t_config_option *option);
@@ -233,8 +237,7 @@ struct t_weechat_plugin
int (*config_write) (struct t_config_file *config_file);
int (*config_read) (struct t_config_file *config_file);
int (*config_reload) (struct t_config_file *config_file);
void (*config_option_free) (struct t_config_section *section,
struct t_config_option *option);
void (*config_option_free) (struct t_config_option *option);
void (*config_section_free_options) (struct t_config_section *section);
void (*config_section_free) (struct t_config_file *config_file,
struct t_config_section *section);
@@ -373,8 +376,8 @@ struct t_weechat_plugin
void (*bar_item_remove) (struct t_gui_bar_item *item);
struct t_gui_bar *(*bar_search) (char *name);
struct t_gui_bar *(*bar_new) (struct t_weechat_plugin *plugin, char *name,
char *type, char *position, int size,
int separator, char *items);
char *type, char *position, char *size,
char *separator, char *items);
void (*bar_set) (struct t_gui_bar *bar, char *property, char *value);
void (*bar_update) (char *name);
void (*bar_remove) (struct t_gui_bar *bar);
@@ -544,12 +547,16 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__callback_reload, \
__callback_reload_data)
#define weechat_config_new_section(__config, __name, \
__user_can_add_options, \
__user_can_delete_options, \
__cb_read, __cb_read_data, \
__cb_write_std, __cb_write_std_data, \
__cb_write_def, __cb_write_def_data, \
__cb_create_option, \
__cb_create_option_data) \
weechat_plugin->config_new_section(__config, __name, \
__user_can_add_options, \
__user_can_delete_options, \
__cb_read, __cb_read_data, \
__cb_write_std, \
__cb_write_std_data, \
@@ -592,9 +599,13 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
__pos_option);
#define weechat_config_string_to_boolean(__string) \
weechat_plugin->config_string_to_boolean(__string)
#define weechat_config_option_reset(__option, __run_callback) \
weechat_plugin->config_option_reset(__option, __run_callback)
#define weechat_config_option_set(__option, __value, __run_callback) \
weechat_plugin->config_option_set(__option, __value, \
__run_callback)
#define weechat_config_option_rename(__option, __new_name) \
weechat_plugin->config_option_rename(__option, __new_name)
#define weechat_config_option_get_pointer(__option, __property) \
weechat_plugin->config_option_get_pointer(__option, __property)
#define weechat_config_boolean(__option) \
@@ -615,8 +626,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->config_read(__config)
#define weechat_config_reload(__config) \
weechat_plugin->config_reload(__config)
#define weechat_config_option_free(__section, __option) \
weechat_plugin->config_option_free(__section, __option)
#define weechat_config_option_free(__option) \
weechat_plugin->config_option_free(__option)
#define weechat_config_section_free_options(__section) \
weechat_plugin->config_section_free_options(__section)
#define weechat_config_section_free(__config, __section) \