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

Added new plugin API function: remove_infobar

This commit is contained in:
Sebastien Helleu
2006-02-20 17:01:18 +00:00
parent e0c97562a5
commit 9373a7a47e
24 changed files with 626 additions and 10 deletions
+34
View File
@@ -272,6 +272,39 @@ weechat_lua_print_infobar (lua_State *L)
return 1;
}
/*
* weechat_lua_remove_infobar: remove message(s) in infobar
*/
static int
weechat_lua_remove_infobar (lua_State *L)
{
int n, how_many;
/* make gcc happy */
(void) L;
if (!lua_current_script)
{
lua_plugin->print_server (lua_plugin,
"Lua error: unable to remove infobar message(s), "
"script not initialized");
lua_pushnumber (lua_current_interpreter, 0);
return 1;
}
how_many = 0;
n = lua_gettop (lua_current_interpreter);
if (n == 1)
how_many = lua_tonumber (lua_current_interpreter, -1);
lua_plugin->infobar_remove (lua_plugin, how_many);
lua_pushnumber (lua_current_interpreter, 1);
return 1;
}
/*
* weechat_lua_print: log message in server/channel (current or specified ones)
*/
@@ -1365,6 +1398,7 @@ const struct luaL_reg weechat_lua_funcs[] = {
{ "register", weechat_lua_register},
{ "print", weechat_lua_print},
{ "print_infobar", weechat_lua_print_infobar},
{ "remove_infobar", weechat_lua_remove_infobar},
{ "log", weechat_lua_log},
{ "command", weechat_lua_command},
{ "add_message_handler", weechat_lua_add_message_handler},
+26
View File
@@ -336,6 +336,31 @@ static XS (XS_weechat_print_infobar)
XSRETURN_YES;
}
/*
* weechat::remove_infobar: remove message(s) from infobar
*/
static XS (XS_weechat_remove_infobar)
{
dXSARGS;
/* make gcc happy */
(void) cv;
if (!perl_current_script)
{
perl_plugin->print_server (perl_plugin,
"Perl error: unable to remove infobar message(s), "
"script not initialized");
XSRETURN_NO;
}
perl_plugin->infobar_remove (perl_plugin,
(items >= 1) ? SvIV (ST (0)) : 0);
XSRETURN_YES;
}
/*
* weechat::log: log message in server/channel (current or specified ones)
*/
@@ -1160,6 +1185,7 @@ weechat_perl_xs_init (pTHX)
newXS ("weechat::register", XS_weechat_register, "weechat");
newXS ("weechat::print", XS_weechat_print, "weechat");
newXS ("weechat::print_infobar", XS_weechat_print_infobar, "weechat");
newXS ("weechat::remove_infobar", XS_weechat_remove_infobar, "weechat");
newXS ("weechat::log", XS_weechat_log, "weechat");
newXS ("weechat::command", XS_weechat_command, "weechat");
newXS ("weechat::add_message_handler", XS_weechat_add_message_handler, "weechat");
@@ -247,6 +247,41 @@ weechat_python_print_infobar (PyObject *self, PyObject *args)
return Py_BuildValue ("i", 1);
}
/*
* weechat_python_remove_infobar: remove message(s) from infobar
*/
static PyObject *
weechat_python_remove_infobar (PyObject *self, PyObject *args)
{
int how_many;
/* make gcc happy */
(void) self;
if (!python_current_script)
{
python_plugin->print_server (python_plugin,
"Python error: unable to remove infobar message(s), "
"script not initialized");
return Py_BuildValue ("i", 0);
}
how_many = 0;
if (!PyArg_ParseTuple (args, "|is", &how_many))
{
python_plugin->print_server (python_plugin,
"Python error: wrong parameters for "
"\"infobar_remove\" function");
return Py_BuildValue ("i", 0);
}
python_plugin->infobar_remove (python_plugin, how_many);
return Py_BuildValue ("i", 1);
}
/*
* weechat_python_log: log message in server/channel (current or specified ones)
*/
@@ -1091,6 +1126,7 @@ PyMethodDef weechat_python_funcs[] = {
{ "register", weechat_python_register, METH_VARARGS, "" },
{ "prnt", weechat_python_print, METH_VARARGS, "" },
{ "print_infobar", weechat_python_print_infobar, METH_VARARGS, "" },
{ "remove_infobar", weechat_python_remove_infobar, METH_VARARGS, "" },
{ "log", weechat_python_log, METH_VARARGS, "" },
{ "command", weechat_python_command, METH_VARARGS, "" },
{ "add_message_handler", weechat_python_add_message_handler, METH_VARARGS, "" },
+39
View File
@@ -319,6 +319,44 @@ weechat_ruby_print_infobar (VALUE class, VALUE delay, VALUE message)
return INT2FIX (1);
}
/*
* weechat_ruby_remove_infobar: remove message(s) from infobar
*/
static VALUE
weechat_ruby_remove_infobar (int argc, VALUE *argv, VALUE class)
{
VALUE how_many;
int c_how_many;
/* make gcc happy */
(void) class;
if (!ruby_current_script)
{
ruby_plugin->print_server (ruby_plugin,
"Ruby error: unable to remove infobar message(s), "
"script not initialized");
return INT2FIX (0);
}
how_many = Qnil;
rb_scan_args (argc, argv, "01", &how_many);
if (!NIL_P (how_many))
{
Check_Type (how_many, T_FIXNUM);
c_how_many = FIX2INT (how_many);
}
else
c_how_many = 0;
ruby_plugin->infobar_remove (ruby_plugin, c_how_many);
return INT2FIX (1);
}
/*
* weechat_ruby_log: log message in server/channel (current or specified ones)
*/
@@ -1713,6 +1751,7 @@ weechat_plugin_init (t_weechat_plugin *plugin)
rb_define_module_function (mWeechat, "register", weechat_ruby_register, 4);
rb_define_module_function (mWeechat, "print", weechat_ruby_print, -1);
rb_define_module_function (mWeechat, "print_infobar", weechat_ruby_print_infobar, 2);
rb_define_module_function (mWeechat, "remove_infobar", weechat_ruby_remove_infobar, -1);
rb_define_module_function (mWeechat, "log", weechat_ruby_log, -1);
rb_define_module_function (mWeechat, "command", weechat_ruby_command, -1);
rb_define_module_function (mWeechat, "add_message_handler", weechat_ruby_add_message_handler, 2);