diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2018-01-16 19:02:56 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2018-01-16 19:02:56 (GMT) |
commit | 9da8f8b37e3edebc917b4e223dd2447cd7cbc818 (patch) | |
tree | 3f330b13e7ca2a0a163882be3043ca9571f25211 /plugins/pychrysalide/gtkext | |
parent | eb9b7fd76451db5c9f07a800c0394480e4b88c9c (diff) |
Changed the Python bindings source directory and updated code.
Diffstat (limited to 'plugins/pychrysalide/gtkext')
-rw-r--r-- | plugins/pychrysalide/gtkext/Makefile.am | 18 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/blockdisplay.c | 115 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/blockdisplay.h | 42 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/bufferdisplay.c | 115 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/bufferdisplay.h | 42 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/displaypanel.c | 269 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/displaypanel.h | 42 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/dockable.c | 102 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/dockable.h | 42 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/module.c | 95 | ||||
-rw-r--r-- | plugins/pychrysalide/gtkext/module.h | 39 |
11 files changed, 921 insertions, 0 deletions
diff --git a/plugins/pychrysalide/gtkext/Makefile.am b/plugins/pychrysalide/gtkext/Makefile.am new file mode 100644 index 0000000..4a36e63 --- /dev/null +++ b/plugins/pychrysalide/gtkext/Makefile.am @@ -0,0 +1,18 @@ + +noinst_LTLIBRARIES = libpychrysagtkext.la + +libpychrysagtkext_la_SOURCES = \ + blockdisplay.h blockdisplay.c \ + bufferdisplay.h bufferdisplay.c \ + displaypanel.h displaypanel.c \ + dockable.h dockable.c \ + module.h module.c + + +libpychrysagtkext_la_LDFLAGS = + + +AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) $(LIBPYTHON_CFLAGS) $(LIBPYGOBJECT_CFLAGS) \ + -I../../../src + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) diff --git a/plugins/pychrysalide/gtkext/blockdisplay.c b/plugins/pychrysalide/gtkext/blockdisplay.c new file mode 100644 index 0000000..c2ccfbb --- /dev/null +++ b/plugins/pychrysalide/gtkext/blockdisplay.c @@ -0,0 +1,115 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * blockdisplay.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkblockdisplay.c" + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "blockdisplay.h" + + +#include <string.h> +#include <pygobject.h> + + +#include <gtkext/gtkblockdisplay.h> + + +#include "bufferdisplay.h" +#include "../helpers.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_block_display_type(void) +{ + static PyMethodDef py_block_display_methods[] = { + { NULL } + }; + + static PyGetSetDef py_block_display_getseters[] = { + { NULL } + }; + + static PyTypeObject py_block_display_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.gtkext.BlockDisplay", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide block display.", + + .tp_methods = py_block_display_methods, + .tp_getset = py_block_display_getseters + + }; + + static PyTypeObject *result = NULL; + + if (result == NULL) + result = define_python_dynamic_type(&py_block_display_type); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.gtkext.BlockDisplay'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_block_display(PyObject *module) +{ + bool result; /* Bilan à retourner */ + PyTypeObject *py_block_display_type; /* Type Python 'BlockDisplay' */ + PyObject *dict; /* Dictionnaire du module */ + + py_block_display_type = get_python_block_display_type(); + + dict = PyModule_GetDict(module); + + result = register_class_for_pygobject(dict, GTK_TYPE_BLOCK_DISPLAY, + py_block_display_type, get_python_buffer_display_type()); + + return result; + +} diff --git a/plugins/pychrysalide/gtkext/blockdisplay.h b/plugins/pychrysalide/gtkext/blockdisplay.h new file mode 100644 index 0000000..ab15ac5 --- /dev/null +++ b/plugins/pychrysalide/gtkext/blockdisplay.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * blockdisplay.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkblockdisplay.h" + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_GTKEXT_BLOCKDISPLAY_H +#define _PLUGINS_PYCHRYSALIDE_GTKEXT_BLOCKDISPLAY_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_block_display_type(void); + +/* Prend en charge l'objet 'pychrysalide.gtkext.BlockDisplay'. */ +bool register_python_block_display(PyObject *module); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_GTKEXT_BLOCKDISPLAY_H */ diff --git a/plugins/pychrysalide/gtkext/bufferdisplay.c b/plugins/pychrysalide/gtkext/bufferdisplay.c new file mode 100644 index 0000000..9aa1bca --- /dev/null +++ b/plugins/pychrysalide/gtkext/bufferdisplay.c @@ -0,0 +1,115 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * bufferdisplay.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkbufferdisplay.c" + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "bufferdisplay.h" + + +#include <string.h> +#include <pygobject.h> + + +#include <gtkext/gtkbufferdisplay.h> + + +#include "displaypanel.h" +#include "../helpers.h" + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_buffer_display_type(void) +{ + static PyMethodDef py_buffer_display_methods[] = { + { NULL } + }; + + static PyGetSetDef py_buffer_display_getseters[] = { + { NULL } + }; + + static PyTypeObject py_buffer_display_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.gtkext.BufferDisplay", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide buffer display.", + + .tp_methods = py_buffer_display_methods, + .tp_getset = py_buffer_display_getseters + + }; + + static PyTypeObject *result = NULL; + + if (result == NULL) + result = define_python_dynamic_type(&py_buffer_display_type); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.gtkext.Bufferdisplay'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_buffer_display(PyObject *module) +{ + bool result; /* Bilan à retourner */ + PyTypeObject *py_buffer_display_type; /* Type Python 'BufferDisplay' */ + PyObject *dict; /* Dictionnaire du module */ + + py_buffer_display_type = get_python_buffer_display_type(); + + dict = PyModule_GetDict(module); + + result = register_class_for_pygobject(dict, GTK_TYPE_BUFFER_DISPLAY, + py_buffer_display_type, get_python_display_panel_type()); + + return result; + +} diff --git a/plugins/pychrysalide/gtkext/bufferdisplay.h b/plugins/pychrysalide/gtkext/bufferdisplay.h new file mode 100644 index 0000000..4a21fb9 --- /dev/null +++ b/plugins/pychrysalide/gtkext/bufferdisplay.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * bufferdisplay.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkbufferdisplay.h" + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_GTKEXT_BUFFERDISPLAY_H +#define _PLUGINS_PYCHRYSALIDE_GTKEXT_BUFFERDISPLAY_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_buffer_display_type(void); + +/* Prend en charge l'objet 'pychrysalide.gtkext.BufferDisplay'. */ +bool register_python_buffer_display(PyObject *module); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_GTKEXT_BUFFERDISPLAY_H */ diff --git a/plugins/pychrysalide/gtkext/displaypanel.c b/plugins/pychrysalide/gtkext/displaypanel.c new file mode 100644 index 0000000..b75d173 --- /dev/null +++ b/plugins/pychrysalide/gtkext/displaypanel.c @@ -0,0 +1,269 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * displaypanel.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkdisplaypanel.c" + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "displaypanel.h" + + +#include <string.h> +#include <pygobject.h> + + +#include <gtkext/gtkdisplaypanel.h> + + +#include "../helpers.h" +#include "../arch/vmpa.h" + + + +/* Crée un nouvel objet Python de type 'DisplayPanel'. */ +#if 0 +static PyObject *py_display_panel_new(PyTypeObject *, PyObject *, PyObject *); +#endif + +/* S'assure qu'une adresse donnée est visible à l'écran. */ +static PyObject *py_display_panel_scroll_to_address(PyObject *, PyObject *); + +/* Définit les constantes pour les panneaux de vue. */ +static bool py_display_panel_define_constants(PyTypeObject *); + + + +/****************************************************************************** +* * +* Paramètres : type = type de l'objet à instancier. * +* args = arguments fournis à l'appel. * +* kwds = arguments de type key=val fournis. * +* * +* Description : Crée un nouvel objet Python de type 'DisplayPanel'. * +* * +* Retour : Instance Python mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ +#if 0 +static PyObject *py_display_panel_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ +#if 0 + PyObject *result; /* Instance à retourner */ + const char *name; /* Désignation humaine */ + const char *lname; /* Nom version longue */ + PyGObject *widget; /* Composant visuel du panneau */ + const char *path; /* Placement à l'affichage */ + int ret; /* Bilan de lecture des args. */ + GEditorItem *item; /* Version GLib du format */ + + ret = PyArg_ParseTuple(args, "ssOs", &name, &lname, &widget, &path); + if (!ret) Py_RETURN_NONE; + + item = g_view_panel_new(name, lname, + GTK_WIDGET(pygobject_get(widget)), path); + + result = py_display_panel_from_c(G_DISPLAY_PANEL(item)); + g_object_unref(item); + + return (PyObject *)result; +#endif + + /* FIXME */ + + + Py_RETURN_NONE; + +} +#endif + + +/****************************************************************************** +* * +* Paramètres : self = classe représentant un tampon de code. * +* args = arguments fournis à l'appel. * +* * +* Description : S'assure qu'une adresse donnée est visible à l'écran. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static PyObject *py_display_panel_scroll_to_address(PyObject *self, PyObject *args) +{ + GtkDisplayPanel *panel; /* Panneau à manipuler */ + PyObject *py_vmpa; /* Localisation version Python */ + int ret; /* Bilan de lecture des args. */ + vmpa2t *addr; /* Adresse visée par l'opérat° */ + + ret = PyArg_ParseTuple(args, "O", &py_vmpa); + if (!ret) return NULL; + + ret = PyObject_IsInstance(py_vmpa, (PyObject *)get_python_vmpa_type()); + if (!ret) return NULL; + + addr = get_internal_vmpa(py_vmpa); + if (addr == NULL) return NULL; + + panel = GTK_DISPLAY_PANEL(pygobject_get(self)); + + // FIXME + //gtk_display_panel_scroll_to_address(panel, addr, SPT_RAW); + + Py_RETURN_NONE; + +} + + +/****************************************************************************** +* * +* Paramètres : obj_type = type dont le dictionnaire est à compléter. * +* * +* Description : Définit les constantes pour les panneaux de vue. * +* * +* Retour : true en cas de succès de l'opération, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool py_display_panel_define_constants(PyTypeObject *obj_type) +{ + bool result; /* Bilan à retourner */ + + result = true; + + result &= PyDict_AddIntMacro(obj_type, SPT_RAW); + result &= PyDict_AddIntMacro(obj_type, SPT_TOP); + result &= PyDict_AddIntMacro(obj_type, SPT_CENTER); + result &= PyDict_AddIntMacro(obj_type, SPT_BOTTOM); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_display_panel_type(void) +{ + static PyMethodDef py_display_panel_methods[] = { + { + "scroll_to_address", (PyCFunction)py_display_panel_scroll_to_address, + METH_VARARGS, + "scroll_to_address($self, addr, tweak, /)\n--\n\nEnsure a given address is displayed in the view panel." + }, + { NULL } + }; + + static PyGetSetDef py_display_panel_getseters[] = { + { NULL } + }; + + static PyTypeObject py_display_panel_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.gtkext.DisplayPanel", + .tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide view panel.", + + .tp_methods = py_display_panel_methods, + .tp_getset = py_display_panel_getseters, + //.tp_new = (newfunc)py_display_panel_new, + //.tp_init = (initproc)pychrysalide_allow_args_for_gobjects + + }; + + static PyTypeObject *result = NULL; + + if (result == NULL) + result = define_python_dynamic_type(&py_display_panel_type); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.gtkext.DisplayPanel'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_display_panel(PyObject *module) +{ + bool result; /* Bilan à retourner */ + PyTypeObject *py_display_panel_type; /* Type Python 'DisplayPanel' */ + PyObject *parent_mod; /* Module Python Fixed */ + PyObject *fixed; /* Module "GtkFixed" */ + PyObject *dict; /* Dictionnaire du module */ + + result = false; + + py_display_panel_type = get_python_display_panel_type(); + + parent_mod = PyImport_ImportModule("gi.repository.Gtk"); + + if (parent_mod == NULL) + goto rpdp_exit; + + fixed = PyObject_GetAttrString(parent_mod, "Fixed"); + + Py_DECREF(parent_mod); + + dict = PyModule_GetDict(module); + + result = register_class_for_pygobject(dict, GTK_TYPE_DISPLAY_PANEL, + py_display_panel_type, (PyTypeObject *)fixed); + Py_DECREF(fixed); + + if (!result) + goto rpdp_exit; + + result = py_display_panel_define_constants(py_display_panel_type); + + rpdp_exit: + + return result; + +} diff --git a/plugins/pychrysalide/gtkext/displaypanel.h b/plugins/pychrysalide/gtkext/displaypanel.h new file mode 100644 index 0000000..318a9f6 --- /dev/null +++ b/plugins/pychrysalide/gtkext/displaypanel.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * displaypanel.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkdisplaypanel.h" + * + * Copyright (C) 2016-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_GTKEXT_DISPLAYPANEL_H +#define _PLUGINS_PYCHRYSALIDE_GTKEXT_DISPLAYPANEL_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_display_panel_type(void); + +/* Prend en charge l'objet 'pychrysalide.gtkext.DisplayPanel'. */ +bool register_python_display_panel(PyObject *module); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_GTKEXT_DISPLAYPANEL_H */ diff --git a/plugins/pychrysalide/gtkext/dockable.c b/plugins/pychrysalide/gtkext/dockable.c new file mode 100644 index 0000000..9c66159 --- /dev/null +++ b/plugins/pychrysalide/gtkext/dockable.c @@ -0,0 +1,102 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * dockable.c - équivalent Python du fichier "gtkext/gtkdockable.c" + * + * Copyright (C) 2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "dockable.h" + + +#include <pygobject.h> + + +#include <gtkext/gtkdockable.h> + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Fournit un accès à une définition de type à diffuser. * +* * +* Retour : Définition d'objet pour Python. * +* * +* Remarques : - * +* * +******************************************************************************/ + +PyTypeObject *get_python_gtk_dockable_type(void) +{ + static PyMethodDef py_gtk_dockable_methods[] = { + { NULL } + }; + + static PyGetSetDef py_gtk_dockable_getseters[] = { + { NULL } + }; + + static PyTypeObject py_gtk_dockable_type = { + + PyVarObject_HEAD_INIT(NULL, 0) + + .tp_name = "pychrysalide.gtkext.GtkDockable", + //.tp_basicsize = sizeof(PyGObject), + + .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, + + .tp_doc = "PyChrysalide interface for Gtk dockable widgets", + + .tp_methods = py_gtk_dockable_methods, + .tp_getset = py_gtk_dockable_getseters, + + }; + + return &py_gtk_dockable_type; + +} + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Prend en charge l'objet 'pychrysalide.gtkext.GtkDockable'. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool register_python_gtk_dockable(PyObject *module) +{ + PyTypeObject *py_gtk_dockable_type; /* Type Python 'LineGenerator' */ + PyObject *dict; /* Dictionnaire du module */ + + py_gtk_dockable_type = get_python_gtk_dockable_type(); + + dict = PyModule_GetDict(module); + pyg_register_interface(dict, "LineGenerator", GTK_TYPE_DOCKABLE, py_gtk_dockable_type); + + return true; + +} diff --git a/plugins/pychrysalide/gtkext/dockable.h b/plugins/pychrysalide/gtkext/dockable.h new file mode 100644 index 0000000..dfec74d --- /dev/null +++ b/plugins/pychrysalide/gtkext/dockable.h @@ -0,0 +1,42 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * dockable.h - prototypes pour l'équivalent Python du fichier "gtkext/gtkdockable.h" + * + * Copyright (C) 2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYCHRYSALIDE_GTKEXT_DOCKABLE_H +#define _PLUGINS_PYCHRYSALIDE_GTKEXT_DOCKABLE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Fournit un accès à une définition de type à diffuser. */ +PyTypeObject *get_python_gtk_dockable_type(void); + +/* Prend en charge l'objet 'pychrysalide.gtkext.GtkDockable'. */ +bool register_python_gtk_dockable(PyObject *); + + + +#endif /* _PLUGINS_PYCHRYSALIDE_GTKEXT_DOCKABLE_H */ diff --git a/plugins/pychrysalide/gtkext/module.c b/plugins/pychrysalide/gtkext/module.c new file mode 100644 index 0000000..8b2cc5e --- /dev/null +++ b/plugins/pychrysalide/gtkext/module.c @@ -0,0 +1,95 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.c - intégration du répertoire gtkext en tant que module + * + * Copyright (C) 2012-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "module.h" + + +#include <assert.h> + + +#include "blockdisplay.h" +#include "bufferdisplay.h" +#include "displaypanel.h" +#include "dockable.h" + + + +/****************************************************************************** +* * +* Paramètres : module = module dont la définition est à compléter. * +* * +* Description : Ajoute le module 'gtkext' au module Python. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool add_gtkext_module_to_python_module(PyObject *super) +{ + bool result; /* Bilan à retourner */ + PyObject *module; /* Sous-module mis en place */ + int ret; /* Bilan d'un appel */ + + static PyModuleDef py_chrysalide_gtkext_module = { + + .m_base = PyModuleDef_HEAD_INIT, + + .m_name = "pychrysalide.gtkext", + .m_doc = "Python module for Chrysalide.gtkext", + + .m_size = -1, + + }; + + result = false; + + module = PyModule_Create(&py_chrysalide_gtkext_module); + if (module == NULL) return false; + + ret = PyState_AddModule(super, &py_chrysalide_gtkext_module); + if (ret != 0) goto agmtpm_exit; + + ret = _PyImport_FixupBuiltin(module, "pychrysalide.gtkext"); + if (ret != 0) goto agmtpm_exit; + + Py_INCREF(module); + ret = PyModule_AddObject(super, "gtkext", module); + if (ret != 0) goto agmtpm_exit; + + result = true; + + result &= register_python_display_panel(module); + result &= register_python_buffer_display(module); + result &= register_python_block_display(module); + result &= register_python_gtk_dockable(module); + + agmtpm_exit: + + assert(result); + + return result; + +} diff --git a/plugins/pychrysalide/gtkext/module.h b/plugins/pychrysalide/gtkext/module.h new file mode 100644 index 0000000..a58aed0 --- /dev/null +++ b/plugins/pychrysalide/gtkext/module.h @@ -0,0 +1,39 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * module.h - prototypes pour l'intégration du répertoire gtkext en tant que module + * + * Copyright (C) 2012-2017 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * Chrysalide is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYOIDA_GTKEXT_MODULE_H +#define _PLUGINS_PYOIDA_GTKEXT_MODULE_H + + +#include <Python.h> +#include <stdbool.h> + + + +/* Ajoute le module 'gtkext' au module Python. */ +bool add_gtkext_module_to_python_module(PyObject *); + + + +#endif /* _PLUGINS_PYOIDA_GTKEXT_MODULE_H */ |