summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-08-16 19:56:00 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-08-16 19:56:00 (GMT)
commit49af9c6449eb48d0ab1fb0893ad59b415f41d3cd (patch)
treebefea4317655a456c2a6c02a913143d101055cfd /plugins/pychrysalide/helpers.c
parent7b3b76a1e6faff521d582902e1230acbe1a906d3 (diff)
Created some extra features for the GTK API.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index e9f65a9..25ce772 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -1174,6 +1174,61 @@ int convert_to_gtk_widget(PyObject *arg, void *dst)
}
+/******************************************************************************
+* *
+* Paramètres : arg = argument quelconque à tenter de convertir. *
+* dst = destination des valeurs récupérées en cas de succès. *
+* *
+* Description : Tente de convertir en instance de conteneur GTK. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_gtk_container(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+ PyObject *gtk_mod; /* Module Python Gtk */
+ PyObject *container_type; /* Module "GtkContainer" */
+ int ret; /* Bilan d'une conversion */
+
+ result = 0;
+
+ gtk_mod = PyImport_ImportModule("gi.repository.Gtk");
+
+ if (gtk_mod == NULL)
+ {
+ PyErr_SetString(PyExc_TypeError, "unable to find the Gtk Python module");
+ goto done;
+ }
+
+ container_type = PyObject_GetAttrString(gtk_mod, "Container");
+
+ Py_DECREF(gtk_mod);
+
+ ret = PyObject_TypeCheck(arg, (PyTypeObject *)container_type);
+
+ Py_DECREF(container_type);
+
+ if (!ret)
+ {
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to GTK container");
+ goto done;
+ }
+
+ *((GtkContainer **)dst) = GTK_CONTAINER(pygobject_get(arg));
+
+ result = 1;
+
+ done:
+
+ return result;
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* TRANSFERT DES VALEURS CONSTANTES */