summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/pychrysa.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/pychrysa.c')
-rw-r--r--plugins/pychrysa/pychrysa.c78
1 files changed, 74 insertions, 4 deletions
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index eafb358..c77553b 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -228,6 +228,7 @@ bool init_plugin(GPluginModule *plugin, GObject *ref)
#include <config.h>
+#include <common/cpp.h>
#include <common/environment.h>
#include <common/extstr.h>
#include <plugins/plugin-def.h>
@@ -245,12 +246,18 @@ bool init_plugin(GPluginModule *plugin, GObject *ref)
DEFINE_CHRYSALIDE_ACTIVE_PLUGIN("PyChrysalide", "Provides bindings to Python", "0.1.0", PGA_PLUGIN_INIT);
+/* Fournit la révision du programme global. */
+static PyObject *py_chrysalide_revision(PyObject *, PyObject *);
+
/* Fournit la version du programme global. */
static PyObject *py_chrysalide_version(PyObject *, PyObject *);
/* Fournit la version du greffon pour Python. */
static PyObject *py_chrysalide_mod_version(PyObject *, PyObject *);
+/* Recherche et fournit si elle existe une valeur globale. */
+static PyObject *py_chrysalide_get_global_gobject(PyObject *, PyObject *);
+
/* Détermine si l'interpréteur lancé est celui pris en compte. */
static bool is_current_abi_suitable(void);
@@ -264,7 +271,7 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *);
* Paramètres : self = NULL car méthode statique. *
* args = non utilisé ici. *
* *
-* Description : Fournit la version du programme global. *
+* Description : Fournit la révision du programme global. *
* *
* Retour : Numéro de révision. *
* *
@@ -272,6 +279,26 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *);
* *
******************************************************************************/
+static PyObject *py_chrysalide_revision(PyObject *self, PyObject *args)
+{
+ return PyUnicode_FromString("r" XSTR(REVISION));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = NULL car méthode statique. *
+* args = non utilisé ici. *
+* *
+* Description : Fournit la version du programme global. *
+* *
+* Retour : Numéro de version. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
static PyObject *py_chrysalide_version(PyObject *self, PyObject *args)
{
char version[16];
@@ -297,7 +324,7 @@ static PyObject *py_chrysalide_version(PyObject *self, PyObject *args)
* *
* Description : Fournit la version du greffon pour Python. *
* *
-* Retour : Numéro de révision. *
+* Retour : Numéro de version. *
* *
* Remarques : - *
* *
@@ -316,6 +343,41 @@ static PyObject *py_chrysalide_mod_version(PyObject *self, PyObject *args)
/******************************************************************************
* *
+* Paramètres : self = NULL car méthode statique. *
+* args = contient la clef d'accès à un champ particulier. *
+* *
+* Description : Recherche et fournit si elle existe une valeur globale. *
+* *
+* Retour : Object attaché à l'espace de référencement global ou NULL. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_chrysalide_get_global_gobject(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Instance à retourner */
+ const char *key; /* Désignation du champ visé */
+ int ret; /* Bilan de lecture des args. */
+ void *data; /* Donnée quelconque */
+
+ ret = PyArg_ParseTuple(args, "s", &key);
+ if (!ret) Py_RETURN_NONE;
+
+ data = g_object_get_data(get_internal_ref(), key);
+ if (data == NULL) Py_RETURN_NONE;
+
+ if (!G_IS_OBJECT(data)) Py_RETURN_NONE;
+
+ result = pygobject_new(G_OBJECT(data));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Détermine si l'interpréteur lancé est celui pris en compte. *
@@ -410,13 +472,21 @@ PyMODINIT_FUNC PyInit_pychrysalide(void)
static PyMethodDef py_chrysalide_methods[] = {
+ { "revision", py_chrysalide_revision,
+ METH_NOARGS,
+ "revision(/)\n--\n\nProvide the revision number of Chrysalide."
+ },
{ "version", py_chrysalide_version,
METH_NOARGS,
- "version(/)\n--\n\nProvide the revision number of Chrysalide."
+ "version(/)\n--\n\nProvide the version number of Chrysalide."
},
{ "mod_version", py_chrysalide_mod_version,
METH_NOARGS,
- "mod_version(/)\n--\n\nProvide the revision number of Chrysalide module for Python."
+ "mod_version(/)\n--\n\nProvide the version number of Chrysalide module for Python."
+ },
+ { "get_global_gobject", py_chrysalide_get_global_gobject,
+ METH_VARARGS,
+ "get_global_gobject(key, /)\n--\n\nRetrieve if it exists a global GObject registered with the given key."
},
{ NULL }