summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/helpers.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2020-12-24 16:26:51 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2020-12-24 16:26:51 (GMT)
commit93dfdc30d815629a7e0c9393f0e8f0462844ff56 (patch)
tree8fe59f8c0186871ffd79873ec20905bf39170528 /plugins/pychrysalide/helpers.c
parentc388ad8910dbb1a3c478176d8b1ab3142fdbd9d5 (diff)
Ported the panel update mechanisms to the Python API.
Diffstat (limited to 'plugins/pychrysalide/helpers.c')
-rw-r--r--plugins/pychrysalide/helpers.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/pychrysalide/helpers.c b/plugins/pychrysalide/helpers.c
index f811ad3..b2ecbec 100644
--- a/plugins/pychrysalide/helpers.c
+++ b/plugins/pychrysalide/helpers.c
@@ -977,6 +977,11 @@ bool register_class_for_dynamic_pygobject(GType gtype, PyTypeObject *type, PyTyp
PyObject *modname; /* Nom du module du type */
PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire dudit module */
+ Py_ssize_t i; /* Boucle de parcours */
+ PyObject *mro_base; /* Base finale effective */
+ GType itype; /* Type d'interface implémentée*/
+ GQuark pyginterface_info_key; /* Clef d'accès non déclarée */
+ const GInterfaceInfo *iinfo; /* Informations associées */
/**
* Lors de l'appel à pygobject_register_class(), PyGObject remplace systématiquement
@@ -1023,6 +1028,47 @@ bool register_class_for_dynamic_pygobject(GType gtype, PyTypeObject *type, PyTyp
Py_TYPE(type) = legacy_parent;
+ /**
+ * Comme la mise en place dynamique de nouveau GType court-circuite les
+ * mécanismes internes de pygobject, les interfaces implémentées ne sont
+ * nominalement plus complétées.
+ *
+ * On reprend donc la logique copiée depuis le contenu de la fonction
+ * pyg_type_add_interfaces() du fichier "pygobject-3.22.0/gi/gobjectmodule.c".
+ */
+
+ for (i = 0; i < PyTuple_GET_SIZE(type->tp_mro); i++)
+ {
+ mro_base = PyTuple_GET_ITEM(type->tp_mro, i);
+
+ if (!PyType_Check(mro_base))
+ continue;
+
+ itype = pyg_type_from_object(mro_base);
+
+ if (itype == G_TYPE_INTERFACE)
+ continue;
+
+ if (!G_TYPE_IS_INTERFACE(itype))
+ continue;
+
+ if (!g_type_is_a(gtype, itype))
+ {
+ /**
+ * Reproduction de pyg_lookup_interface_info().
+ */
+
+ pyginterface_info_key = g_quark_from_static_string("PyGInterface::info");
+
+ iinfo = g_type_get_qdata(itype, pyginterface_info_key);
+ assert(iinfo != NULL);
+
+ g_type_add_interface_static(gtype, itype, iinfo);
+
+ }
+
+ }
+
return result;
}