diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-09-12 21:44:24 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-09-12 21:44:38 (GMT) |
commit | 682159e73cfbf8ec61d2f2aba765be1016a30ded (patch) | |
tree | 9477af8765263667b20a48c53835aa9b3be73a2a /plugins/pychrysalide/analysis/db/collection.c | |
parent | 57f6179e22f880bbcff031714e8576cf9bd488ac (diff) |
Extended the Python API for update databases.
Diffstat (limited to 'plugins/pychrysalide/analysis/db/collection.c')
-rw-r--r-- | plugins/pychrysalide/analysis/db/collection.c | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/plugins/pychrysalide/analysis/db/collection.c b/plugins/pychrysalide/analysis/db/collection.c index b7e3e0b..e62c17e 100644 --- a/plugins/pychrysalide/analysis/db/collection.c +++ b/plugins/pychrysalide/analysis/db/collection.c @@ -37,6 +37,66 @@ +/* Renvoie la liste des éléments rassemblés. */ +static PyObject *py_db_collection_get_items(PyObject *, void *); + + + +/****************************************************************************** +* * +* Paramètres : self = objet Python concerné par l'appel. * +* closure = non utilisé ici. * +* * +* Description : Renvoie la liste des éléments rassemblés. * +* * +* Retour : Liste d'éléments à parcourir. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_db_collection_get_items(PyObject *self, void *closure) +{ + PyObject *result; /* Trouvailles à retourner */ + GDbCollection *collec; /* Version native */ + size_t counter; /* Décompte des éléments */ + GList *items; /* Eléments déjà en place */ + GList *iter; /* Boucle de parcours */ + int ret; /* Bilan d'une extension */ + +#define DB_COLLECTION_ITEMS_ATTRIB PYTHON_GET_DEF_FULL \ +( \ + items, py_db_collection, \ + "List of all items contained in the collection." \ + "\n" \ + "These items can currently be applied or not." \ +) + + collec = G_DB_COLLECTION(pygobject_get(self)); + + counter = 0; + result = PyTuple_New(counter); + + g_db_collection_rlock(collec); + + items = g_db_collection_get_items(G_DB_COLLECTION(collec)); + + for (iter = g_list_first(items); iter != NULL; iter = g_list_next(iter)) + { + ret = _PyTuple_Resize(&result, ++counter); + if (ret == -1) break; + + PyTuple_SetItem(result, counter - 1, pygobject_new(G_OBJECT(iter->data))); + + } + + g_db_collection_runlock(collec); + + return result; + +} + + /****************************************************************************** * * * Paramètres : - * @@ -56,9 +116,8 @@ PyTypeObject *get_python_db_collection_type(void) }; static PyGetSetDef py_db_collection_getseters[] = { - + DB_COLLECTION_ITEMS_ATTRIB, { NULL } - }; static PyTypeObject py_db_collection_type = { |