diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-12-05 00:39:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-12-05 00:39:57 (GMT) |
commit | 1e3fa9b79ebe55698e2aa7d5484baec7e8400a8f (patch) | |
tree | c3581ceb7f8586f2f6822de563927a1246dd33a5 /plugins/pychrysalide/core.c | |
parent | 6122bb7f34b178d4c07285adae16afcc55294b1f (diff) |
Rewritten the whole API dealing with panels.
Diffstat (limited to 'plugins/pychrysalide/core.c')
-rw-r--r-- | plugins/pychrysalide/core.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/plugins/pychrysalide/core.c b/plugins/pychrysalide/core.c index fad21bf..1ba738d 100644 --- a/plugins/pychrysalide/core.c +++ b/plugins/pychrysalide/core.c @@ -69,7 +69,8 @@ DEFINE_CHRYSALIDE_CONTAINER_PLUGIN("PyChrysalide", "Chrysalide bindings to Python", PACKAGE_VERSION, CHRYSALIDE_WEBSITE("api/python/pychrysalide"), - NO_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT, PGA_NATIVE_LOADED)); + NO_REQ, AL(PGA_PLUGIN_INIT, PGA_PLUGIN_EXIT, + PGA_NATIVE_LOADED, PGA_TYPE_BUILDING)); /* Note la nature du chargement */ @@ -894,6 +895,54 @@ G_MODULE_EXPORT void chrysalide_plugin_on_native_loaded(GPluginModule *plugin, P /****************************************************************************** * * +* Paramètres : plugin = greffon à manipuler. * +* action = type d'action attendue. * +* type = type d'objet à mettre en place. * +* * +* Description : Crée une instance à partir d'un type dynamique externe. * +* * +* Retour : Instance d'objet gérée par l'extension ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +G_MODULE_EXPORT gpointer chrysalide_plugin_build_type_instance(GPluginModule *plugin, PluginAction action, GType type) +{ + gpointer result; /* Instance à retourner */ + PyThreadState *tstate; /* Contexte d'environnement */ + PyTypeObject *pytype; /* Classe Python concernée */ + PyObject *instance; /* Initialisation forcée */ + + result = NULL; + + if (!_standalone) + { + tstate = get_pychrysalide_main_tstate(); + PyEval_RestoreThread(tstate); + } + + pytype = pygobject_lookup_class(type); + + if (pytype != NULL) + { + instance = PyObject_CallObject((PyObject *)pytype, NULL); + assert(instance != NULL); + + result = pygobject_get(instance); + + } + + if (!_standalone) + PyEval_SaveThread(); + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : - * * * * Description : Fournit les informations du thread principal. * |