diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2025-04-01 16:13:55 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2025-04-01 16:13:55 (GMT) |
commit | 1569c4bb1cd25bed29b887c5c8180e7caffc586b (patch) | |
tree | cf758696593a5af54b935b8078426c1fdf052992 /plugins/pychrysalide/bindings.c | |
parent | bb7e4c5e6e4c51da0d9b1a33b571b0c64851c1a8 (diff) |
Handle UI Python plugins and clean the core bindings code.
Diffstat (limited to 'plugins/pychrysalide/bindings.c')
-rw-r--r-- | plugins/pychrysalide/bindings.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/plugins/pychrysalide/bindings.c b/plugins/pychrysalide/bindings.c index 7e87e27..5bc96a6 100644 --- a/plugins/pychrysalide/bindings.c +++ b/plugins/pychrysalide/bindings.c @@ -33,6 +33,7 @@ #include <common/cpp.h> +#include <common/environment.h> #include <common/extstr.h> #include <core/core.h> #include <plugins/pglist.h> @@ -158,6 +159,7 @@ static bool populate_python_modules(const pyinit_details_t *); static void restore_original_pygobject_type(PyTypeObject *); + /* ------------------------ FONCTIONS GLOBALES DE CHRYSALIDE ------------------------ */ @@ -1356,6 +1358,54 @@ void log_pychrysalide_exception(const char *prefix, ...) /* ---------------------------------------------------------------------------------- */ +/* INTERVENTION DANS LA GESTION DE GREFFONS */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : plugin = instance représentant le greffon courant. * +* path = chemin supplémentaire pour l'espace de recherche. * +* * +* Description : Complète les chemins de recherches de Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void extend_python_path(const GPluginModule *plugin, const char *path) +{ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ + PyObject *list; /* Liste de chemins à compléter*/ + PyObject *new; /* Nouveau chemin à intégrer */ + + gstate = PyGILState_Ensure(); + + list = PySys_GetObject("path"); + assert(list != NULL); + + new = PyUnicode_FromString(path); + assert(new != NULL); + + PyList_Append(list, new); + + Py_DECREF(new); + + add_to_env_var("PYTHONPATH", path, ":"); + + PyGILState_Release(gstate); + + g_plugin_module_log_variadic_message(plugin, LMT_INFO, + _("PYTHONPATH environment variable set to '%s'"), + getenv("PYTHONPATH")); + +} + + + +/* ---------------------------------------------------------------------------------- */ /* FONCTIONS GLOBALES DE CHRYSALIDE */ /* ---------------------------------------------------------------------------------- */ |