1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

Partial support of bars, with custom items.

Today only root bars are partially working (refresh is not always performed),
and bars are not saved in configuration file. To be continued...
This commit is contained in:
Sebastien Helleu
2008-03-05 16:19:10 +01:00
parent d64e852a38
commit 14d393b11e
49 changed files with 5582 additions and 242 deletions
File diff suppressed because it is too large Load Diff
+605
View File
@@ -178,6 +178,7 @@ static XS (XS_weechat_iconv_to_internal)
result = weechat_iconv_to_internal (SvPV (ST (0), PL_na), /* charset */
SvPV (ST (1), PL_na)); /* string */
PERL_RETURN_STRING_FREE(result);
}
@@ -208,6 +209,7 @@ static XS (XS_weechat_iconv_from_internal)
result = weechat_iconv_from_internal (SvPV (ST (0), PL_na), /* charset */
SvPV (ST (1), PL_na)); /* string */
PERL_RETURN_STRING_FREE(result);
}
@@ -236,6 +238,7 @@ static XS (XS_weechat_gettext)
}
result = weechat_gettext (SvPV (ST (0), PL_na)); /* string */
PERL_RETURN_STRING(result);
}
@@ -266,6 +269,7 @@ static XS (XS_weechat_ngettext)
result = weechat_ngettext (SvPV (ST (0), PL_na), /* single */
SvPV (ST (1), PL_na), /* plural */
SvIV (ST (2))); /* count */
PERL_RETURN_STRING(result);
}
@@ -349,6 +353,7 @@ static XS (XS_weechat_list_new)
}
result = script_ptr2str (weechat_list_new ());
PERL_RETURN_STRING_FREE(result);
}
@@ -379,6 +384,7 @@ static XS (XS_weechat_list_add)
result = script_ptr2str (weechat_list_add (script_str2ptr (SvPV (ST (0), PL_na)), /* weelist */
SvPV (ST (1), PL_na), /* data */
SvPV (ST (2), PL_na))); /* where */
PERL_RETURN_STRING_FREE(result);
}
@@ -408,6 +414,7 @@ static XS (XS_weechat_list_search)
result = script_ptr2str (weechat_list_search (script_str2ptr (SvPV (ST (0), PL_na)), /* weelist */
SvPV (ST (1), PL_na))); /* data */
PERL_RETURN_STRING_FREE(result);
}
@@ -437,6 +444,7 @@ static XS (XS_weechat_list_casesearch)
result = script_ptr2str (weechat_list_casesearch (script_str2ptr (SvPV (ST (0), PL_na)), /* weelist */
SvPV (ST (1), PL_na))); /* data */
PERL_RETURN_STRING_FREE(result);
}
@@ -466,6 +474,7 @@ static XS (XS_weechat_list_get)
result = script_ptr2str (weechat_list_get (script_str2ptr (SvPV (ST (0), PL_na)), /* weelist */
SvIV (ST (1)))); /* position */
PERL_RETURN_STRING_FREE(result);
}
@@ -523,6 +532,7 @@ static XS (XS_weechat_list_next)
}
result = script_ptr2str (weechat_list_next (script_str2ptr (SvPV (ST (0), PL_na)))); /* item */
PERL_RETURN_STRING_FREE(result);
}
@@ -551,6 +561,7 @@ static XS (XS_weechat_list_prev)
}
result = script_ptr2str (weechat_list_prev (script_str2ptr (SvPV (ST (0), PL_na)))); /* item */
PERL_RETURN_STRING_FREE(result);
}
@@ -579,6 +590,7 @@ static XS (XS_weechat_list_string)
}
result = weechat_list_string (script_str2ptr (SvPV (ST (0), PL_na))); /* item */
PERL_RETURN_STRING(result);
}
@@ -607,6 +619,7 @@ static XS (XS_weechat_list_size)
}
size = weechat_list_size (script_str2ptr (SvPV (ST (0), PL_na))); /* weelist */
PERL_RETURN_INT(size);
}
@@ -764,6 +777,7 @@ static XS (XS_weechat_config_new)
SvPV (ST (0), PL_na), /* filename */
&weechat_perl_api_config_reload_cb,
SvPV (ST (1), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -902,6 +916,7 @@ static XS (XS_weechat_config_new_section)
SvPV (ST (3), PL_na), /* perl function (write cb) */
&weechat_perl_api_config_section_write_default_cb,
SvPV (ST (4), PL_na))); /* perl function (write default cb) */
PERL_RETURN_STRING_FREE(result);
}
@@ -931,6 +946,7 @@ static XS (XS_weechat_config_search_section)
result = script_ptr2str (weechat_config_search_section (script_str2ptr (SvPV (ST (0), PL_na)), /* config_file */
SvPV (ST (1), PL_na))); /* section_name */
PERL_RETURN_STRING_FREE(result);
}
@@ -998,6 +1014,7 @@ static XS (XS_weechat_config_new_option)
SvPV (ST (8), PL_na), /* default_value */
&weechat_perl_api_config_option_change_cb,
SvPV (ST (9), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -1028,6 +1045,7 @@ static XS (XS_weechat_config_search_option)
result = script_ptr2str (weechat_config_search_option (script_str2ptr (SvPV (ST (0), PL_na)), /* config_file */
script_str2ptr (SvPV (ST (1), PL_na)), /* section */
SvPV (ST (2), PL_na))); /* option_name */
PERL_RETURN_STRING_FREE(result);
}
@@ -1056,6 +1074,7 @@ static XS (XS_weechat_config_string_to_boolean)
}
value = weechat_config_string_to_boolean (SvPV (ST (0), PL_na)); /* text */
PERL_RETURN_INT(value);
}
@@ -1086,6 +1105,7 @@ static XS (XS_weechat_config_option_set)
rc = weechat_config_option_set (script_str2ptr (SvPV (ST (0), PL_na)), /* option */
SvPV (ST (1), PL_na), /* new_value */
SvIV (ST (2))); /* run_callback */
PERL_RETURN_INT(rc);
}
@@ -1114,6 +1134,7 @@ static XS (XS_weechat_config_boolean)
}
value = weechat_config_boolean (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_INT(value);
}
@@ -1142,6 +1163,7 @@ static XS (XS_weechat_config_integer)
}
value = weechat_config_integer (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_INT(value);
}
@@ -1170,6 +1192,7 @@ static XS (XS_weechat_config_string)
}
value = weechat_config_string (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_STRING(value);
}
@@ -1198,6 +1221,7 @@ static XS (XS_weechat_config_color)
}
value = weechat_config_color (script_str2ptr (SvPV (ST (0), PL_na))); /* option */
PERL_RETURN_INT(value);
}
@@ -1257,6 +1281,7 @@ static XS (XS_weechat_config_write)
}
rc = weechat_config_write (script_str2ptr (SvPV (ST (0), PL_na))); /* config_file */
PERL_RETURN_INT(rc);
}
@@ -1285,6 +1310,7 @@ static XS (XS_weechat_config_read)
}
rc = weechat_config_read (script_str2ptr (SvPV (ST (0), PL_na))); /* config_file */
PERL_RETURN_INT(rc);
}
@@ -1313,6 +1339,7 @@ static XS (XS_weechat_config_reload)
}
rc = weechat_config_reload (script_str2ptr (SvPV (ST (0), PL_na))); /* config_file */
PERL_RETURN_INT(rc);
}
@@ -1371,6 +1398,7 @@ static XS (XS_weechat_prefix)
}
result = weechat_prefix (SvPV (ST (0), PL_na));
PERL_RETURN_STRING(result);
}
@@ -1399,6 +1427,7 @@ static XS (XS_weechat_color)
}
result = weechat_color (SvPV (ST (0), PL_na));
PERL_RETURN_STRING(result);
}
@@ -1590,6 +1619,7 @@ static XS (XS_weechat_hook_command)
SvPV (ST (4), PL_na), /* completion */
&weechat_perl_api_hook_command_cb,
SvPV (ST (5), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -1655,6 +1685,7 @@ static XS (XS_weechat_hook_timer)
SvIV (ST (2)), /* max_calls */
&weechat_perl_api_hook_timer_cb,
SvPV (ST (3), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -1721,6 +1752,7 @@ static XS (XS_weechat_hook_fd)
SvIV (ST (3)), /* exception */
&weechat_perl_api_hook_fd_cb,
SvPV (ST (4), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -1796,6 +1828,7 @@ static XS (XS_weechat_hook_print)
SvIV (ST (2)), /* strip_colors */
&weechat_perl_api_hook_print_cb,
SvPV (ST (3), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -1882,6 +1915,7 @@ static XS (XS_weechat_hook_signal)
SvPV (ST (0), PL_na), /* signal */
&weechat_perl_api_hook_signal_cb,
SvPV (ST (1), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -2002,6 +2036,7 @@ static XS (XS_weechat_hook_config)
SvPV (ST (1), PL_na), /* option */
&weechat_perl_api_hook_config_cb,
SvPV (ST (2), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -2074,6 +2109,7 @@ static XS (XS_weechat_hook_completion)
SvPV (ST (0), PL_na), /* completion */
&weechat_perl_api_hook_completion_cb,
SvPV (ST (1), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -2130,6 +2166,7 @@ static XS (XS_weechat_hook_modifier)
SvPV (ST (0), PL_na), /* modifier */
&weechat_perl_api_hook_modifier_cb,
SvPV (ST (1), PL_na))); /* perl function */
PERL_RETURN_STRING_FREE(result);
}
@@ -2160,6 +2197,7 @@ static XS (XS_weechat_hook_modifier_exec)
result = weechat_hook_modifier_exec (SvPV (ST (0), PL_na), /* modifier */
SvPV (ST (1), PL_na), /* modifier_data */
SvPV (ST (2), PL_na)); /* string */
PERL_RETURN_STRING_FREE(result);
}
@@ -2316,6 +2354,7 @@ static XS (XS_weechat_buffer_new)
SvPV (ST (2), PL_na), /* function input */
&weechat_perl_api_close_cb,
SvPV (ST (3), PL_na))); /* function close */
PERL_RETURN_STRING_FREE(result);
}
@@ -2345,6 +2384,7 @@ static XS (XS_weechat_buffer_search)
result = script_ptr2str (weechat_buffer_search (SvPV (ST (0), PL_na), /* category */
SvPV (ST (1), PL_na))); /* name */
PERL_RETURN_STRING_FREE(result);
}
@@ -2405,6 +2445,7 @@ static XS (XS_weechat_buffer_get)
value = weechat_buffer_get (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */
SvPV (ST (1), PL_na)); /* property */
PERL_RETURN_STRING(value);
}
@@ -2467,6 +2508,7 @@ static XS (XS_weechat_nicklist_add_group)
SvPV (ST (2), PL_na), /* name */
SvPV (ST (3), PL_na), /* color */
SvIV (ST (4)))); /* visible */
PERL_RETURN_STRING_FREE(result);
}
@@ -2497,6 +2539,7 @@ static XS (XS_weechat_nicklist_search_group)
result = script_ptr2str (weechat_nicklist_search_group (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */
script_str2ptr (SvPV (ST (1), PL_na)), /* from_group */
SvPV (ST (2), PL_na))); /* name */
PERL_RETURN_STRING_FREE(result);
}
@@ -2537,6 +2580,7 @@ static XS (XS_weechat_nicklist_add_nick)
char_prefix,
SvPV (ST (5), PL_na), /* prefix_color */
SvIV (ST (6)))); /* visible */
PERL_RETURN_STRING_FREE(result);
}
@@ -2567,6 +2611,7 @@ static XS (XS_weechat_nicklist_search_nick)
result = script_ptr2str (weechat_nicklist_search_nick (script_str2ptr (SvPV (ST (0), PL_na)), /* buffer */
script_str2ptr (SvPV (ST (1), PL_na)), /* from_group */
SvPV (ST (2), PL_na))); /* name */
PERL_RETURN_STRING_FREE(result);
}
@@ -2656,6 +2701,280 @@ static XS (XS_weechat_nicklist_remove_all)
PERL_RETURN_OK;
}
/*
* weechat::bar_item_search: search a bar item
*/
static XS (XS_weechat_bar_item_search)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_bar_item_search (SvPV (ST (0), PL_na))); /* name */
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat_perl_api_bar_item_build_cb: callback for building bar item
*/
char *
weechat_perl_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window,
int max_width)
{
struct t_script_callback *script_callback;
char *perl_argv[4], *ret;
static char buf[32];
script_callback = (struct t_script_callback *)data;
snprintf (buf, sizeof (buf) - 1, "%d", max_width);
perl_argv[0] = script_ptr2str (item);
perl_argv[1] = script_ptr2str (window);
perl_argv[2] = buf;
perl_argv[3] = NULL;
ret = (char *)weechat_perl_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
perl_argv);
if (perl_argv[0])
free (perl_argv[0]);
if (perl_argv[1])
free (perl_argv[1]);
return ret;
}
/*
* weechat::bar_item_new: add a new bar item
*/
static XS (XS_weechat_bar_item_new)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (script_api_bar_item_new (weechat_perl_plugin,
perl_current_script,
SvPV (ST (0), PL_na), /* name */
&weechat_perl_api_bar_item_build_cb,
SvPV (ST (1), PL_na))); /* function build */
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::bar_item_update: update a bar item on screen
*/
static XS (XS_weechat_bar_item_update)
{
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update");
PERL_RETURN_ERROR;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update");
PERL_RETURN_ERROR;
}
weechat_bar_item_update (SvPV (ST (0), PL_na)); /* name */
PERL_RETURN_OK;
}
/*
* weechat::bar_item_remove: remove a bar item
*/
static XS (XS_weechat_bar_item_remove)
{
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove");
PERL_RETURN_ERROR;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove");
PERL_RETURN_ERROR;
}
script_api_bar_item_remove (weechat_perl_plugin,
perl_current_script,
script_str2ptr (SvPV (ST (0), PL_na))); /* item */
PERL_RETURN_OK;
}
/*
* weechat::bar_search: search a bar
*/
static XS (XS_weechat_bar_search)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_bar_search (SvPV (ST (0), PL_na))); /* name */
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::bar_new: add a new bar
*/
static XS (XS_weechat_bar_new)
{
char *result;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new");
PERL_RETURN_EMPTY;
}
if (items < 6)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
PERL_RETURN_EMPTY;
}
result = script_ptr2str (weechat_bar_new (SvPV (ST (0), PL_na), /* name */
SvPV (ST (1), PL_na), /* type */
SvPV (ST (2), PL_na), /* position */
SvIV (ST (3)), /* size */
SvIV (ST (4)), /* separator */
SvPV (ST (5), PL_na))); /* items */
PERL_RETURN_STRING_FREE(result);
}
/*
* weechat::bar_update: update a bar on screen
*/
static XS (XS_weechat_bar_update)
{
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_update");
PERL_RETURN_ERROR;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_update");
PERL_RETURN_ERROR;
}
weechat_bar_update (SvPV (ST (0), PL_na)); /* name */
PERL_RETURN_OK;
}
/*
* weechat::bar_remove: remove a bar
*/
static XS (XS_weechat_bar_remove)
{
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove");
PERL_RETURN_ERROR;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove");
PERL_RETURN_ERROR;
}
weechat_bar_remove (script_str2ptr (SvPV (ST (0), PL_na))); /* bar */
PERL_RETURN_OK;
}
/*
* weechat::command: execute a command on a buffer
*/
@@ -2712,9 +3031,278 @@ static XS (XS_weechat_info_get)
}
value = weechat_info_get (SvPV (ST (0), PL_na));
PERL_RETURN_STRING(value);
}
/*
* weechat::infolist_get: get list with infos
*/
static XS (XS_weechat_infolist_get)
{
char *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get");
PERL_RETURN_EMPTY;
}
value = script_ptr2str (weechat_infolist_get (SvPV (ST (0), PL_na), /* name */
script_str2ptr (SvPV (ST (1), PL_na)))); /* pointer */
PERL_RETURN_STRING_FREE(value);
}
/*
* weechat::infolist_next: move item pointer to next item in infolist
*/
static XS (XS_weechat_infolist_next)
{
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next");
PERL_RETURN_INT(0);
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next");
PERL_RETURN_INT(0);
}
value = weechat_infolist_next (script_str2ptr (SvPV (ST (0), PL_na))); /* infolist */
PERL_RETURN_INT(value);
}
/*
* weechat::infolist_prev: move item pointer to previous item in infolist
*/
static XS (XS_weechat_infolist_prev)
{
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev");
PERL_RETURN_INT(0);
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev");
PERL_RETURN_INT(0);
}
value = weechat_infolist_prev (script_str2ptr (SvPV (ST (0), PL_na))); /* infolist */
PERL_RETURN_INT(value);
}
/*
* weechat::infolist_fields: get list of fields for current item of infolist
*/
static XS (XS_weechat_infolist_fields)
{
char *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields");
PERL_RETURN_EMPTY;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields");
PERL_RETURN_EMPTY;
}
value = weechat_infolist_fields (script_str2ptr (SvPV (ST (0), PL_na))); /* infolist */
PERL_RETURN_STRING(value);
}
/*
* weechat::infolist_integer: get integer value of a variable in infolist
*/
static XS (XS_weechat_infolist_integer)
{
int value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer");
PERL_RETURN_INT(0);
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer");
PERL_RETURN_INT(0);
}
value = weechat_infolist_integer (script_str2ptr (SvPV (ST (0), PL_na)), /* infolist */
SvPV (ST (1), PL_na)); /* variable */
PERL_RETURN_INT(value);
}
/*
* weechat::infolist_string: get string value of a variable in infolist
*/
static XS (XS_weechat_infolist_string)
{
char *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string");
PERL_RETURN_EMPTY;
}
value = weechat_infolist_string (script_str2ptr (SvPV (ST (0), PL_na)), /* infolist */
SvPV (ST (1), PL_na)); /* variable */
PERL_RETURN_STRING(value);
}
/*
* weechat::infolist_pointer: get pointer value of a variable in infolist
*/
static XS (XS_weechat_infolist_pointer)
{
char *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer");
PERL_RETURN_EMPTY;
}
value = script_ptr2str (weechat_infolist_pointer (script_str2ptr (SvPV (ST (0), PL_na)), /* infolist */
SvPV (ST (1), PL_na))); /* variable */
PERL_RETURN_STRING_FREE(value);
}
/*
* weechat::infolist_time: get time value of a variable in infolist
*/
static XS (XS_weechat_infolist_time)
{
time_t time;
char timebuffer[64], *value;
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time");
PERL_RETURN_EMPTY;
}
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time");
PERL_RETURN_EMPTY;
}
time = weechat_infolist_time (script_str2ptr (SvPV (ST (0), PL_na)), /* infolist */
SvPV (ST (1), PL_na)); /* variable */
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
value = strdup (timebuffer);
PERL_RETURN_STRING_FREE(value);
}
/*
* weechat::infolist_free: free infolist
*/
static XS (XS_weechat_infolist_free)
{
dXSARGS;
/* make C compiler happy */
(void) cv;
if (!perl_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free");
PERL_RETURN_ERROR;
}
if (items < 1)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free");
PERL_RETURN_ERROR;
}
weechat_infolist_free (script_str2ptr (SvPV (ST (0), PL_na))); /* infolist */
PERL_RETURN_OK;
}
/*
* weechat_perl_api_init: initialize subroutines
*/
@@ -2794,8 +3382,25 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::nicklist_remove_group", XS_weechat_nicklist_remove_group, "weechat");
newXS ("weechat::nicklist_remove_nick", XS_weechat_nicklist_remove_nick, "weechat");
newXS ("weechat::nicklist_remove_all", XS_weechat_nicklist_remove_all, "weechat");
newXS ("weechat::bar_item_search", XS_weechat_bar_item_search, "weechat");
newXS ("weechat::bar_item_new", XS_weechat_bar_item_new, "weechat");
newXS ("weechat::bar_item_update", XS_weechat_bar_item_update, "weechat");
newXS ("weechat::bar_item_remove", XS_weechat_bar_item_remove, "weechat");
newXS ("weechat::bar_search", XS_weechat_bar_search, "weechat");
newXS ("weechat::bar_new", XS_weechat_bar_new, "weechat");
newXS ("weechat::bar_update", XS_weechat_bar_update, "weechat");
newXS ("weechat::bar_remove", XS_weechat_bar_remove, "weechat");
newXS ("weechat::command", XS_weechat_command, "weechat");
newXS ("weechat::info_get", XS_weechat_info_get, "weechat");
newXS ("weechat::infolist_get", XS_weechat_infolist_get, "weechat");
newXS ("weechat::infolist_next", XS_weechat_infolist_next, "weechat");
newXS ("weechat::infolist_prev", XS_weechat_infolist_prev, "weechat");
newXS ("weechat::infolist_fields", XS_weechat_infolist_fields, "weechat");
newXS ("weechat::infolist_integer", XS_weechat_infolist_integer, "weechat");
newXS ("weechat::infolist_string", XS_weechat_infolist_string, "weechat");
newXS ("weechat::infolist_pointer", XS_weechat_infolist_pointer, "weechat");
newXS ("weechat::infolist_time", XS_weechat_infolist_time, "weechat");
newXS ("weechat::infolist_free", XS_weechat_infolist_free, "weechat");
/* interface constants */
stash = gv_stashpv ("weechat", TRUE);
@@ -175,6 +175,7 @@ weechat_python_api_iconv_to_internal (PyObject *self, PyObject *args)
}
result = weechat_iconv_to_internal (charset, string);
PYTHON_RETURN_STRING_FREE(result);
}
@@ -208,6 +209,7 @@ weechat_python_api_iconv_from_internal (PyObject *self, PyObject *args)
}
result = weechat_iconv_from_internal (charset, string);
PYTHON_RETURN_STRING_FREE(result);
}
@@ -238,6 +240,7 @@ weechat_python_api_gettext (PyObject *self, PyObject *args)
}
result = weechat_gettext (string);
PYTHON_RETURN_STRING(result);
}
@@ -271,6 +274,7 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args)
}
result = weechat_ngettext (single, plural, count);
PYTHON_RETURN_STRING(result);
}
@@ -363,6 +367,7 @@ weechat_python_api_list_new (PyObject *self, PyObject *args)
}
result = script_ptr2str (weechat_list_new ());
PYTHON_RETURN_STRING_FREE(result);
}
@@ -398,6 +403,7 @@ weechat_python_api_list_add (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_list_add (script_str2ptr (weelist),
data,
where));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -431,6 +437,7 @@ weechat_python_api_list_search (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_list_search (script_str2ptr (weelist),
data));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -464,6 +471,7 @@ weechat_python_api_list_casesearch (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_list_casesearch (script_str2ptr (weelist),
data));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -562,6 +570,7 @@ weechat_python_api_list_next (PyObject *self, PyObject *args)
}
result = script_ptr2str (weechat_list_next (script_str2ptr (item)));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -593,6 +602,7 @@ weechat_python_api_list_prev (PyObject *self, PyObject *args)
}
result = script_ptr2str (weechat_list_prev (script_str2ptr (item)));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -623,6 +633,7 @@ weechat_python_api_list_string (PyObject *self, PyObject *args)
}
result = weechat_list_string (script_str2ptr (item));
PYTHON_RETURN_STRING(result);
}
@@ -654,6 +665,7 @@ weechat_python_api_list_size (PyObject *self, PyObject *args)
}
size = weechat_list_size (script_str2ptr (weelist));
PYTHON_RETURN_INT(size);
}
@@ -825,6 +837,7 @@ weechat_python_api_config_new (PyObject *self, PyObject *args)
filename,
&weechat_python_api_config_reload_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -972,6 +985,7 @@ weechat_python_api_config_new_section (PyObject *self, PyObject *args)
function_write,
&weechat_python_api_config_section_write_default_cb,
function_write_default));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1005,6 +1019,7 @@ weechat_python_api_config_search_section (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_config_search_section (script_str2ptr (config_file),
section_name));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1086,6 +1101,7 @@ weechat_python_api_config_new_option (PyObject *self, PyObject *args)
default_value,
&weechat_python_api_config_option_change_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1121,6 +1137,7 @@ weechat_python_api_config_search_option (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_config_search_option (script_str2ptr (config_file),
script_str2ptr (section),
option_name));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1152,6 +1169,7 @@ weechat_python_api_config_string_to_boolean (PyObject *self, PyObject *args)
}
value = weechat_config_string_to_boolean (text);
PYTHON_RETURN_INT(value);
}
@@ -1187,6 +1205,7 @@ weechat_python_api_config_option_set (PyObject *self, PyObject *args)
rc = weechat_config_option_set (script_str2ptr (option),
new_value,
run_callback);
PYTHON_RETURN_INT(rc);
}
@@ -1218,6 +1237,7 @@ weechat_python_api_config_boolean (PyObject *self, PyObject *args)
}
value = weechat_config_boolean (script_str2ptr (option));
PYTHON_RETURN_INT(value);
}
@@ -1249,6 +1269,7 @@ weechat_python_api_config_integer (PyObject *self, PyObject *args)
}
value = weechat_config_integer (script_str2ptr (option));
PYTHON_RETURN_INT(value);
}
@@ -1279,6 +1300,7 @@ weechat_python_api_config_string (PyObject *self, PyObject *args)
}
value = weechat_config_string (script_str2ptr (option));
PYTHON_RETURN_STRING(value);
}
@@ -1310,6 +1332,7 @@ weechat_python_api_config_color (PyObject *self, PyObject *args)
}
value = weechat_config_color (script_str2ptr (option));
PYTHON_RETURN_INT(value);
}
@@ -1377,6 +1400,7 @@ weechat_python_api_config_write (PyObject *self, PyObject *args)
}
rc = weechat_config_write (script_str2ptr (config_file));
PYTHON_RETURN_INT(rc);
}
@@ -1408,6 +1432,7 @@ weechat_python_api_config_read (PyObject *self, PyObject *args)
}
rc = weechat_config_read (script_str2ptr (config_file));
PYTHON_RETURN_INT(rc);
}
@@ -1439,6 +1464,7 @@ weechat_python_api_config_reload (PyObject *self, PyObject *args)
}
rc = weechat_config_reload (script_str2ptr (config_file));
PYTHON_RETURN_INT(rc);
}
@@ -1502,6 +1528,7 @@ weechat_python_api_prefix (PyObject *self, PyObject *args)
}
result = weechat_prefix (prefix);
PYTHON_RETURN_STRING(result);
}
@@ -1532,6 +1559,7 @@ weechat_python_api_color (PyObject *self, PyObject *args)
}
result = weechat_color (color);
PYTHON_RETURN_STRING(result);
}
@@ -1751,6 +1779,7 @@ weechat_python_api_hook_command (PyObject *self, PyObject *args)
completion,
&weechat_python_api_hook_command_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1824,6 +1853,7 @@ weechat_python_api_hook_timer (PyObject *self, PyObject *args)
max_calls,
&weechat_python_api_hook_timer_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1899,6 +1929,7 @@ weechat_python_api_hook_fd (PyObject *self, PyObject *args)
exception,
&weechat_python_api_hook_fd_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -1982,6 +2013,7 @@ weechat_python_api_hook_print (PyObject *self, PyObject *args)
strip_colors,
&weechat_python_api_hook_print_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2072,6 +2104,7 @@ weechat_python_api_hook_signal (PyObject *self, PyObject *args)
signal,
&weechat_python_api_hook_signal_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2199,6 +2232,7 @@ weechat_python_api_hook_config (PyObject *self, PyObject *args)
option,
&weechat_python_api_hook_config_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2275,6 +2309,7 @@ weechat_python_api_hook_completion (PyObject *self, PyObject *args)
completion,
&weechat_python_api_hook_completion_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2335,6 +2370,7 @@ weechat_python_api_hook_modifier (PyObject *self, PyObject *args)
modifier,
&weechat_python_api_hook_modifier_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2368,6 +2404,7 @@ weechat_python_api_hook_modifier_exec (PyObject *self, PyObject *args)
}
result = weechat_hook_modifier_exec (modifier, modifier_data, string);
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2533,6 +2570,7 @@ weechat_python_api_buffer_new (PyObject *self, PyObject *args)
function_input,
&weechat_python_api_close_cb,
function_close));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2566,6 +2604,7 @@ weechat_python_api_buffer_search (PyObject *self, PyObject *args)
}
result = script_ptr2str (weechat_buffer_search (category, name));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2633,6 +2672,7 @@ weechat_python_api_buffer_get (PyObject *self, PyObject *args)
}
value = weechat_buffer_get (script_str2ptr (buffer), property);
PYTHON_RETURN_STRING(value);
}
@@ -2709,6 +2749,7 @@ weechat_python_api_nicklist_add_group (PyObject *self, PyObject *args)
name,
color,
visible));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2744,6 +2785,7 @@ weechat_python_api_nicklist_search_group (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_nicklist_search_group (script_str2ptr (buffer),
script_str2ptr (from_group),
name));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2795,6 +2837,7 @@ weechat_python_api_nicklist_add_nick (PyObject *self, PyObject *args)
char_prefix,
prefix_color,
visible));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2830,6 +2873,7 @@ weechat_python_api_nicklist_search_nick (PyObject *self, PyObject *args)
result = script_ptr2str (weechat_nicklist_search_nick (script_str2ptr (buffer),
script_str2ptr (from_group),
name));
PYTHON_RETURN_STRING_FREE(result);
}
@@ -2930,6 +2974,312 @@ weechat_python_api_nicklist_remove_all (PyObject *self, PyObject *args)
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_bar_item_search: search a bar item
*/
static PyObject *
weechat_python_api_bar_item_search (PyObject *self, PyObject *args)
{
char *name, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_search");
PYTHON_RETURN_EMPTY;
}
name = NULL;
if (!PyArg_ParseTuple (args, "s", &name))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_search");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_bar_item_search (name));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_bar_item_build_cb: callback for building bar item
*/
char *
weechat_python_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
struct t_gui_window *window,
int max_width)
{
struct t_script_callback *script_callback;
char *python_argv[4], *ret;
static char buf[32];
script_callback = (struct t_script_callback *)data;
snprintf (buf, sizeof (buf) - 1, "%d", max_width);
python_argv[0] = script_ptr2str (item);
python_argv[1] = script_ptr2str (window);
python_argv[2] = buf;
python_argv[3] = NULL;
ret = (char *)weechat_python_exec (script_callback->script,
WEECHAT_SCRIPT_EXEC_STRING,
script_callback->function,
python_argv);
if (python_argv[0])
free (python_argv[0]);
if (python_argv[1])
free (python_argv[1]);
return ret;
}
/*
* weechat_python_api_bar_item_new: add a new bar item
*/
static PyObject *
weechat_python_api_bar_item_new (PyObject *self, PyObject *args)
{
char *name, *function, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_new");
PYTHON_RETURN_EMPTY;
}
name = NULL;
function = NULL;
if (!PyArg_ParseTuple (args, "ss", &name, &function))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_new");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (script_api_bar_item_new (weechat_python_plugin,
python_current_script,
name,
&weechat_python_api_bar_item_build_cb,
function));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_bar_item_update: update a bar item on screen
*/
static PyObject *
weechat_python_api_bar_item_update (PyObject *self, PyObject *args)
{
char *name;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_update");
PYTHON_RETURN_ERROR;
}
name = NULL;
if (!PyArg_ParseTuple (args, "s", &name))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_update");
PYTHON_RETURN_ERROR;
}
weechat_bar_item_update (name);
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_bar_item_remove: remove a bar item
*/
static PyObject *
weechat_python_api_bar_item_remove (PyObject *self, PyObject *args)
{
char *item;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item_remove");
PYTHON_RETURN_ERROR;
}
item = NULL;
if (!PyArg_ParseTuple (args, "s", &item))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item_remove");
PYTHON_RETURN_ERROR;
}
script_api_bar_item_remove (weechat_python_plugin,
python_current_script,
script_str2ptr (item));
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_bar_search: search a bar
*/
static PyObject *
weechat_python_api_bar_search (PyObject *self, PyObject *args)
{
char *name, *result;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_search");
PYTHON_RETURN_EMPTY;
}
name = NULL;
if (!PyArg_ParseTuple (args, "s", &name))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_search");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_bar_search (name));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_bar_new: add a new bar
*/
static PyObject *
weechat_python_api_bar_new (PyObject *self, PyObject *args)
{
char *name, *type, *position, *items, *result;
int size, separator;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_new");
PYTHON_RETURN_EMPTY;
}
name = NULL;
type = NULL;
position = NULL;
size = 0;
separator = 0;
items = NULL;
if (!PyArg_ParseTuple (args, "sssiis", &name, &type, &position, &size,
&separator, &items))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_new");
PYTHON_RETURN_EMPTY;
}
result = script_ptr2str (weechat_bar_new (name,
type,
position,
size,
separator,
items));
PYTHON_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_bar_update: update a bar on screen
*/
static PyObject *
weechat_python_api_bar_update (PyObject *self, PyObject *args)
{
char *name;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_item");
PYTHON_RETURN_ERROR;
}
name = NULL;
if (!PyArg_ParseTuple (args, "s", &name))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_item");
PYTHON_RETURN_ERROR;
}
weechat_bar_update (name);
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_bar_remove: remove a bar
*/
static PyObject *
weechat_python_api_bar_remove (PyObject *self, PyObject *args)
{
char *bar;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("bar_remove");
PYTHON_RETURN_ERROR;
}
bar = NULL;
if (!PyArg_ParseTuple (args, "s", &bar))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("bar_remove");
PYTHON_RETURN_ERROR;
}
weechat_bar_remove (script_str2ptr (bar));
PYTHON_RETURN_OK;
}
/*
* weechat_python_api_command: send command to server
*/
@@ -2992,9 +3342,308 @@ weechat_python_api_info_get (PyObject *self, PyObject *args)
}
value = weechat_info_get (info);
PYTHON_RETURN_STRING(value);
}
/*
* weechat_python_api_infolist_get: get list with infos
*/
static PyObject *
weechat_python_api_infolist_get (PyObject *self, PyObject *args)
{
char *name, *pointer, *value;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_get");
PYTHON_RETURN_EMPTY;
}
name = NULL;
pointer = NULL;
if (!PyArg_ParseTuple (args, "ss", &name, &pointer))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_get");
PYTHON_RETURN_EMPTY;
}
value = script_ptr2str (weechat_infolist_get (name,
script_str2ptr (pointer)));
PYTHON_RETURN_STRING_FREE(value);
}
/*
* weechat_python_api_infolist_next: move item pointer to next item in infolist
*/
static PyObject *
weechat_python_api_infolist_next (PyObject *self, PyObject *args)
{
char *infolist;
int value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_next");
PYTHON_RETURN_INT(0);
}
infolist = NULL;
if (!PyArg_ParseTuple (args, "s", &infolist))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_next");
PYTHON_RETURN_INT(0);
}
value = weechat_infolist_next (script_str2ptr (infolist));
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_infolist_prev: move item pointer to previous item in infolist
*/
static PyObject *
weechat_python_api_infolist_prev (PyObject *self, PyObject *args)
{
char *infolist;
int value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_prev");
PYTHON_RETURN_INT(0);
}
infolist = NULL;
if (!PyArg_ParseTuple (args, "s", &infolist))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_prev");
PYTHON_RETURN_INT(0);
}
value = weechat_infolist_prev (script_str2ptr (infolist));
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_infolist_fields: get list of fields for current item of infolist
*/
static PyObject *
weechat_python_api_infolist_fields (PyObject *self, PyObject *args)
{
char *infolist, *value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_fields");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
if (!PyArg_ParseTuple (args, "s", &infolist))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_fields");
PYTHON_RETURN_EMPTY;
}
value = weechat_infolist_fields (script_str2ptr (infolist));
PYTHON_RETURN_STRING(value);
}
/*
* weechat_python_api_infolist_integer: get integer value of a variable in infolist
*/
static PyObject *
weechat_python_api_infolist_integer (PyObject *self, PyObject *args)
{
char *infolist, *variable;
int value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_integer");
PYTHON_RETURN_INT(0);
}
infolist = NULL;
variable = NULL;
if (!PyArg_ParseTuple (args, "s&", &infolist, &variable))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_integer");
PYTHON_RETURN_INT(0);
}
value = weechat_infolist_integer (script_str2ptr (infolist),
variable);
PYTHON_RETURN_INT(value);
}
/*
* weechat_python_api_infolist_string: get string value of a variable in infolist
*/
static PyObject *
weechat_python_api_infolist_string (PyObject *self, PyObject *args)
{
char *infolist, *variable, *value;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_string");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
variable = NULL;
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_string");
PYTHON_RETURN_EMPTY;
}
value = weechat_infolist_string (script_str2ptr (infolist),
variable);
PYTHON_RETURN_STRING(value);
}
/*
* weechat_python_api_infolist_pointer: get pointer value of a variable in infolist
*/
static PyObject *
weechat_python_api_infolist_pointer (PyObject *self, PyObject *args)
{
char *infolist, *variable, *value;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_pointer");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
variable = NULL;
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_pointer");
PYTHON_RETURN_EMPTY;
}
value = script_ptr2str (weechat_infolist_string (script_str2ptr (infolist),
variable));
PYTHON_RETURN_STRING_FREE(value);
}
/*
* weechat_python_api_infolist_time: get time value of a variable in infolist
*/
static PyObject *
weechat_python_api_infolist_time (PyObject *self, PyObject *args)
{
char *infolist, *variable, timebuffer[64], *value;
time_t time;
PyObject *object;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_time");
PYTHON_RETURN_EMPTY;
}
infolist = NULL;
variable = NULL;
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_time");
PYTHON_RETURN_EMPTY;
}
time = weechat_infolist_time (script_str2ptr (infolist),
variable);
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
value = strdup (timebuffer);
PYTHON_RETURN_STRING_FREE(value);
}
/*
* weechat_python_api_infolist_free: free infolist
*/
static PyObject *
weechat_python_api_infolist_free (PyObject *self, PyObject *args)
{
char *infolist;
/* make C compiler happy */
(void) self;
if (!python_current_script)
{
WEECHAT_SCRIPT_MSG_NOT_INITIALIZED("infolist_free");
PYTHON_RETURN_ERROR;
}
infolist = NULL;
if (!PyArg_ParseTuple (args, "s", &infolist))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("infolist_free");
PYTHON_RETURN_ERROR;
}
weechat_infolist_free (script_str2ptr (infolist));
PYTHON_RETURN_OK;
}
/*
* Python subroutines
*/
@@ -3068,7 +3717,24 @@ PyMethodDef weechat_python_funcs[] =
{ "nicklist_remove_group", &weechat_python_api_nicklist_remove_group, METH_VARARGS, "" },
{ "nicklist_remove_nick", &weechat_python_api_nicklist_remove_nick, METH_VARARGS, "" },
{ "nicklist_remove_all", &weechat_python_api_nicklist_remove_all, METH_VARARGS, "" },
{ "bar_item_search", &weechat_python_api_bar_item_search, METH_VARARGS, "" },
{ "bar_item_new", &weechat_python_api_bar_item_new, METH_VARARGS, "" },
{ "bar_item_update", &weechat_python_api_bar_item_update, METH_VARARGS, "" },
{ "bar_item_remove", &weechat_python_api_bar_item_remove, METH_VARARGS, "" },
{ "bar_search", &weechat_python_api_bar_search, METH_VARARGS, "" },
{ "bar_new", &weechat_python_api_bar_new, METH_VARARGS, "" },
{ "bar_update", &weechat_python_api_bar_update, METH_VARARGS, "" },
{ "bar_remove", &weechat_python_api_bar_remove, METH_VARARGS, "" },
{ "command", &weechat_python_api_command, METH_VARARGS, "" },
{ "info_get", &weechat_python_api_info_get, METH_VARARGS, "" },
{ "infolist_get", &weechat_python_api_infolist_get, METH_VARARGS, "" },
{ "infolist_next", &weechat_python_api_infolist_next, METH_VARARGS, "" },
{ "infolist_prev", &weechat_python_api_infolist_prev, METH_VARARGS, "" },
{ "infolist_fields", &weechat_python_api_infolist_fields, METH_VARARGS, "" },
{ "infolist_integer", &weechat_python_api_infolist_integer, METH_VARARGS, "" },
{ "infolist_string", &weechat_python_api_infolist_string, METH_VARARGS, "" },
{ "infolist_pointer", &weechat_python_api_infolist_pointer, METH_VARARGS, "" },
{ "infolist_time", &weechat_python_api_infolist_time, METH_VARARGS, "" },
{ "infolist_free", &weechat_python_api_infolist_free, METH_VARARGS, "" },
{ NULL, NULL, 0, NULL }
};
File diff suppressed because it is too large Load Diff
+65
View File
@@ -814,6 +814,71 @@ script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
}
}
/*
* script_api_bar_item_new: add a new bar item
*/
struct t_gui_bar_item *
script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *name,
char *(*build_callback)(void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
int remaining_space),
char *function_build)
{
struct t_script_callback *new_script_callback;
struct t_gui_bar_item *new_item;
new_script_callback = script_callback_alloc ();
if (!new_script_callback)
return NULL;
new_item = weechat_bar_item_new (name,
(function_build && function_build[0]) ?
build_callback : NULL,
(function_build && function_build[0]) ?
new_script_callback : NULL);
if (!new_item)
{
free (new_script_callback);
return NULL;
}
new_script_callback->script = script;
new_script_callback->function = (function_build && function_build[0]) ?
strdup (function_build) : NULL;
new_script_callback->bar_item = new_item;
script_callback_add (script, new_script_callback);
return new_item;
}
/*
* script_api_bar_item_remove: remove a bar item
*/
void
script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_bar_item *item)
{
struct t_script_callback *ptr_script_callback;
if (!weechat_plugin || !script || !item)
return;
weechat_bar_item_remove (item);
for (ptr_script_callback = script->callbacks; ptr_script_callback;
ptr_script_callback = ptr_script_callback->next_callback)
{
if (ptr_script_callback->bar_item == item)
script_callback_remove (script, ptr_script_callback);
}
}
/*
* script_api_command: execute a command (simulate user entry)
*/
+11
View File
@@ -151,6 +151,17 @@ extern void script_api_buffer_close (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
int switch_to_another);
extern struct t_gui_bar_item *script_api_bar_item_new (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
char *name,
char *(*build_callback)(void *data,
struct t_gui_bar_item *item,
struct t_gui_window *window,
int remaining_space),
char *function_build);
extern void script_api_bar_item_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_bar_item *item);
extern void script_api_command (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *script,
struct t_gui_buffer *buffer,
+6 -1
View File
@@ -46,6 +46,7 @@ script_callback_alloc ()
new_script_callback->config_option = NULL;
new_script_callback->hook = NULL;
new_script_callback->buffer = NULL;
new_script_callback->bar_item = NULL;
return new_script_callback;
}
@@ -85,7 +86,7 @@ script_callback_remove (struct t_plugin_script *script,
if (script->callbacks == script_callback)
script->callbacks = script_callback->next_callback;
/* unhook and free data */
/* free data */
if (script_callback->function)
free (script_callback->function);
@@ -117,8 +118,12 @@ script_callback_print_log (struct t_weechat_plugin *weechat_plugin,
weechat_log_printf ("[callback (addr:0x%x)]", script_callback);
weechat_log_printf (" script. . . . . . . : 0x%x", script_callback->script);
weechat_log_printf (" function. . . . . . : '%s'", script_callback->function);
weechat_log_printf (" config_file . . . . : '%s'", script_callback->config_file);
weechat_log_printf (" config_section. . . : '%s'", script_callback->config_section);
weechat_log_printf (" config_option . . . : '%s'", script_callback->config_option);
weechat_log_printf (" hook. . . . . . . . : 0x%x", script_callback->hook);
weechat_log_printf (" buffer. . . . . . . : 0x%x", script_callback->buffer);
weechat_log_printf (" bar_item. . . . . . : 0x%x", script_callback->bar_item);
weechat_log_printf (" prev_callback . . . : 0x%x", script_callback->prev_callback);
weechat_log_printf (" next_callback . . . : 0x%x", script_callback->next_callback);
}
+2 -1
View File
@@ -27,7 +27,8 @@ struct t_script_callback
struct t_config_section *config_section; /* not NULL for config section */
struct t_config_option *config_option; /* not NULL for config option */
struct t_hook *hook; /* not NULL for hook */
struct t_gui_buffer *buffer; /* not NULL for buffer callback*/
struct t_gui_buffer *buffer; /* not NULL for buffer */
struct t_gui_bar_item *bar_item; /* not NULL for bar item */
struct t_script_callback *prev_callback; /* link to next callback */
struct t_script_callback *next_callback; /* link to previous callback */
};
+5
View File
@@ -416,10 +416,12 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
for (ptr_script_callback = script->callbacks; ptr_script_callback;
ptr_script_callback = ptr_script_callback->next_callback)
{
/* unhook */
if (ptr_script_callback->hook)
{
weechat_unhook (ptr_script_callback->hook);
}
/* free config file */
if (ptr_script_callback->config_file
&& !ptr_script_callback->config_section
&& !ptr_script_callback->config_option)
@@ -428,6 +430,9 @@ script_remove (struct t_weechat_plugin *weechat_plugin,
weechat_config_write (ptr_script_callback->config_file);
weechat_config_free (ptr_script_callback->config_file);
}
/* remove bar item */
if (ptr_script_callback->bar_item)
weechat_bar_item_remove (ptr_script_callback->bar_item);
}
/* remove all callbacks created by this script */