diff --git a/src/plugins/plugins.c b/src/plugins/plugins.c index 2e39f866..4d8f1f05 100644 --- a/src/plugins/plugins.c +++ b/src/plugins/plugins.c @@ -20,10 +20,7 @@ * */ -#include - #include "config/preferences.h" -#include "plugins/api.h" #include "plugins/callbacks.h" #include "plugins/plugins.h" #include "plugins/python_api.h" @@ -37,17 +34,7 @@ plugins_init(void) { plugins = NULL; - // initialse python and path - Py_Initialize(); - python_check_error(); - python_api_init(); - python_check_error(); - // TODO change to use XDG spec - GString *path = g_string_new(Py_GetPath()); - g_string_append(path, ":./plugins/"); - PySys_SetPath(path->str); - python_check_error(); - g_string_free(path, TRUE); + python_init(); // load plugins gchar **plugins_load = prefs_get_plugins(); @@ -114,5 +101,5 @@ plugins_on_message(const char * const jid, const char * const message) void plugins_shutdown(void) { - Py_Finalize(); + python_shutdown(); } diff --git a/src/plugins/python_api.h b/src/plugins/python_api.h index d598ec68..4eaa59e1 100644 --- a/src/plugins/python_api.h +++ b/src/plugins/python_api.h @@ -23,6 +23,8 @@ #ifndef PYTHON_API_H #define PYTHON_API_H +void python_init(void); void python_api_init(void); +void python_shutdown(void); #endif diff --git a/src/plugins/python_plugins.c b/src/plugins/python_plugins.c index 7750724d..f6486b45 100644 --- a/src/plugins/python_plugins.c +++ b/src/plugins/python_plugins.c @@ -26,9 +26,25 @@ #include "plugins/api.h" #include "plugins/callbacks.h" #include "plugins/plugins.h" +#include "plugins/python_api.h" #include "plugins/python_plugins.h" #include "ui/ui.h" +void +python_init(void) +{ + Py_Initialize(); + python_check_error(); + python_api_init(); + python_check_error(); + // TODO change to use XDG spec + GString *path = g_string_new(Py_GetPath()); + g_string_append(path, ":./plugins/"); + PySys_SetPath(path->str); + python_check_error(); + g_string_free(path, TRUE); +} + ProfPlugin * python_plugin_create(const char * const filename) { @@ -130,3 +146,9 @@ python_check_error(void) PyErr_Clear(); } } + +void +python_shutdown(void) +{ + Py_Finalize(); +}