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

Moved python init and shutdown

This commit is contained in:
James Booth 2013-08-17 23:21:32 +01:00
parent 67972f8eac
commit d2b15cad7c
3 changed files with 26 additions and 15 deletions

View File

@ -20,10 +20,7 @@
* *
*/ */
#include <Python.h>
#include "config/preferences.h" #include "config/preferences.h"
#include "plugins/api.h"
#include "plugins/callbacks.h" #include "plugins/callbacks.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"
#include "plugins/python_api.h" #include "plugins/python_api.h"
@ -37,17 +34,7 @@ plugins_init(void)
{ {
plugins = NULL; plugins = NULL;
// initialse python and path python_init();
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);
// load plugins // load plugins
gchar **plugins_load = prefs_get_plugins(); gchar **plugins_load = prefs_get_plugins();
@ -114,5 +101,5 @@ plugins_on_message(const char * const jid, const char * const message)
void void
plugins_shutdown(void) plugins_shutdown(void)
{ {
Py_Finalize(); python_shutdown();
} }

View File

@ -23,6 +23,8 @@
#ifndef PYTHON_API_H #ifndef PYTHON_API_H
#define PYTHON_API_H #define PYTHON_API_H
void python_init(void);
void python_api_init(void); void python_api_init(void);
void python_shutdown(void);
#endif #endif

View File

@ -26,9 +26,25 @@
#include "plugins/api.h" #include "plugins/api.h"
#include "plugins/callbacks.h" #include "plugins/callbacks.h"
#include "plugins/plugins.h" #include "plugins/plugins.h"
#include "plugins/python_api.h"
#include "plugins/python_plugins.h" #include "plugins/python_plugins.h"
#include "ui/ui.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 * ProfPlugin *
python_plugin_create(const char * const filename) python_plugin_create(const char * const filename)
{ {
@ -130,3 +146,9 @@ python_check_error(void)
PyErr_Clear(); PyErr_Clear();
} }
} }
void
python_shutdown(void)
{
Py_Finalize();
}