summaryrefslogtreecommitdiff
path: root/src/plugins/lua
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/lua')
-rw-r--r--src/plugins/lua/weechat-lua-api.c57
1 files changed, 42 insertions, 15 deletions
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index ae13899ae..fd6d50b43 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -3997,29 +3997,56 @@ weechat_lua_api_bar_item_search (lua_State *L)
char *
weechat_lua_api_bar_item_build_cb (void *data, struct t_gui_bar_item *item,
- struct t_gui_window *window)
+ struct t_gui_window *window,
+ struct t_gui_buffer *buffer,
+ struct t_hashtable *extra_info)
{
struct t_plugin_script_cb *script_callback;
- void *func_argv[3];
+ void *func_argv[5];
char empty_arg[1] = { '\0' }, *ret;
script_callback = (struct t_plugin_script_cb *)data;
if (script_callback && script_callback->function && script_callback->function[0])
{
- func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
- func_argv[1] = API_PTR2STR(item);
- func_argv[2] = API_PTR2STR(window);
-
- ret = (char *)weechat_lua_exec (script_callback->script, NULL,
- WEECHAT_SCRIPT_EXEC_STRING,
- script_callback->function,
- "sss", func_argv);
-
- if (func_argv[1])
- free (func_argv[1]);
- if (func_argv[2])
- free (func_argv[2]);
+ if (strncmp (script_callback->function, "(extra)", 7) == 0)
+ {
+ /* new callback: data, item, window, buffer, extra_info */
+ func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[1] = API_PTR2STR(item);
+ func_argv[2] = API_PTR2STR(window);
+ func_argv[3] = API_PTR2STR(buffer);
+ func_argv[4] = extra_info;
+
+ ret = (char *)weechat_lua_exec (script_callback->script, NULL,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ script_callback->function + 7,
+ "ssssh", func_argv);
+
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[2])
+ free (func_argv[2]);
+ if (func_argv[3])
+ free (func_argv[3]);
+ }
+ else
+ {
+ /* old callback: data, item, window */
+ func_argv[0] = (script_callback->data) ? script_callback->data : empty_arg;
+ func_argv[1] = API_PTR2STR(item);
+ func_argv[2] = API_PTR2STR(window);
+
+ ret = (char *)weechat_lua_exec (script_callback->script, NULL,
+ WEECHAT_SCRIPT_EXEC_STRING,
+ script_callback->function,
+ "sss", func_argv);
+
+ if (func_argv[1])
+ free (func_argv[1]);
+ if (func_argv[2])
+ free (func_argv[2]);
+ }
return ret;
}