From 1569c4bb1cd25bed29b887c5c8180e7caffc586b Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Tue, 1 Apr 2025 18:13:55 +0200 Subject: Handle UI Python plugins and clean the core bindings code. --- plugins/pychrysalide/bindings.c | 50 +++++++++++ plugins/pychrysalide/bindings.h | 13 ++- plugins/pychrysalide/core-ui.c | 135 ++++++++++++++++++++++++---- plugins/pychrysalide/core.c | 193 +++++++++++++++------------------------- 4 files changed, 251 insertions(+), 140 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 +#include #include #include #include @@ -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 */ /* ---------------------------------------------------------------------------------- */ diff --git a/plugins/pychrysalide/bindings.h b/plugins/pychrysalide/bindings.h index 1758747..6bf2efa 100644 --- a/plugins/pychrysalide/bindings.h +++ b/plugins/pychrysalide/bindings.h @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * bindings.h - prototypes pour les éléments d'un socle commun aux fonctionnalités graphiques et non graphiques * - * Copyright (C) 2024 Cyrille Bagard + * Copyright (C) 2024-2025 Cyrille Bagard * * This file is part of Chrysalide. * @@ -44,6 +44,9 @@ +/* ------------------------ FONCTIONNALITES DE MISE EN PLACE ------------------------ */ + + /* Charge un module GI dans Python avec une version attendue. */ bool import_namespace_from_gi_repository(const char *, const char *); @@ -70,4 +73,12 @@ void log_pychrysalide_exception(const char *, ...); +/* -------------------- INTERVENTION DANS LA GESTION DE GREFFONS -------------------- */ + + +/* Complète les chemins de recherches de Python. */ +void extend_python_path(const GPluginModule *, const char *); + + + #endif /* _PLUGINS_PYCHRYSALIDE_BINDINGS_H */ diff --git a/plugins/pychrysalide/core-ui.c b/plugins/pychrysalide/core-ui.c index 1fb7931..ebc32cb 100644 --- a/plugins/pychrysalide/core-ui.c +++ b/plugins/pychrysalide/core-ui.c @@ -28,6 +28,7 @@ #include +#include #include @@ -49,14 +50,17 @@ static bool _standalone = true; /* Initialise la classe des greffons de support Python. */ static void g_pychrysalide_plugin_ui_class_init(GPyChrysalidePluginUIClass *); +/* Procède à l'initialisation de l'interface de gestion. */ +static void g_pychrysalide_plugin_ui_plugin_manager_interface_init(GPluginManagerInterface *); + /* Initialise une instance de greffon de support Python. */ static void g_pychrysalide_plugin_ui_init(GPyChrysalidePluginUI *); /* Supprime toutes les références externes. */ -static void g_pychrysalide_plugin_ui_dispose(GPyChrysalidePluginUI *); +static void g_pychrysalide_plugin_ui_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ -static void g_pychrysalide_plugin_ui_finalize(GPyChrysalidePluginUI *); +static void g_pychrysalide_plugin_ui_finalize(GObject *); @@ -64,7 +68,15 @@ static void g_pychrysalide_plugin_ui_finalize(GPyChrysalidePluginUI *); /* Prend acte de l'activation du greffon. */ -static bool g_pychrysalide_plugin_ui_enable(GPyChrysalidePluginUI *); +static bool g_pychrysalide_plugin_ui_enable(GPluginModule *); + + + +/* -------------------- INTERVENTION DANS LA GESTION DE GREFFONS -------------------- */ + + +/* Prend acte du chargement de l'ensemble des greffons natifs. */ +static void g_pychrysalide_plugin_ui_handle_native_plugins_loaded_event(GPluginManager *); @@ -82,7 +94,8 @@ static bool populate_python_modules_ui(void); /* Indique le type défini pour un greffon de liaison Python */ -G_DEFINE_TYPE(GPyChrysalidePluginUI, g_pychrysalide_plugin_ui, G_TYPE_PYCHRYSALIDE_PLUGIN); +G_DEFINE_TYPE_WITH_CODE(GPyChrysalidePluginUI, g_pychrysalide_plugin_ui, G_TYPE_PYCHRYSALIDE_PLUGIN, + G_IMPLEMENT_INTERFACE(G_TYPE_PLUGIN_MANAGER, g_pychrysalide_plugin_ui_plugin_manager_interface_init)); NATIVE_PLUGIN_ENTRYPOINT(g_pychrysalide_plugin_ui_new); @@ -107,12 +120,31 @@ static void g_pychrysalide_plugin_ui_class_init(GPyChrysalidePluginUIClass *clas object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)g_pychrysalide_plugin_ui_dispose; - object->finalize = (GObjectFinalizeFunc)g_pychrysalide_plugin_ui_finalize; + object->dispose = g_pychrysalide_plugin_ui_dispose; + object->finalize = g_pychrysalide_plugin_ui_finalize; plugin = G_PLUGIN_MODULE_CLASS(class); - plugin->enable = (pg_management_fc)g_pychrysalide_plugin_ui_enable; + plugin->enable = g_pychrysalide_plugin_ui_enable; + +} + + +/****************************************************************************** +* * +* Paramètres : iface = interface GLib à initialiser. * +* * +* Description : Procède à l'initialisation de l'interface de gestion. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_pychrysalide_plugin_ui_plugin_manager_interface_init(GPluginManagerInterface *iface) +{ + iface->handle_native = g_pychrysalide_plugin_ui_handle_native_plugins_loaded_event; } @@ -137,7 +169,7 @@ static void g_pychrysalide_plugin_ui_init(GPyChrysalidePluginUI *plugin) /****************************************************************************** * * -* Paramètres : plugin = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * * * @@ -147,16 +179,16 @@ static void g_pychrysalide_plugin_ui_init(GPyChrysalidePluginUI *plugin) * * ******************************************************************************/ -static void g_pychrysalide_plugin_ui_dispose(GPyChrysalidePluginUI *plugin) +static void g_pychrysalide_plugin_ui_dispose(GObject *object) { - G_OBJECT_CLASS(g_pychrysalide_plugin_ui_parent_class)->dispose(G_OBJECT(plugin)); + G_OBJECT_CLASS(g_pychrysalide_plugin_ui_parent_class)->dispose(object); } /****************************************************************************** * * -* Paramètres : plugin = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Procède à la libération totale de la mémoire. * * * @@ -166,9 +198,9 @@ static void g_pychrysalide_plugin_ui_dispose(GPyChrysalidePluginUI *plugin) * * ******************************************************************************/ -static void g_pychrysalide_plugin_ui_finalize(GPyChrysalidePluginUI *plugin) +static void g_pychrysalide_plugin_ui_finalize(GObject *object) { - G_OBJECT_CLASS(g_pychrysalide_plugin_ui_parent_class)->finalize(G_OBJECT(plugin)); + G_OBJECT_CLASS(g_pychrysalide_plugin_ui_parent_class)->finalize(object); } @@ -241,22 +273,24 @@ bool g_pychrysalide_plugin_ui_create(GPyChrysalidePluginUI *plugin, GModule *mod * * ******************************************************************************/ -static bool g_pychrysalide_plugin_ui_enable(GPyChrysalidePluginUI *plugin) +static bool g_pychrysalide_plugin_ui_enable(GPluginModule *plugin) { bool result; /* Bilan à retourner */ + GPyChrysalidePlugin *pychr_plugin; /* Version spécialisée */ PyGILState_STATE gstate; /* Sauvegarde d'environnement */ int ret; /* Bilan de préparatifs */ _standalone = false; + pychr_plugin = G_PYCHRYSALIDE_PLUGIN(plugin); + /* Chargement du module pour Python */ ret = PyImport_AppendInittab("pychrysalide", &PyInit_pychrysalideui); if (ret == -1) { - g_plugin_module_log_simple_message(G_PLUGIN_MODULE(plugin), - LMT_ERROR, + g_plugin_module_log_simple_message(plugin, LMT_ERROR, _("Can not extend the existing table of Python built-in modules.")); result = false; @@ -268,7 +302,7 @@ static bool g_pychrysalide_plugin_ui_enable(GPyChrysalidePluginUI *plugin) gstate = PyGILState_Ensure(); - G_PYCHRYSALIDE_PLUGIN(plugin)->py_module = PyImport_ImportModule("pychrysalide"); + pychr_plugin->py_module = PyImport_ImportModule("pychrysalide"); /** * Pour mémoire, une situation concrête conduisant à un échec : @@ -283,7 +317,7 @@ static bool g_pychrysalide_plugin_ui_enable(GPyChrysalidePluginUI *plugin) // TODO : check (2025) - result = (G_PYCHRYSALIDE_PLUGIN(plugin)->py_module != NULL); + result = (pychr_plugin->py_module != NULL); PyGILState_Release(gstate); @@ -296,6 +330,71 @@ static bool g_pychrysalide_plugin_ui_enable(GPyChrysalidePluginUI *plugin) /* ---------------------------------------------------------------------------------- */ +/* INTERVENTION DANS LA GESTION DE GREFFONS */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : manager = interface à manipuler. * +* * +* Description : Accompagne la fin du chargement des modules natifs. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_pychrysalide_plugin_ui_handle_native_plugins_loaded_event(GPluginManager *manager) +{ + GPluginModule *plugin; /* Version de base du greffon */ +#ifdef DISCARD_LOCAL + char *edir; /* Répertoire de base effectif */ + DIR *dir; /* Répertoire à parcourir */ +#endif + GPluginManagerInterface *iface; /* Interface utilisée */ + GPluginManagerInterface *parent_iface; /* Interface parente */ + + plugin = G_PLUGIN_MODULE(manager); + + /* Définition des zones d'influence */ + +#ifndef DISCARD_LOCAL + + extend_python_path(plugin, PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "plugins" G_DIR_SEPARATOR_S "pythonui"); + +#else + + edir = get_effective_directory(PLUGINS_DATA_DIR G_DIR_SEPARATOR_S "pythonui"); + + dir = opendir(edir); + + if (dir != NULL) + { + closedir(dir); + + extend_python_path(plugin, edir); + + } + + free(edir); + +#endif + + /* Chargements des extensions Python */ + + iface = G_PLUGIN_MANAGER_GET_IFACE(manager); + + parent_iface = g_type_interface_peek_parent(iface); + + parent_iface->handle_native(manager); + +} + + + +/* ---------------------------------------------------------------------------------- */ /* POINT D'ENTREE POUR PYTHON */ /* ---------------------------------------------------------------------------------- */ diff --git a/plugins/pychrysalide/core.c b/plugins/pychrysalide/core.c index 51a06a1..fd4a11f 100644 --- a/plugins/pychrysalide/core.c +++ b/plugins/pychrysalide/core.c @@ -24,24 +24,14 @@ #include "core.h" -#include "core-int.h" - - - - - #undef NO_IMPORT_PYGOBJECT #include #define NO_IMPORT_PYGOBJECT -#include "core.h" - - #include #include #include -//#include #include #include #include @@ -60,10 +50,9 @@ #include - - #include "access.h" #include "bindings.h" +#include "core-int.h" @@ -72,14 +61,6 @@ static bool _standalone = true; - - - - - - - - /* ---------------------- COMPOSITION DE NOUVEAU GREFFON NATIF ---------------------- */ @@ -93,10 +74,10 @@ static void g_pychrysalide_plugin_plugin_manager_interface_init(GPluginManagerIn static void g_pychrysalide_plugin_init(GPyChrysalidePlugin *); /* Supprime toutes les références externes. */ -static void g_pychrysalide_plugin_dispose(GPyChrysalidePlugin *); +static void g_pychrysalide_plugin_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ -static void g_pychrysalide_plugin_finalize(GPyChrysalidePlugin *); +static void g_pychrysalide_plugin_finalize(GObject *); @@ -104,19 +85,16 @@ static void g_pychrysalide_plugin_finalize(GPyChrysalidePlugin *); /* Prend acte de l'activation du greffon. */ -static bool g_pychrysalide_plugin_enable(GPyChrysalidePlugin *); +static bool g_pychrysalide_plugin_enable(GPluginModule *); /* Prend acte de la désactivation du greffon. */ -static bool g_pychrysalide_plugin_disable(GPyChrysalidePlugin *); +static bool g_pychrysalide_plugin_disable(GPluginModule *); /* -------------------- INTERVENTION DANS LA GESTION DE GREFFONS -------------------- */ -/* Complète les chemins de recherches de Python. */ -static void extend_python_path(const char *); - /* Crée un greffon à partir de code Python. */ static GPluginModule *create_python_plugin(const char *, const char *); @@ -124,7 +102,7 @@ static GPluginModule *create_python_plugin(const char *, const char *); static void load_python_plugins(GPluginModule *); /* Prend acte du chargement de l'ensemble des greffons natifs. */ -static void g_pychrysalide_plugin_handle_native_plugins_loaded_event(GPyChrysalidePlugin *); +static void g_pychrysalide_plugin_handle_native_plugins_loaded_event(GPluginManager *); @@ -160,13 +138,13 @@ static void g_pychrysalide_plugin_class_init(GPyChrysalidePluginClass *class) object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)g_pychrysalide_plugin_dispose; - object->finalize = (GObjectFinalizeFunc)g_pychrysalide_plugin_finalize; + object->dispose = g_pychrysalide_plugin_dispose; + object->finalize = g_pychrysalide_plugin_finalize; plugin = G_PLUGIN_MODULE_CLASS(class); - plugin->enable = (pg_management_fc)g_pychrysalide_plugin_enable; - plugin->disable = (pg_management_fc)g_pychrysalide_plugin_disable; + plugin->enable = g_pychrysalide_plugin_enable; + plugin->disable = g_pychrysalide_plugin_disable; } @@ -185,7 +163,7 @@ static void g_pychrysalide_plugin_class_init(GPyChrysalidePluginClass *class) static void g_pychrysalide_plugin_plugin_manager_interface_init(GPluginManagerInterface *iface) { - iface->handle_native = (handle_native_plugins_cb)g_pychrysalide_plugin_handle_native_plugins_loaded_event; + iface->handle_native = g_pychrysalide_plugin_handle_native_plugins_loaded_event; } @@ -213,7 +191,7 @@ static void g_pychrysalide_plugin_init(GPyChrysalidePlugin *plugin) /****************************************************************************** * * -* Paramètres : plugin = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * * * @@ -223,16 +201,16 @@ static void g_pychrysalide_plugin_init(GPyChrysalidePlugin *plugin) * * ******************************************************************************/ -static void g_pychrysalide_plugin_dispose(GPyChrysalidePlugin *plugin) +static void g_pychrysalide_plugin_dispose(GObject *object) { - G_OBJECT_CLASS(g_pychrysalide_plugin_parent_class)->dispose(G_OBJECT(plugin)); + G_OBJECT_CLASS(g_pychrysalide_plugin_parent_class)->dispose(object); } /****************************************************************************** * * -* Paramètres : plugin = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Procède à la libération totale de la mémoire. * * * @@ -242,9 +220,9 @@ static void g_pychrysalide_plugin_dispose(GPyChrysalidePlugin *plugin) * * ******************************************************************************/ -static void g_pychrysalide_plugin_finalize(GPyChrysalidePlugin *plugin) +static void g_pychrysalide_plugin_finalize(GObject *object) { - G_OBJECT_CLASS(g_pychrysalide_plugin_parent_class)->finalize(G_OBJECT(plugin)); + G_OBJECT_CLASS(g_pychrysalide_plugin_parent_class)->finalize(object); } @@ -323,22 +301,24 @@ bool g_pychrysalide_plugin_create(GPyChrysalidePlugin *plugin, GModule *module) * * ******************************************************************************/ -static bool g_pychrysalide_plugin_enable(GPyChrysalidePlugin *plugin) +static bool g_pychrysalide_plugin_enable(GPluginModule *plugin) { bool result; /* Bilan à retourner */ + GPyChrysalidePlugin *pychr_plugin; /* Version spécialisée */ PyGILState_STATE gstate; /* Sauvegarde d'environnement */ int ret; /* Bilan de préparatifs */ _standalone = false; + pychr_plugin = G_PYCHRYSALIDE_PLUGIN(plugin); + /* Chargement du module pour Python */ ret = PyImport_AppendInittab("pychrysalide", &PyInit_pychrysalide); if (ret == -1) { - g_plugin_module_log_simple_message(G_PLUGIN_MODULE(plugin), - LMT_ERROR, + g_plugin_module_log_simple_message(plugin, LMT_ERROR, _("Can not extend the existing table of Python built-in modules.")); result = false; @@ -350,7 +330,7 @@ static bool g_pychrysalide_plugin_enable(GPyChrysalidePlugin *plugin) gstate = PyGILState_Ensure(); - plugin->py_module = PyImport_ImportModule("pychrysalide"); + pychr_plugin->py_module = PyImport_ImportModule("pychrysalide"); /** * Pour mémoire, une situation concrête conduisant à un échec : @@ -365,7 +345,7 @@ static bool g_pychrysalide_plugin_enable(GPyChrysalidePlugin *plugin) // TODO : check (2025) - result = (plugin->py_module != NULL); + result = (pychr_plugin->py_module != NULL); PyGILState_Release(gstate); @@ -388,14 +368,17 @@ static bool g_pychrysalide_plugin_enable(GPyChrysalidePlugin *plugin) * * ******************************************************************************/ -static bool g_pychrysalide_plugin_disable(GPyChrysalidePlugin *plugin) +static bool g_pychrysalide_plugin_disable(GPluginModule *plugin) { bool result; /* Bilan à retourner */ + GPyChrysalidePlugin *pychr_plugin; /* Version spécialisée */ bool standalone; /* Nature du chargement */ PyGILState_STATE gstate; /* Sauvegarde d'environnement */ result = true; + pychr_plugin = G_PYCHRYSALIDE_PLUGIN(plugin); + /** * Le champ plugin->py_module n'est défini que via la fonction * g_pychrysalide_plugin_enable(), qui n'est pas sollicitée lorsque @@ -407,7 +390,7 @@ static bool g_pychrysalide_plugin_disable(GPyChrysalidePlugin *plugin) * initial ici. */ - standalone = (plugin->py_module == NULL); + standalone = (pychr_plugin->py_module == NULL); /** * Si on se trouve embarqué dans un interpréteur Python, le déchargement @@ -430,8 +413,8 @@ static bool g_pychrysalide_plugin_disable(GPyChrysalidePlugin *plugin) clear_all_accesses_to_python_modules(); - Py_XDECREF(plugin->py_module); - plugin->py_module = NULL; + Py_XDECREF(pychr_plugin->py_module); + pychr_plugin->py_module = NULL; if (!standalone) PyGILState_Release(gstate); @@ -449,38 +432,6 @@ static bool g_pychrysalide_plugin_disable(GPyChrysalidePlugin *plugin) /****************************************************************************** * * -* Paramètres : path = chemin supplémentaire pour l'espace de recherche. * -* * -* Description : Complète les chemins de recherches de Python. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void extend_python_path(const char *path) -{ - PyObject *list; /* Liste de chemins à compléter*/ - PyObject *new; /* Nouveau chemin à intégrer */ - - 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, ":"); - -} - - -/****************************************************************************** -* * * Paramètres : modname = nom du module à charger. * * filename = chemin d'accès au code Python à charger. * * * @@ -568,48 +519,18 @@ static GPluginModule *create_python_plugin(const char *modname, const char *file static void load_python_plugins(GPluginModule *plugin) { -#ifdef DISCARD_LOCAL - char *edir; /* Répertoire de base effectif */ -#endif - DIR *dir; /* Répertoire à parcourir */ + PyGILState_STATE gstate; /* Sauvegarde d'environnement */ char *paths; /* Emplacements de greffons */ char *save; /* Sauvegarde pour ré-entrance */ char *path; /* Chemin à fouiller */ + DIR *dir; /* Répertoire à parcourir */ struct dirent *entry; /* Elément trouvé */ char *modname; /* Nom du module pour Python */ char *filename; /* Chemin d'accès reconstruit */ GPluginModule *pyplugin; /* Lien vers un grffon Python */ bool status; /* Bilan d'une opération */ - /* Définition des zones d'influence */ - -#ifndef DISCARD_LOCAL - - extend_python_path(PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "plugins" G_DIR_SEPARATOR_S "python"); - -#else - - edir = get_effective_directory(PLUGINS_DATA_DIR G_DIR_SEPARATOR_S "python"); - - dir = opendir(edir); - - if (dir != NULL) - { - closedir(dir); - - extend_python_path(edir); - - } - - free(edir); - -#endif - - g_plugin_module_log_variadic_message(plugin, LMT_INFO, - _("PYTHONPATH environment variable set to '%s'"), - getenv("PYTHONPATH")); - - /* Chargements des extensions Python */ + gstate = PyGILState_Ensure(); paths = get_env_var("PYTHONPATH"); @@ -622,7 +543,7 @@ static void load_python_plugins(GPluginModule *plugin) dir = opendir(path); if (dir == NULL) { - perror("opendir"); + LOG_ERROR_N("opendir"); continue; } @@ -639,7 +560,7 @@ static void load_python_plugins(GPluginModule *plugin) if (entry == NULL) { if (errno != 0) - perror("readdir"); + LOG_ERROR_N("readdir"); break; @@ -703,12 +624,14 @@ static void load_python_plugins(GPluginModule *plugin) free(paths); + PyGILState_Release(gstate); + } /****************************************************************************** * * -* Paramètres : plugin = interface à manipuler. * +* Paramètres : manager = interface à manipuler. * * * * Description : Accompagne la fin du chargement des modules natifs. * * * @@ -718,15 +641,43 @@ static void load_python_plugins(GPluginModule *plugin) * * ******************************************************************************/ -static void g_pychrysalide_plugin_handle_native_plugins_loaded_event(GPyChrysalidePlugin *plugin) +static void g_pychrysalide_plugin_handle_native_plugins_loaded_event(GPluginManager *manager) { - PyGILState_STATE gstate; /* Sauvegarde d'environnement */ + GPluginModule *plugin; /* Version de base du greffon */ +#ifdef DISCARD_LOCAL + char *edir; /* Répertoire de base effectif */ + DIR *dir; /* Répertoire à parcourir */ +#endif - gstate = PyGILState_Ensure(); + plugin = G_PLUGIN_MODULE(manager); - load_python_plugins(G_PLUGIN_MODULE(plugin)); + /* Définition des zones d'influence */ - PyGILState_Release(gstate); +#ifndef DISCARD_LOCAL + + extend_python_path(plugin, PACKAGE_SOURCE_DIR G_DIR_SEPARATOR_S "plugins" G_DIR_SEPARATOR_S "python"); + +#else + + edir = get_effective_directory(PLUGINS_DATA_DIR G_DIR_SEPARATOR_S "python"); + + dir = opendir(edir); + + if (dir != NULL) + { + closedir(dir); + + extend_python_path(plugin, edir); + + } + + free(edir); + +#endif + + /* Chargements des extensions Python */ + + load_python_plugins(plugin); } -- cgit v0.11.2-87-g4458