summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/glibext/loadedpanel.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/glibext/loadedpanel.c')
-rw-r--r--plugins/pychrysalide/glibext/loadedpanel.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/pychrysalide/glibext/loadedpanel.c b/plugins/pychrysalide/glibext/loadedpanel.c
index d9364c5..a3f6dc8 100644
--- a/plugins/pychrysalide/glibext/loadedpanel.c
+++ b/plugins/pychrysalide/glibext/loadedpanel.c
@@ -25,6 +25,7 @@
#include "loadedpanel.h"
+#include <assert.h>
#include <pygobject.h>
@@ -198,3 +199,48 @@ bool ensure_python_loaded_panel_is_registered(void)
return true;
}
+
+
+/******************************************************************************
+* *
+* 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 panneau de contenu chargé. *
+* *
+* Retour : Bilan de l'opération, voire indications supplémentaires. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+int convert_to_loaded_panel(PyObject *arg, void *dst)
+{
+ int result; /* Bilan à retourner */
+
+ result = PyObject_IsInstance(arg, (PyObject *)get_python_loaded_panel_type());
+
+ switch (result)
+ {
+ case -1:
+ /* L'exception est déjà fixée par Python */
+ result = 0;
+ break;
+
+ case 0:
+ PyErr_SetString(PyExc_TypeError, "unable to convert the provided argument to loaded panel");
+ break;
+
+ case 1:
+ *((GLoadedPanel **)dst) = G_LOADED_PANEL(pygobject_get(arg));
+ break;
+
+ default:
+ assert(false);
+ break;
+
+ }
+
+ return result;
+
+}