diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-12-05 00:39:57 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-12-05 00:39:57 (GMT) |
commit | 1e3fa9b79ebe55698e2aa7d5484baec7e8400a8f (patch) | |
tree | c3581ceb7f8586f2f6822de563927a1246dd33a5 /plugins/pychrysalide/gui/core/items.c | |
parent | 6122bb7f34b178d4c07285adae16afcc55294b1f (diff) |
Rewritten the whole API dealing with panels.
Diffstat (limited to 'plugins/pychrysalide/gui/core/items.c')
-rw-r--r-- | plugins/pychrysalide/gui/core/items.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/plugins/pychrysalide/gui/core/items.c b/plugins/pychrysalide/gui/core/items.c index ce3eaee..95842fc 100644 --- a/plugins/pychrysalide/gui/core/items.c +++ b/plugins/pychrysalide/gui/core/items.c @@ -66,29 +66,36 @@ static PyObject *py_items_update_project(PyObject *, PyObject *); * * ******************************************************************************/ -static PyObject *py_items_find_editor_item_by_key(PyObject *self, PyObject *args) +static PyObject *py_items_find_editor_item_by_type(PyObject *self, PyObject *args) { PyObject *result; /* Trouvaille à retourner */ - const char *key; /* Objet des recherches */ + GType type; /* Type d'élément à traiter */ int ret; /* Bilan de lecture des args. */ GEditorItem *found; /* Instance retrouvée ou NULL */ -#define ITEMS_FIND_EDITOR_ITEM_BY_KEY_METHOD PYTHON_METHOD_DEF \ -( \ - find_editor_item_by_key, "key", \ - METH_VARARGS, py_items, \ - "Find the editor component belonging to a given key." \ - "\n" \ - "The key has to be provided as a simple (short) string, and the" \ - " result is a pychrysalide.gui.EditorItem instance or None if no" \ - " component is found for the given key." \ +#define ITEMS_FIND_EDITOR_ITEM_BY_TYPE_METHOD PYTHON_METHOD_DEF \ +( \ + find_editor_item_by_type, "cls", \ + METH_VARARGS, py_items, \ + "Find the editor component belonging to a given class." \ + "\n" \ + "The provided *cls* has to be an pychrysalide.gui.EditorItem" \ + " derived class." \ + "\n" \ + "The result is an pychrysalide.gui.EditorItem instance or None" \ + " if no component is found for the given key." \ ) - ret = PyArg_ParseTuple(args, "s", &key); + ret = PyArg_ParseTuple(args, "O&", convert_to_gtype, &type); if (!ret) return NULL; + if (!g_type_is_a(type, G_TYPE_EDITOR_ITEM)) + { + PyErr_SetString(PyExc_TypeError, "the argument must be a class derived from pychrysalide.gui.EditorItem"); + return NULL; + } - found = find_editor_item_by_key(key); + found = find_editor_item_by_type(type); if (found == NULL) { @@ -276,7 +283,7 @@ bool populate_gui_core_module_with_items(void) PyObject *module; /* Module à recompléter */ static PyMethodDef py_items_methods[] = { - ITEMS_FIND_EDITOR_ITEM_BY_KEY_METHOD, + ITEMS_FIND_EDITOR_ITEM_BY_TYPE_METHOD, ITEMS_CHANGE_CURRENT_CONTENT_METHOD, ITEMS_CHANGE_CURRENT_VIEW_METHOD, ITEMS_UPDATE_CURRENT_VIEW_METHOD, |