1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Add plugin name to win_create api call

This commit is contained in:
James Booth 2016-07-03 00:48:22 +01:00
parent 31c66bf857
commit 70a79abd3b
6 changed files with 15 additions and 6 deletions

View File

@ -292,6 +292,7 @@ api_win_exists(const char *tag)
void void
api_win_create( api_win_create(
const char *const plugin_name,
const char *tag, const char *tag,
void *callback, void *callback,
void(*destroy)(void *callback), void(*destroy)(void *callback),

View File

@ -67,6 +67,7 @@ void api_log_error(const char *message);
int api_win_exists(const char *tag); int api_win_exists(const char *tag);
void api_win_create( void api_win_create(
const char *const plugin_name,
const char *tag, const char *tag,
void *callback, void *callback,
void(*destroy)(void *callback), void(*destroy)(void *callback),

View File

@ -198,11 +198,14 @@ c_api_win_exists(char *tag)
} }
static void 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)); WindowWrapper *wrapper = malloc(sizeof(WindowWrapper));
wrapper->func = callback; 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 static int
@ -311,6 +314,7 @@ c_api_init(void)
_prof_register_command = c_api_register_command; _prof_register_command = c_api_register_command;
_prof_register_timed = c_api_register_timed; _prof_register_timed = c_api_register_timed;
_prof_completer_add = c_api_completer_add; _prof_completer_add = c_api_completer_add;
_prof_win_create = c_api_win_create;
prof_completer_remove = c_api_completer_remove; prof_completer_remove = c_api_completer_remove;
prof_completer_clear = c_api_completer_clear; prof_completer_clear = c_api_completer_clear;
prof_notify = c_api_notify; prof_notify = c_api_notify;
@ -325,7 +329,6 @@ c_api_init(void)
prof_log_warning = c_api_log_warning; prof_log_warning = c_api_log_warning;
prof_log_error = c_api_log_error; prof_log_error = c_api_log_error;
prof_win_exists = c_api_win_exists; prof_win_exists = c_api_win_exists;
prof_win_create = c_api_win_create;
prof_win_focus = c_api_win_focus; prof_win_focus = c_api_win_focus;
prof_win_show = c_api_win_show; prof_win_show = c_api_win_show;
prof_win_show_themed = c_api_win_show_themed; prof_win_show_themed = c_api_win_show_themed;

View File

@ -67,8 +67,8 @@ void (*prof_log_info)(const char *message) = NULL;
void (*prof_log_warning)(const char *message) = NULL; void (*prof_log_warning)(const char *message) = NULL;
void (*prof_log_error)(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; 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_focus)(PROF_WIN_TAG win) = NULL;
int (*prof_win_show)(PROF_WIN_TAG win, char *line) = 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; int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line) = NULL;

View File

@ -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_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_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_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; 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_warning)(const char *message);
void (*prof_log_error)(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); 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_focus)(PROF_WIN_TAG win);
int (*prof_win_show)(PROF_WIN_TAG win, char *line); 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); int (*prof_win_show_themed)(PROF_WIN_TAG tag, char *group, char *key, char *def, char *line);

View File

@ -456,13 +456,16 @@ python_api_win_create(PyObject *self, PyObject *args)
char *tag = NULL; char *tag = NULL;
PyObject *p_callback = 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)) { if (!PyArg_ParseTuple(args, "sO", &tag, &p_callback)) {
return Py_BuildValue(""); return Py_BuildValue("");
} }
if (p_callback && PyCallable_Check(p_callback)) { if (p_callback && PyCallable_Check(p_callback)) {
allow_python_threads(); 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(); disable_python_threads();
} }