summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/gtkext/displaypanel.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/gtkext/displaypanel.c')
-rw-r--r--plugins/pychrysa/gtkext/displaypanel.c252
1 files changed, 252 insertions, 0 deletions
diff --git a/plugins/pychrysa/gtkext/displaypanel.c b/plugins/pychrysa/gtkext/displaypanel.c
new file mode 100644
index 0000000..598d9b5
--- /dev/null
+++ b/plugins/pychrysa/gtkext/displaypanel.c
@@ -0,0 +1,252 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * displaypanel.c - prototypes pour l'équivalent Python du fichier "gtkext/gtkdisplaypanel.c"
+ *
+ * Copyright (C) 2012 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 <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(get_internal_ref(), 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
+
+ };
+
+ return &py_display_panel_type;
+
+}
+
+
+/******************************************************************************
+* *
+* 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)
+{
+ PyTypeObject *py_display_panel_type; /* Type Python 'DisplayPanel' */
+ PyObject *parent_mod; /* Module Python Fixed */
+ PyObject *fixed; /* Module "GtkFixed" */
+ PyObject *dict; /* Dictionnaire du module */
+
+ py_display_panel_type = get_python_display_panel_type();
+
+ parent_mod = PyImport_ImportModule("gi.repository.Gtk");
+ if (parent_mod == NULL) return false;
+
+ fixed = PyObject_GetAttrString(parent_mod, "Fixed");
+ Py_DECREF(parent_mod);
+
+ dict = PyModule_GetDict(module);
+
+ if (!register_class_for_pygobject(dict, GTK_TYPE_DISPLAY_PANEL, py_display_panel_type, (PyTypeObject *)fixed))
+ return false;
+
+ if (!py_display_panel_define_constants(py_display_panel_type))
+ return false;
+
+ return true;
+
+}