diff options
author | James Booth <boothj5@gmail.com> | 2016-03-07 20:44:18 +0000 |
---|---|---|
committer | James Booth <boothj5@gmail.com> | 2016-03-07 20:44:18 +0000 |
commit | 9850e041c8788fe1807978765998089aab778222 (patch) | |
tree | b9fb42f69b0f23e086f9a5f8ccb2e905c722d2f7 /src/plugins/callbacks.c | |
parent | e4071015ea256e172fa9a581cdfa15bd501bd805 (diff) | |
parent | 5cabcf9b79880d550782da2967b9d67a531a8f7d (diff) | |
download | profani-tty-9850e041c8788fe1807978765998089aab778222.tar.gz |
Merge branch 'master' into plugins-python
Diffstat (limited to 'src/plugins/callbacks.c')
-rw-r--r-- | src/plugins/callbacks.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/plugins/callbacks.c b/src/plugins/callbacks.c index a3cbfc1d..6f796259 100644 --- a/src/plugins/callbacks.c +++ b/src/plugins/callbacks.c @@ -46,6 +46,27 @@ static GSList *p_commands = NULL; static GSList *p_timed_functions = NULL; static GHashTable *p_window_callbacks = NULL; +static void +_free_window_callback(PluginWindowCallback *window_callback) +{ + if (window_callback->destroy) { + window_callback->destroy(window_callback->callback); + } + free(window_callback); +} + +void +callbacks_init(void) +{ + p_window_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)_free_window_callback); +} + +void +callbacks_close(void) +{ + g_hash_table_destroy(p_window_callbacks); +} + void callbacks_add_command(PluginCommand *command) { @@ -64,10 +85,6 @@ callbacks_add_timed(PluginTimedFunction *timed_function) void callbacks_add_window_handler(const char *tag, PluginWindowCallback *window_callback) { - if (p_window_callbacks == NULL) { - p_window_callbacks = g_hash_table_new(g_str_hash, g_str_equal); - } - g_hash_table_insert(p_window_callbacks, strdup(tag), window_callback); } |