diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-19 21:22:10 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2013-08-19 21:22:10 +0200 |
commit | eac1ca929bb23544fa98c7f11f7118e1925b27a3 (patch) | |
tree | 5f1b75a82af98a02a7de29808ace55f3b5d23347 /src/plugins/python | |
parent | 9990917cc7380a92f59fbac2fec8d6a5fc91760c (diff) | |
download | weechat-eac1ca929bb23544fa98c7f11f7118e1925b27a3.zip |
core: add syntax "@buffer:item" in bar items to force the buffer used when displaying the bar item (task #12717)
Diffstat (limited to 'src/plugins/python')
-rw-r--r-- | src/plugins/python/weechat-python-api.c | 61 |
1 files changed, 46 insertions, 15 deletions
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c index 1ab3ad421..f4a9797f9 100644 --- a/src/plugins/python/weechat-python-api.c +++ b/src/plugins/python/weechat-python-api.c @@ -3935,29 +3935,60 @@ weechat_python_api_bar_item_search (PyObject *self, PyObject *args) char * weechat_python_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_python_exec (script_callback->script, - 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] = weechat_python_hashtable_to_dict (extra_info); + + ret = (char *)weechat_python_exec (script_callback->script, + WEECHAT_SCRIPT_EXEC_STRING, + script_callback->function + 7, + "ssssO", 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]); + if (func_argv[4]) + { + Py_XDECREF((PyObject *)func_argv[4]); + } + } + 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_python_exec (script_callback->script, + 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; } |