summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui/panel.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/gui/panel.c')
-rw-r--r--plugins/pychrysalide/gui/panel.c89
1 files changed, 63 insertions, 26 deletions
diff --git a/plugins/pychrysalide/gui/panel.c b/plugins/pychrysalide/gui/panel.c
index 33ff4e3..d9a2bc5 100644
--- a/plugins/pychrysalide/gui/panel.c
+++ b/plugins/pychrysalide/gui/panel.c
@@ -36,9 +36,10 @@
#include "constants.h"
-#include "editem.h"
+#include "item.h"
#include "../access.h"
#include "../helpers.h"
+#include "../glibext/named.h"
#include "../gtkext/dockable.h"
@@ -66,6 +67,9 @@ static PyObject *py_panel_item_dock(PyObject *, PyObject *);
/* Supprime un panneau de l'ensemble affiché. */
static PyObject *py_panel_item_undock(PyObject *, PyObject *);
+/* Fournit le chemin d'accès à utiliser pour les encapsulations. */
+static PyObject *py_panel_item_get_named_widget(PyObject *, void *);
+
/* Fournit une indication sur la personnalité du panneau. */
static PyObject *py_panel_item_get_personality(PyObject *, void *);
@@ -184,17 +188,14 @@ static void py_panel_item_init_gclass(GPanelItemClass *class, gpointer unused)
static int py_panel_item_init(PyObject *self, PyObject *args, PyObject *kwds)
{
- unsigned long personality; /* Nature du panneau */
- const char *name; /* Désignation humaine */
- const char *lname; /* Nom version longue */
- PyGObject *widget; /* Composant visuel du panneau */
+ PanelItemPersonality personality; /* Nature du panneau */
+ GNamedWidget *widget; /* Composant visuel du panneau */
int startup; /* Recommandation au démarrage */
const char *path; /* Placement à l'affichage */
int ret; /* Bilan de lecture des args. */
GPanelItem *panel; /* Panneau à manipuler */
- GEditorItem *item; /* Version basique d'instance */
- static char *kwlist[] = { "name", "widget", "personality", "lname", "dock", "path", NULL };
+ static char *kwlist[] = { "personality", "widget", "dock", "path", NULL };
#define PANEL_ITEM_DOC \
"PanelItem is an abstract class for panels available in the main GUI" \
@@ -202,15 +203,14 @@ static int py_panel_item_init(PyObject *self, PyObject *args, PyObject *kwds)
"\n" \
"Instances can be created using the following constructor:\n" \
"\n" \
- " PanelItem(name=str, widget=Gtk.Widget," \
- " personality=PanelItemPersonality, lname=str, dock=bool, path=str)" \
+ " PanelItem(personality, widget, dock, path)" \
"\n" \
"Where:\n" \
- "* name is the displayed label on the notebook tab when docked.\n" \
- "* widget is the main widget inside the panel.\n" \
"* personality defines how many instances of the panels can be created" \
" at the same time.\n" \
- "* lname is the long description used for the tooltip.\n" \
+ "* widget is an implementation of the pychrysalide.glibext.NamedWidget" \
+ " interface (see pychrysalide.gtkext.BuiltNamedWidget for a ready-to-use" \
+ " helper).\n" \
"* dock defines if the panel is docked by default.\n" \
"* path states the location of the panel inside the main GUI.\n" \
"\n" \
@@ -218,22 +218,25 @@ static int py_panel_item_init(PyObject *self, PyObject *args, PyObject *kwds)
" transitional dictionary inside the panel *__init__()* constructor:\n" \
"\n" \
" params = {\n" \
- " 'name' : 'Tab label',\n" \
- " 'widget' : self._my_gtk_widget,\n" \
" 'personality' : PanelItemPersonality.PIP_SINGLETON,\n" \
- " 'lname' : 'Long description for tooltip',\n" \
+ " 'widget' : my_named_widget_instance,\n" \
" 'dock' : True,\n" \
" 'path' : 'MES'\n" \
" }\n" \
" super(MyPanel, self).__init__(**params)\n" \
"\n" \
+ "The PanelItem definition handles internally the supply of the *_widget*" \
+ " attribute for pychrysalide.gui.EditorItem.\n" \
+ "\n" \
"For more details about the panel path, please refer to" \
" pychrysalide.gtkext.GtkDockable."
/* Récupération des paramètres */
- ret = PyArg_ParseTupleAndKeywords(args, kwds, "sOksps", kwlist,
- &name, &widget, &personality, &lname, &startup, &path);
+ ret = PyArg_ParseTupleAndKeywords(args, kwds, "O&O&ps", kwlist,
+ convert_to_panel_item_personality, &personality,
+ convert_to_named_widget, &widget,
+ &startup, &path);
if (!ret) return -1;
/* Initialisation d'un objet GLib */
@@ -245,15 +248,7 @@ static int py_panel_item_init(PyObject *self, PyObject *args, PyObject *kwds)
panel = G_PANEL_ITEM(pygobject_get(self));
- item = G_EDITOR_ITEM(panel);
-
- item->name = strdup(name);;
- item->widget = GTK_WIDGET(pygobject_get(widget));
-
panel->personality = personality;
- panel->lname = strdup(lname);
- panel->dock_at_startup = startup;
- panel->path = strdup(path);
/**
* Si Python ne voit plus la variable représentant le panneau utilisée,
@@ -262,7 +257,11 @@ static int py_panel_item_init(PyObject *self, PyObject *args, PyObject *kwds)
* On sera donc en situation de Use-After-Free, dont les conséquences
* arrivent très vite.
*/
- g_object_ref(G_OBJECT(item->widget));
+ panel->widget = widget;
+ g_object_ref(G_OBJECT(widget));
+
+ panel->dock_at_startup = startup;
+ panel->path = strdup(path);
return 0;
@@ -346,6 +345,43 @@ static PyObject *py_panel_item_undock(PyObject *self, PyObject *args)
* Paramètres : self = objet Python concerné par l'appel. *
* closure = non utilisé ici. *
* *
+* Description : Fournit le chemin d'accès à utiliser pour les encapsulations.*
+* *
+* Retour : Chemin d'accès défini. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_panel_item_get_named_widget(PyObject *self, void *closure)
+{
+ PyObject *result; /* Valeur à retourner */
+ GPanelItem *item; /* Panneau à consulter */
+ GNamedWidget *widget; /* Composant nommé à transférer*/
+
+#define PANEL_ITEM_NAMED_WIDGET_ATTRIB PYTHON_GET_DEF_FULL \
+( \
+ named_widget, py_panel_item, \
+ "Named widget as core component of the panel item." \
+)
+
+ item = G_PANEL_ITEM(pygobject_get(self));
+ widget = gtk_panel_item_get_named_widget(item);
+
+ result = pygobject_new(G_OBJECT(widget));
+
+ g_object_unref(G_OBJECT(widget));
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* closure = non utilisé ici. *
+* *
* Description : Fournit une indication sur la personnalité du panneau. *
* *
* Retour : Identifiant lié à la nature du panneau. *
@@ -502,6 +538,7 @@ PyTypeObject *get_python_panel_item_type(void)
};
static PyGetSetDef py_panel_item_getseters[] = {
+ PANEL_ITEM_NAMED_WIDGET_ATTRIB,
PANEL_ITEM_PERSONALITY_ATTRIB,
PANEL_ITEM_PATH_ATTRIB,
PANEL_ITEM_DOCKED_ATTRIB,