diff options
author | James Booth <boothj5@gmail.com> | 2016-07-03 00:48:22 +0100 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-07-03 00:48:22 +0100 |
commit | 70a79abd3bbc978f2dc1a4c54bdc7202e14ea9a8 (patch) | |
tree | 0794712038fd4513757739d0c9b74baf901de39b /src | |
parent | 31c66bf8573c1d6c486b99808cc471ac6da79b97 (diff) | |
download | profani-tty-70a79abd3bbc978f2dc1a4c54bdc7202e14ea9a8.tar.gz |
Add plugin name to win_create api call
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/api.c | 1 | ||||
-rw-r--r-- | src/plugins/api.h | 1 | ||||
-rw-r--r-- | src/plugins/c_api.c | 9 | ||||
-rw-r--r-- | src/plugins/profapi.c | 2 | ||||
-rw-r--r-- | src/plugins/profapi.h | 3 | ||||
-rw-r--r-- | src/plugins/python_api.c | 5 |
6 files changed, 15 insertions, 6 deletions
diff --git a/src/plugins/api.c b/src/plugins/api.c index 3bdb073b..24947d95 100644 --- a/src/plugins/api.c +++ b/src/plugins/api.c @@ -292,6 +292,7 @@ api_win_exists(const char *tag) void api_win_create( + const char *const plugin_name, const char *tag, void *callback, void(*destroy)(void *callback), diff --git a/src/plugins/api.h b/src/plugins/api.h index afa9f5a1..571c6168 100644 --- a/src/plugins/api.h +++ b/src/plugins/api.h @@ -67,6 +67,7 @@ void api_log_error(const char *message); int api_win_exists(const char *tag); void api_win_create( + const char *const plugin_name, const char *tag, void *callback, void(*destroy)(void *callback), diff --git a/src/plugins/c_api.c b/src/plugins/c_api.c index 1fab40f9..96673972 100644 --- a/src/plugins/c_api.c +++ b/src/plugins/c_api.c @@ -198,11 +198,14 @@ c_api_win_exists(char *tag) } static void -c_api_win_create(char *tag, void(*callback)(char *tag, char *line)) +c_api_win_create(const char *filename, char *tag, void(*callback)(char *tag, char *line)) { + char *plugin_name = _c_plugin_name(filename); + log_debug("Win create %s for %s", tag, plugin_name); + WindowWrapper *wrapper = malloc(sizeof(WindowWrapper)); wrapper->func = callback; - api_win_create(tag, wrapper, free, c_window_callback); + api_win_create(plugin_name, tag, wrapper, free, c_window_callback); } static int @@ -311,6 +314,7 @@ c_api_init(void) _prof_register_command = c_api_register_command; _prof_register_timed = c_api_register_timed; _prof_completer_add = c_api_completer_add; + _prof_win_create = c_api_win_create; prof_completer_remove = c_api_completer_remove; prof_completer_clear = c_api_completer_clear; prof_notify = c_api_notify; @@ -325,7 +329,6 @@ c_api_init(void) prof_log_warning = c_api_log_warning; prof_log_error = c_api_log_error; prof_win_exists = c_api_win_exists; - prof_win_create = c_api_win_create; prof_win_focus = c_api_win_focus; prof_win_show = c_api_win_show; prof_win_show_themed = c_api_win_show_themed; diff --git a/src/plugins/profapi.c b/src/plugins/profapi.c index d80e2690..2f955ecb 100644 --- a/src/plugins/profapi.c +++ b/src/plugins/profapi.c @@ -67,8 +67,8 @@ void (*prof_log_info)(const char *message) = NULL; void (*prof_log_warning)(const char *message) = NULL; void (*prof_log_error)(const char *message) = NULL; +void (*_prof_win_create)(const char *filename, PROF_WIN_TAG win, void(*input_handler)(PROF_WIN_TAG win, char *line)) = NULL; int (*prof_win_exists)(PROF_WIN_TAG win) = NULL; -void (*prof_win_create)(PROF_WIN_TAG win, void(*input_handler)(PROF_WIN_TAG win, char *line)) = NULL; int (*prof_win_focus)(PROF_WIN_TAG win) = NULL; int (*prof_win_show)(PROF_WIN_TAG win, char *line) = NULL; int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line) = NULL; diff --git a/src/plugins/profapi.h b/src/plugins/profapi.h index 8c41b2f2..d42bf70f 100644 --- a/src/plugins/profapi.h +++ b/src/plugins/profapi.h @@ -38,6 +38,7 @@ #define prof_register_command(command_name, min_args, max_args, synopsis, description, arguments, examples, callback) _prof_register_command(__FILE__, command_name, min_args, max_args, synopsis, description, arguments, examples, callback) #define prof_register_timed(callback, interval_seconds) _prof_register_timed(__FILE__, callback, interval_seconds) #define prof_completer_add(key, items) _prof_completer_add(__FILE__, key, items) +#define prof_win_create(win, input_handler) _prof_win_create(__FILE__, win, input_handler) typedef char* PROF_WIN_TAG; @@ -71,8 +72,8 @@ void (*prof_log_info)(const char *message); void (*prof_log_warning)(const char *message); void (*prof_log_error)(const char *message); +void (*_prof_win_create)(const char *filename, PROF_WIN_TAG win, void(*input_handler)(PROF_WIN_TAG win, char *line)); int (*prof_win_exists)(PROF_WIN_TAG win); -void (*prof_win_create)(PROF_WIN_TAG win, void(*input_handler)(PROF_WIN_TAG win, char *line)); int (*prof_win_focus)(PROF_WIN_TAG win); int (*prof_win_show)(PROF_WIN_TAG win, char *line); int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line); diff --git a/src/plugins/python_api.c b/src/plugins/python_api.c index d0d223e8..1a60a07c 100644 --- a/src/plugins/python_api.c +++ b/src/plugins/python_api.c @@ -456,13 +456,16 @@ python_api_win_create(PyObject *self, PyObject *args) char *tag = NULL; PyObject *p_callback = NULL; + char *plugin_name = _python_plugin_name(); + log_debug("Win create %s for %s", tag, plugin_name); + if (!PyArg_ParseTuple(args, "sO", &tag, &p_callback)) { return Py_BuildValue(""); } if (p_callback && PyCallable_Check(p_callback)) { allow_python_threads(); - api_win_create(tag, p_callback, NULL, python_window_callback); + api_win_create(plugin_name, tag, p_callback, NULL, python_window_callback); disable_python_threads(); } |