diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/pychrysa/pychrysa.c | 48 | ||||
-rw-r--r-- | plugins/pychrysa/pychrysa.h | 3 |
2 files changed, 50 insertions, 1 deletions
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c index 7c082d6..c971e56 100644 --- a/plugins/pychrysa/pychrysa.c +++ b/plugins/pychrysa/pychrysa.c @@ -24,6 +24,7 @@ #include "pychrysa.h" +#include <assert.h> #include <errno.h> #include <pygobject.h> #include <stdio.h> @@ -62,6 +63,9 @@ DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("PyChrysalide", "Provides bindings to Python", " /* Note la nature du chargement */ static bool _standalone = true; +/* Réceptacle pour le chargement forcé */ +static PyObject *_chrysalide_module = NULL; + /* Fournit la révision du programme global. */ static PyObject *py_chrysalide_revision(PyObject *, PyObject *); @@ -299,6 +303,8 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) { PyObject *result; /* Module Python à retourner */ bool status; /* Bilan des inclusions */ + GPluginModule *self; /* Représentation interne */ + PluginStatusFlags self_flags; /* Fanions à mettre à jour */ static PyMethodDef py_chrysalide_methods[] = { @@ -400,7 +406,25 @@ PyMODINIT_FUNC PyInit_pychrysalide(void) } if (_standalone) - init_all_plugins(); + { + init_all_plugins(false); + + lock_plugin_list_for_reading(); + + self = get_plugin_by_name("PyChrysalide", NULL); + assert(self != NULL); + + self_flags = g_plugin_module_get_flags(self); + self_flags &= ~(PSF_FAILURE | PSF_LOADED); + self_flags |= (status ? PSF_LOADED : PSF_FAILURE); + + g_plugin_module_override_flags(self, self_flags); + + unlock_plugin_list_for_reading(); + + load_remaning_plugins(); + + } return result; @@ -556,6 +580,8 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) PySys_SetArgv(0, (wchar_t *[]) { NULL }); + _chrysalide_module = PyImport_ImportModule("pychrysalide"); + result = load_python_plugins(plugin); cpi_done: @@ -563,3 +589,23 @@ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *plugin) return result; } + + + +/****************************************************************************** +* * +* Paramètres : plugin = greffon à manipuler. * +* * +* Description : Prend acte du déchargement du greffon. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *plugin) +{ + Py_XDECREF(_chrysalide_module); + +} diff --git a/plugins/pychrysa/pychrysa.h b/plugins/pychrysa/pychrysa.h index 51d0470..eb8fc5b 100644 --- a/plugins/pychrysa/pychrysa.h +++ b/plugins/pychrysa/pychrysa.h @@ -91,6 +91,9 @@ PyMODINIT_FUNC PyInit_pychrysalide(void); /* Prend acte du chargement du greffon. */ G_MODULE_EXPORT bool chrysalide_plugin_init(GPluginModule *); +/* Prend acte du déchargement du greffon. */ +G_MODULE_EXPORT void chrysalide_plugin_exit(GPluginModule *); + #endif /* _PLUGINS_PYCHRYSA_H */ |