summaryrefslogtreecommitdiff
path: root/src/gui/editem.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-02-10 20:16:25 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-02-10 20:16:25 (GMT)
commit61b7967d5031e0724ac8d02694ff58505818a5a0 (patch)
tree4b9ea233e61ee9e688fd29e93a8061732a755e6e /src/gui/editem.c
parentabc912f8500312c888832ff521d3dd17d8b2c613 (diff)
Refreshed all menu accesses in a better way.
Diffstat (limited to 'src/gui/editem.c')
-rw-r--r--src/gui/editem.c89
1 files changed, 55 insertions, 34 deletions
diff --git a/src/gui/editem.c b/src/gui/editem.c
index 9f10bec..1dc77c9 100644
--- a/src/gui/editem.c
+++ b/src/gui/editem.c
@@ -47,12 +47,18 @@ static void g_editor_item_init(GEditorItem *);
/* Liste des éléments enregistrés */
static GEditorItem *_editem_list = NULL;
+/* Suivi du panneau d'affichage courant */
+static GtkViewPanel *_current_view = NULL;
+
/* Suivi des changements de position */
static GObject *_caret_instance = NULL;
+/* Suit les changements de focus des panneaux d'affichage. */
+static gboolean notify_view_panel_focus_change(GtkViewPanel *, GdkEventFocus *, void *);
+
/* Suit les changements de position dans du code d'assembleur. */
-static void track_caret_address_on_buffer_views(GtkBufferView *, const vmpa2t *, void *);
+static void track_caret_address_on_view_panel(GtkViewPanel *, const vmpa2t *, void *);
@@ -173,7 +179,7 @@ GLoadedBinary *g_editor_item_get_current_binary(const GEditorItem *item)
GtkViewPanel *g_editor_item_get_current_view(const GEditorItem *item)
{
- return g_object_get_data(item->ref, "current_view");
+ return _current_view;
}
@@ -237,18 +243,19 @@ void change_editor_items_current_binary(GObject *ref, GLoadedBinary *binary)
/******************************************************************************
* *
-* Paramètres : view = nouveau panneau d'affichage nouveau. *
-* created = fait état d'une création ou d'une destruction. *
+* Paramètres : vpanel = composant d'affichage concerné par l'opération. *
+* event = informations liées à l'événement. *
+* data = adresse non utilisée ici. *
* *
-* Description : Lance une actualisation liée à une modification du cheptel. *
+* Description : Suit les changements de focus des panneaux d'affichage. *
* *
-* Retour : - *
+* Retour : FALSE pour continuer la propagation. *
* *
* Remarques : - *
* *
******************************************************************************/
-void manage_editor_items_view(GtkViewPanel *view, bool created)
+static gboolean notify_view_panel_focus_change(GtkViewPanel *vpanel, GdkEventFocus *event, void *data)
{
GEditorItem *iter; /* Boucle de parcours */
GEditorItemClass *klass; /* Classe correspondante */
@@ -257,19 +264,21 @@ void manage_editor_items_view(GtkViewPanel *view, bool created)
{
klass = G_EDITOR_ITEM_GET_CLASS(iter);
- if (klass->manage_view != NULL)
- klass->manage_view(iter, view, created);
+ if (klass->notify_focus != NULL)
+ klass->notify_focus(iter, event->in ? vpanel : NULL);
}
+ return FALSE;
+
}
/******************************************************************************
* *
-* Paramètres : view = composant d'affichage parcouru. *
-* addr = nouvelle adresse du curseur courant. *
-* data = adresse non utilisée ici. *
+* Paramètres : vpanel = composant d'affichage parcouru. *
+* addr = nouvelle adresse du curseur courant. *
+* data = adresse non utilisée ici. *
* *
* Description : Suit les changements de position dans du code d'assembleur. *
* *
@@ -279,7 +288,7 @@ void manage_editor_items_view(GtkViewPanel *view, bool created)
* *
******************************************************************************/
-static void track_caret_address_on_buffer_views(GtkBufferView *view, const vmpa2t *addr, void *data)
+static void track_caret_address_on_view_panel(GtkViewPanel *vpanel, const vmpa2t *addr, void *data)
{
GEditorItem *iter; /* Boucle de parcours */
GEditorItemClass *klass; /* Classe correspondante */
@@ -289,7 +298,7 @@ static void track_caret_address_on_buffer_views(GtkBufferView *view, const vmpa2
klass = G_EDITOR_ITEM_GET_CLASS(iter);
if (klass->track_caret != NULL)
- klass->track_caret(iter, view, addr);
+ klass->track_caret(iter, vpanel, addr);
}
@@ -298,8 +307,8 @@ static void track_caret_address_on_buffer_views(GtkBufferView *view, const vmpa2
/******************************************************************************
* *
-* Paramètres : ref = espace de référencement global. *
-* view = nouveau panneau d'affichage actif. *
+* Paramètres : ref = espace de référencement global. *
+* vpanel = nouveau panneau d'affichage actif. *
* *
* Description : Lance une actualisation du fait d'un changement de vue. *
* *
@@ -309,43 +318,55 @@ static void track_caret_address_on_buffer_views(GtkBufferView *view, const vmpa2
* *
******************************************************************************/
-void change_editor_items_current_view(GObject *ref, GtkViewPanel *view)
+void change_editor_items_current_view(GObject *ref, GtkViewPanel *vpanel)
{
GEditorItem *iter; /* Boucle de parcours */
GEditorItemClass *klass; /* Classe correspondante */
- g_object_set_data(ref, "current_view", view);
+ /* Suivi des affichages */
+
+ if (_current_view != NULL)
+ {
+ g_signal_handlers_disconnect_by_func(_current_view, G_CALLBACK(notify_view_panel_focus_change), NULL);
+ g_signal_handlers_disconnect_by_func(_current_view, G_CALLBACK(notify_view_panel_focus_change), NULL);
+ }
+
+ _current_view = vpanel;
editem_list_for_each(iter, _editem_list)
{
klass = G_EDITOR_ITEM_GET_CLASS(iter);
if (klass->update_view != NULL)
- klass->update_view(iter, view);
+ klass->update_view(iter, vpanel);
+
+ }
+ if (vpanel != NULL)
+ {
+ g_signal_connect(vpanel, "focus-in-event", G_CALLBACK(notify_view_panel_focus_change), NULL);
+ g_signal_connect(vpanel, "focus-out-event", G_CALLBACK(notify_view_panel_focus_change), NULL);
}
+ /* Suivi du curseur */
+
if (_caret_instance != NULL)
{
g_signal_handlers_disconnect_by_func(_caret_instance,
- G_CALLBACK(track_caret_address_on_buffer_views),
+ G_CALLBACK(track_caret_address_on_view_panel),
NULL);
g_object_unref(_caret_instance);
_caret_instance = NULL;
}
- if (view != NULL)
+ if (vpanel != NULL)
{
- if (GTK_IS_BLOCK_VIEW(view))
- {
- g_signal_connect(view, "caret-moved",
- G_CALLBACK(track_caret_address_on_buffer_views),
- NULL);
-
- _caret_instance = G_OBJECT(view);
- g_object_ref(_caret_instance);
+ g_signal_connect(vpanel, "caret-moved",
+ G_CALLBACK(track_caret_address_on_view_panel),
+ NULL);
- }
+ _caret_instance = G_OBJECT(vpanel);
+ g_object_ref(_caret_instance);
}
@@ -354,8 +375,8 @@ void change_editor_items_current_view(GObject *ref, GtkViewPanel *view)
/******************************************************************************
* *
-* Paramètres : ref = espace de référencement global. *
-* view = nouveau panneau d'affichage actif. *
+* Paramètres : ref = espace de référencement global. *
+* vpanel = nouveau panneau d'affichage actif. *
* *
* Description : Lance une actualisation du fait d'un changement de contenu. *
* *
@@ -365,7 +386,7 @@ void change_editor_items_current_view(GObject *ref, GtkViewPanel *view)
* *
******************************************************************************/
-void change_editor_items_current_view_content(GtkViewPanel *view)
+void change_editor_items_current_view_content(GtkViewPanel *vpanel)
{
GEditorItem *iter; /* Boucle de parcours */
GEditorItemClass *klass; /* Classe correspondante */
@@ -375,7 +396,7 @@ void change_editor_items_current_view_content(GtkViewPanel *view)
klass = G_EDITOR_ITEM_GET_CLASS(iter);
if (klass->update_content != NULL)
- klass->update_content(iter, view);
+ klass->update_content(iter, vpanel);
}