diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2015-07-17 16:36:21 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2015-07-17 16:36:21 (GMT) |
commit | 24d3836fcf8d443eb654b981f65478cd9923b8f1 (patch) | |
tree | 7672a28b864127e8958c3c6cce751dcf646d2fbe /plugins/pychrysa/gui/panels/panel.c | |
parent | a61f089babe336b012da31a494b0f7470b6e1a9a (diff) |
Updated the Python bindings.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@552 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'plugins/pychrysa/gui/panels/panel.c')
-rw-r--r-- | plugins/pychrysa/gui/panels/panel.c | 85 |
1 files changed, 52 insertions, 33 deletions
diff --git a/plugins/pychrysa/gui/panels/panel.c b/plugins/pychrysa/gui/panels/panel.c index 826982f..e713cc0 100644 --- a/plugins/pychrysa/gui/panels/panel.c +++ b/plugins/pychrysa/gui/panels/panel.c @@ -28,18 +28,24 @@ #include <pygobject.h> -#include "../../quirks.h" +#include <gui/panels/panel.h> + + +#include "../editem.h" /* Crée un nouvel objet Python de type 'PanelItem'. */ +#if 0 static PyObject *py_panel_item_new(PyTypeObject *, PyObject *, PyObject *); +#endif /* Place un panneau dans l'ensemble affiché. */ static PyObject *py_panel_item_dock(PyObject *, PyObject *); +#if 0 /****************************************************************************** * * * Paramètres : type = type de l'objet à instancier. * @@ -110,6 +116,7 @@ PyObject *_py_panel_item_from_c(GPanelItem *item, PyTypeObject *type) return pygobject_new(G_OBJECT(item)); } +#endif /****************************************************************************** @@ -138,40 +145,25 @@ static PyObject *py_panel_item_dock(PyObject *self, PyObject *args) } - - - - - - - - - - - - /****************************************************************************** * * -* Paramètres : module = module dont la définition est à compléter. * +* Paramètres : - * * * -* Description : Prend en charge l'objet 'pychrysalide.gui.panels.PanelItem'. * +* Description : Fournit un accès à une définition de type à diffuser. * * * -* Retour : Bilan de l'opération. * +* Retour : Définition d'objet pour Python. * * * * Remarques : - * * * ******************************************************************************/ -bool register_python_panel_item(PyObject *module) +PyTypeObject *get_python_panel_item_type(void) { - PyObject *parent_mod; /* Module Python-EditorItem */ - int ret; /* Bilan d'un appel */ - static PyMethodDef py_panel_item_methods[] = { { "dock", (PyCFunction)py_panel_item_dock, METH_NOARGS, - "Display the panel item in the right place." + "dock($self, /)\n--\n\nDisplay the panel item in the right place." }, { NULL } }; @@ -182,34 +174,61 @@ bool register_python_panel_item(PyObject *module) static PyTypeObject py_panel_item_type = { - PyObject_HEAD_INIT(NULL) + PyVarObject_HEAD_INIT(NULL, 0) .tp_name = "pychrysalide.gui.panels.PanelItem", .tp_basicsize = sizeof(PyGObject), .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_doc = "PyChrysalide panel item", + .tp_doc = "PyChrysalide panel item.", .tp_methods = py_panel_item_methods, .tp_getset = py_panel_item_getseters, - .tp_new = (newfunc)py_panel_item_new, - .tp_init = (initproc)pychrysalide_allow_args_for_gobjects + //.tp_new = (newfunc)py_panel_item_new, + //.tp_init = (initproc)pychrysalide_allow_args_for_gobjects }; - parent_mod = PyImport_ImportModule("pychrysalide.gui"); - if (parent_mod == NULL) return false; + return &py_panel_item_type; - py_panel_item_type.tp_base = (PyTypeObject *)PyObject_GetAttrString(parent_mod, "EditorItem"); - Py_DECREF(parent_mod); +} - if (PyType_Ready(&py_panel_item_type) < 0) + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.gui.panels.PanelItem'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_panel_item(PyObject *module) +{ + PyTypeObject *py_panel_item_type; /* Type Python 'LoadedBinary' */ + int ret; /* Bilan d'un appel */ + PyObject *dict; /* Dictionnaire du module */ + + py_panel_item_type = get_python_panel_item_type(); + + py_panel_item_type->tp_base = get_python_editor_item_type(); + py_panel_item_type->tp_basicsize = py_panel_item_type->tp_base->tp_basicsize; + + if (PyType_Ready(py_panel_item_type) != 0) return false; - Py_INCREF(&py_panel_item_type); - ret = PyModule_AddObject(module, "PanelItem", (PyObject *)&py_panel_item_type); + Py_INCREF(py_panel_item_type); + ret = PyModule_AddObject(module, "PanelItem", (PyObject *)py_panel_item_type); + if (ret != 0) return false; + + dict = PyModule_GetDict(module); + pygobject_register_class(dict, "PanelItem", G_TYPE_PANEL_ITEM, py_panel_item_type, + Py_BuildValue("(O)", py_panel_item_type->tp_base)); - return (ret == 0); + return true; } |