summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-11-11 18:47:15 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-11-11 18:47:15 (GMT)
commit04f9aebee5249624ccd4173989354cd93474376f (patch)
tree90c23774e2898be78a372650a6d6d219104196fb /plugins/pychrysalide/gui
parent77c68b54d4b2970a749eb4a658c32d2a16deacf6 (diff)
Extended the Python bindings.
Diffstat (limited to 'plugins/pychrysalide/gui')
-rw-r--r--plugins/pychrysalide/gui/core/global.c49
-rw-r--r--plugins/pychrysalide/gui/editem.c103
2 files changed, 152 insertions, 0 deletions
diff --git a/plugins/pychrysalide/gui/core/global.c b/plugins/pychrysalide/gui/core/global.c
index 40f6b6e..26d51cb 100644
--- a/plugins/pychrysalide/gui/core/global.c
+++ b/plugins/pychrysalide/gui/core/global.c
@@ -39,6 +39,9 @@
/* Fournit l'adresse de la fenêtre principale de l'éditeur. */
static PyObject *py_global_get_editor_window(PyObject *, PyObject *);
+/* Fournit le contenu actif en cours d'étude. */
+static PyObject *py_global_get_current_content(PyObject *, PyObject *);
+
/******************************************************************************
@@ -86,6 +89,51 @@ static PyObject *py_global_get_editor_window(PyObject *self, PyObject *args)
/******************************************************************************
* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* args = non utilisé ici. *
+* *
+* Description : Fournit le contenu actif en cours d'étude. *
+* *
+* Retour : Instance courante de contenu étudié ou None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_global_get_current_content(PyObject *self, PyObject *args)
+{
+ PyObject *result; /* Instance Python à retourner */
+ GLoadedContent *content; /* Contenu courant récupéré */
+
+#define GLOBAL_GET_CURRENT_CONTENT_METHOD PYTHON_METHOD_DEF \
+( \
+ get_current_content, "", \
+ METH_NOARGS, py_global, \
+ "Provide access to the active loaded content, as a" \
+ " pychrysalide.analysis.LoadedContent instance, or None" \
+ " if no current content is loaded." \
+)
+
+ content = get_current_content();
+
+ if (content != NULL)
+ {
+ result = pygobject_new(G_OBJECT(content));
+ g_object_unref(G_OBJECT(content));
+ }
+ else
+ {
+ result = Py_None;
+ Py_INCREF(result);
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : - *
* *
* Description : Définit une extension du module 'core' à compléter. *
@@ -103,6 +151,7 @@ bool populate_gui_core_module_with_global(void)
static PyMethodDef py_global_methods[] = {
GLOBAL_GET_EDITOR_WINDOW_METHOD,
+ GLOBAL_GET_CURRENT_CONTENT_METHOD,
{ NULL }
};
diff --git a/plugins/pychrysalide/gui/editem.c b/plugins/pychrysalide/gui/editem.c
index 68962ae..71bf316 100644
--- a/plugins/pychrysalide/gui/editem.c
+++ b/plugins/pychrysalide/gui/editem.c
@@ -51,6 +51,12 @@ static void py_editor_item_change_view_wrapper(GEditorItem *, GLoadedPanel *, GL
/* Réagit à une modification de la vue du contenu analysé. */
static void py_editor_item_update_view_wrapper(GEditorItem *, GLoadedPanel *);
+/* Réagit à une modification de la vue du contenu analysé. */
+static void py_editor_item_track_cursor_wrapper(GEditorItem *, GLoadedPanel *, const GLineCursor *);
+
+/* Réagit à une modification de la vue du contenu analysé. */
+static void py_editor_item_focus_cursor_wrapper(GEditorItem *, GLoadedContent *, const GLineCursor *);
+
/* ---------------------------------------------------------------------------------- */
@@ -77,6 +83,9 @@ void py_editor_item_init_gclass(GEditorItemClass *class, gpointer unused)
class->change_view = py_editor_item_change_view_wrapper;
class->update_view = py_editor_item_update_view_wrapper;
+ class->track_cursor = py_editor_item_track_cursor_wrapper;
+ class->focus_cursor = py_editor_item_focus_cursor_wrapper;
+
}
@@ -255,6 +264,100 @@ static void py_editor_item_update_view_wrapper(GEditorItem *item, GLoadedPanel *
}
+/******************************************************************************
+* *
+* Paramètres : item = instance à consulter. *
+* panel = composant d'affichage parcouru. *
+* cursor = nouvel emplacement du curseur courant. *
+* *
+* Description : Réagit à une modification de la vue du contenu analysé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void py_editor_item_track_cursor_wrapper(GEditorItem *item, GLoadedPanel *panel, const GLineCursor *cursor)
+{
+ PyObject *pyobj; /* Objet Python concerné */
+ PyThreadState *tstate; /* Contexte d'environnement */
+ PyObject *args; /* Arguments pour l'appel */
+ PyObject *pyret; /* Retour de Python */
+
+ pyobj = pygobject_new(G_OBJECT(item));
+
+ tstate = get_pychrysalide_main_tstate();
+
+ if (tstate != NULL)
+ PyEval_RestoreThread(tstate);
+
+ if (has_python_method(pyobj, "_track_cursor"))
+ {
+ args = PyTuple_New(2);
+ PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(panel)));
+ PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(cursor)));
+
+ pyret = run_python_method(pyobj, "_track_cursor", args);
+
+ Py_DECREF(args);
+ Py_DECREF(pyret);
+
+ }
+
+ if (tstate != NULL)
+ PyEval_SaveThread();
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : item = instance à consulter. *
+* content = contenu contenant le curseur à représenter. *
+* cursor = nouvel emplacement du curseur courant. *
+* *
+* Description : Réagit à une modification de la vue du contenu analysé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void py_editor_item_focus_cursor_wrapper(GEditorItem *item, GLoadedContent *content, const GLineCursor *cursor)
+{
+ PyObject *pyobj; /* Objet Python concerné */
+ PyThreadState *tstate; /* Contexte d'environnement */
+ PyObject *args; /* Arguments pour l'appel */
+ PyObject *pyret; /* Retour de Python */
+
+ pyobj = pygobject_new(G_OBJECT(item));
+
+ tstate = get_pychrysalide_main_tstate();
+
+ if (tstate != NULL)
+ PyEval_RestoreThread(tstate);
+
+ if (has_python_method(pyobj, "_focus_cursor"))
+ {
+ args = PyTuple_New(2);
+ PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(content)));
+ PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(cursor)));
+
+ pyret = run_python_method(pyobj, "_focus_cursor", args);
+
+ Py_DECREF(args);
+ Py_DECREF(pyret);
+
+ }
+
+ if (tstate != NULL)
+ PyEval_SaveThread();
+
+}
+
+
/* ---------------------------------------------------------------------------------- */
/* FONCTIONNALITES D'UN ELEMENT */