Rename callback execte and destroy functions
This commit is contained in:
@@ -108,14 +108,14 @@ api_cons_bad_cmd_usage(const char *const cmd)
|
|||||||
void
|
void
|
||||||
api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args,
|
api_register_command(const char *const plugin_name, const char *command_name, int min_args, int max_args,
|
||||||
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, void *callback,
|
const char **synopsis, const char *description, const char *arguments[][2], const char **examples, void *callback,
|
||||||
void(*callback_func)(PluginCommand *command, gchar **args))
|
void(*callback_exec)(PluginCommand *command, gchar **args))
|
||||||
{
|
{
|
||||||
PluginCommand *command = malloc(sizeof(PluginCommand));
|
PluginCommand *command = malloc(sizeof(PluginCommand));
|
||||||
command->command_name = command_name;
|
command->command_name = command_name;
|
||||||
command->min_args = min_args;
|
command->min_args = min_args;
|
||||||
command->max_args = max_args;
|
command->max_args = max_args;
|
||||||
command->callback = callback;
|
command->callback = callback;
|
||||||
command->callback_func = callback_func;
|
command->callback_exec = callback_exec;
|
||||||
|
|
||||||
CommandHelp *help = malloc(sizeof(CommandHelp));
|
CommandHelp *help = malloc(sizeof(CommandHelp));
|
||||||
|
|
||||||
@@ -145,11 +145,11 @@ api_register_command(const char *const plugin_name, const char *command_name, in
|
|||||||
|
|
||||||
void
|
void
|
||||||
api_register_timed(const char *const plugin_name, void *callback, int interval_seconds,
|
api_register_timed(const char *const plugin_name, void *callback, int interval_seconds,
|
||||||
void (*callback_func)(PluginTimedFunction *timed_function))
|
void (*callback_exec)(PluginTimedFunction *timed_function))
|
||||||
{
|
{
|
||||||
PluginTimedFunction *timed_function = malloc(sizeof(PluginTimedFunction));
|
PluginTimedFunction *timed_function = malloc(sizeof(PluginTimedFunction));
|
||||||
timed_function->callback = callback;
|
timed_function->callback = callback;
|
||||||
timed_function->callback_func = callback_func;
|
timed_function->callback_exec = callback_exec;
|
||||||
timed_function->interval_seconds = interval_seconds;
|
timed_function->interval_seconds = interval_seconds;
|
||||||
timed_function->timer = g_timer_new();
|
timed_function->timer = g_timer_new();
|
||||||
|
|
||||||
@@ -295,13 +295,13 @@ api_win_create(
|
|||||||
const char *const plugin_name,
|
const char *const plugin_name,
|
||||||
const char *tag,
|
const char *tag,
|
||||||
void *callback,
|
void *callback,
|
||||||
void(*destroy)(void *callback),
|
void(*callback_exec)(PluginWindowCallback *window_callback, const char *tag, const char * const line),
|
||||||
void(*callback_func)(PluginWindowCallback *window_callback, const char *tag, const char * const line))
|
void(*callback_destroy)(void *callback))
|
||||||
{
|
{
|
||||||
PluginWindowCallback *window = malloc(sizeof(PluginWindowCallback));
|
PluginWindowCallback *window = malloc(sizeof(PluginWindowCallback));
|
||||||
window->callback = callback;
|
window->callback = callback;
|
||||||
window->callback_func = callback_func;
|
window->callback_exec = callback_exec;
|
||||||
window->destroy = destroy;
|
window->callback_destroy = callback_destroy;
|
||||||
callbacks_add_window_handler(tag, window);
|
callbacks_add_window_handler(tag, window);
|
||||||
wins_new_plugin(tag);
|
wins_new_plugin(tag);
|
||||||
|
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ static GHashTable *p_window_callbacks = NULL;
|
|||||||
static void
|
static void
|
||||||
_free_window_callback(PluginWindowCallback *window_callback)
|
_free_window_callback(PluginWindowCallback *window_callback)
|
||||||
{
|
{
|
||||||
if (window_callback->destroy) {
|
if (window_callback->callback_destroy) {
|
||||||
window_callback->destroy(window_callback->callback);
|
window_callback->callback_destroy(window_callback->callback);
|
||||||
}
|
}
|
||||||
free(window_callback);
|
free(window_callback);
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ plugins_run_command(const char * const input)
|
|||||||
g_strfreev(split);
|
g_strfreev(split);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
command->callback_func(command, args);
|
command->callback_exec(command, args);
|
||||||
g_strfreev(split);
|
g_strfreev(split);
|
||||||
g_strfreev(args);
|
g_strfreev(args);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -153,7 +153,7 @@ plugins_run_timed(void)
|
|||||||
gdouble elapsed = g_timer_elapsed(timed_function->timer, NULL);
|
gdouble elapsed = g_timer_elapsed(timed_function->timer, NULL);
|
||||||
|
|
||||||
if (timed_function->interval_seconds > 0 && elapsed >= timed_function->interval_seconds) {
|
if (timed_function->interval_seconds > 0 && elapsed >= timed_function->interval_seconds) {
|
||||||
timed_function->callback_func(timed_function);
|
timed_function->callback_exec(timed_function);
|
||||||
g_timer_start(timed_function->timer);
|
g_timer_start(timed_function->timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,20 +45,20 @@ typedef struct p_command {
|
|||||||
int max_args;
|
int max_args;
|
||||||
CommandHelp *help;
|
CommandHelp *help;
|
||||||
void *callback;
|
void *callback;
|
||||||
void (*callback_func)(struct p_command *command, gchar **args);
|
void (*callback_exec)(struct p_command *command, gchar **args);
|
||||||
} PluginCommand;
|
} PluginCommand;
|
||||||
|
|
||||||
typedef struct p_timed_function {
|
typedef struct p_timed_function {
|
||||||
void *callback;
|
void *callback;
|
||||||
void (*callback_func)(struct p_timed_function *timed_function);
|
void (*callback_exec)(struct p_timed_function *timed_function);
|
||||||
int interval_seconds;
|
int interval_seconds;
|
||||||
GTimer *timer;
|
GTimer *timer;
|
||||||
} PluginTimedFunction;
|
} PluginTimedFunction;
|
||||||
|
|
||||||
typedef struct p_window_input_callback {
|
typedef struct p_window_input_callback {
|
||||||
void *callback;
|
void *callback;
|
||||||
void (*destroy)(void *callback);
|
void (*callback_exec)(struct p_window_input_callback *window_callback, const char *tag, const char * const line);
|
||||||
void (*callback_func)(struct p_window_input_callback *window_callback, const char *tag, const char * const line);
|
void (*callback_destroy)(void *callback);
|
||||||
} PluginWindowCallback;
|
} PluginWindowCallback;
|
||||||
|
|
||||||
void callbacks_init(void);
|
void callbacks_init(void);
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ void
|
|||||||
plugins_win_process_line(char *win, const char * const line)
|
plugins_win_process_line(char *win, const char * const line)
|
||||||
{
|
{
|
||||||
PluginWindowCallback *window = callbacks_get_window_handler(win);
|
PluginWindowCallback *window = callbacks_get_window_handler(win);
|
||||||
window->callback_func(window, win, line);
|
window->callback_exec(window, win, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user