From f89f72f53b42c704dcb5767e508747795f7115c6 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 12 Dec 2012 23:27:00 +0000 Subject: Allowed classes which derive from GObject to receive arguments in their constructor. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@302 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 12 ++++++++++++ plugins/pychrysa/gui/panels/panel.c | 7 +++---- plugins/pychrysa/quirks.c | 21 +++++++++++++++++++++ plugins/pychrysa/quirks.h | 3 +++ plugins/python/androperms/androperms.py | 2 +- plugins/python/androperms/panel.py | 2 +- 6 files changed, 41 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cf8d7d..9bcd9bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +12-12-13 Cyrille Bagard + + * plugins/pychrysa/gui/panels/panel.c: + * plugins/pychrysa/quirks.c: + * plugins/pychrysa/quirks.h: + Allow classes which derive from GObject to receive arguments in their + constructor (dirty hack). + + * plugins/python/androperms/androperms.py: + * plugins/python/androperms/panel.py: + Update code. + 12-12-12 Cyrille Bagard * src/analysis/binary.c: diff --git a/plugins/pychrysa/gui/panels/panel.c b/plugins/pychrysa/gui/panels/panel.c index c35e9a0..b1bcc61 100644 --- a/plugins/pychrysa/gui/panels/panel.c +++ b/plugins/pychrysa/gui/panels/panel.c @@ -65,9 +65,7 @@ static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject int ret; /* Bilan de lecture des args. */ GEditorItem *item; /* Version GLib du format */ - ret = PyArg_ParseTupleAndKeywords(args, kwds, "ssOs", - (char *[]) { "name", "lname", "widget", "path", NULL }, - &name, &lname, &widget, &path); + ret = PyArg_ParseTuple(args, "ssOs", &name, &lname, &widget, &path); if (!ret) return Py_None; item = g_panel_item_new(get_internal_ref(), name, lname, @@ -192,7 +190,8 @@ bool register_python_panel_item(PyObject *module) .tp_methods = py_panel_item_methods, .tp_getset = py_panel_item_getseters, - .tp_new = (newfunc)py_panel_item_new + .tp_new = (newfunc)py_panel_item_new, + .tp_init = (initproc)pychrysalide_allow_args_for_gobjects }; diff --git a/plugins/pychrysa/quirks.c b/plugins/pychrysa/quirks.c index 0e35f57..bd60925 100644 --- a/plugins/pychrysa/quirks.c +++ b/plugins/pychrysa/quirks.c @@ -153,6 +153,27 @@ void pychrysalide_set_instance_data(GObject *obj, PyTypeObject *type) /****************************************************************************** * * +* Paramètres : self = objet à initialiser (théoriquement). * +* args = arguments fournis à l'appel. * +* kwds = arguments de type key=val fournis. * +* * +* Description : Initialise un objet dérivé de GObject en Python. * +* * +* Retour : 0. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int pychrysalide_allow_args_for_gobjects(PyObject *self, PyObject *args, PyObject *kwds) +{ + return 0; + +} + + +/****************************************************************************** +* * * Paramètres : ref = espace de référencement global à utiliser. * * * * Description : Evite à Python d'avoir à manipuler les références internes. * diff --git a/plugins/pychrysa/quirks.h b/plugins/pychrysa/quirks.h index f9c53dc..84a778f 100644 --- a/plugins/pychrysa/quirks.h +++ b/plugins/pychrysa/quirks.h @@ -37,6 +37,9 @@ void pychrysalide_init_quirks(void); /* Crée l'association précise attendue par Python-GObject. */ void pychrysalide_set_instance_data(GObject *, PyTypeObject *); +/* Initialise un objet dérivé de GObject en Python. */ +int pychrysalide_allow_args_for_gobjects(PyObject *, PyObject *, PyObject *); + /* Evite à Python d'avoir à manipuler les références internes. */ GObject *_get_internal_ref(GObject *); diff --git a/plugins/python/androperms/androperms.py b/plugins/python/androperms/androperms.py index a11c37d..569558a 100644 --- a/plugins/python/androperms/androperms.py +++ b/plugins/python/androperms/androperms.py @@ -118,5 +118,5 @@ class AndroPerms(Plugin): self._store = gtk.TreeStore(gtk.gdk.Pixbuf, str, gtk.gdk.Pixbuf, str) self._tree.set_model(self._store) - pi = PanelItem(name="Permissions", lname="Permissions", widget=self._scrolled_window, path="SE") + pi = PanelItem('Permissions', 'Permissions', self._scrolled_window, 'SE') pi.dock() diff --git a/plugins/python/androperms/panel.py b/plugins/python/androperms/panel.py index ecbd762..ea26f74 100644 --- a/plugins/python/androperms/panel.py +++ b/plugins/python/androperms/panel.py @@ -71,7 +71,7 @@ class PermsPanel: for p in self._used: - if len(self._used[p]) > 0: + if len(self._used[p]) > 0 or True: img = os.path.dirname(os.path.abspath(__file__)) + '/android.png' buf = gtk.gdk.pixbuf_new_from_file(img) -- cgit v0.11.2-87-g4458