From 61b7967d5031e0724ac8d02694ff58505818a5a0 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Wed, 10 Feb 2016 21:16:25 +0100
Subject: Refreshed all menu accesses in a better way.

---
 ChangeLog                      |  29 +++++++++++
 src/analysis/project.c         |   3 --
 src/gtkext/easygtk.c           |   7 ---
 src/gtkext/gtkbufferview-int.h |   1 -
 src/gtkext/gtkbufferview.c     |   8 ----
 src/gtkext/gtkviewpanel-int.h  |   4 ++
 src/gtkext/gtkviewpanel.c      |   9 +++-
 src/gui/editem-int.h           |  13 ++---
 src/gui/editem.c               |  89 +++++++++++++++++++++-------------
 src/gui/editem.h               |   3 --
 src/gui/menus/edition.c        |  17 ++++---
 src/gui/menus/edition.h        |   4 +-
 src/gui/menus/menubar.c        | 106 ++++++++++++++++-------------------------
 src/gui/status.c               |   5 +-
 src/gui/tb/source.c            |   2 +-
 15 files changed, 160 insertions(+), 140 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index fed398e..eb16b1b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,34 @@
 16-02-10  Cyrille Bagard <nocbos@gmail.com>
 
+	* src/analysis/project.c:
+	Update code.
+
+	* src/gtkext/easygtk.c:
+	Let GTK guess if an accelerator can get activated.
+
+	* src/gtkext/gtkbufferview-int.h:
+	* src/gtkext/gtkbufferview.c:
+	* src/gtkext/gtkviewpanel-int.h:
+	* src/gtkext/gtkviewpanel.c:
+	Move the caret tracking signal from buffer views to view panels.
+
+	* src/gui/editem-int.h:
+	* src/gui/editem.c:
+	* src/gui/editem.h:
+	* src/gui/menus/edition.c:
+	* src/gui/menus/edition.h:
+	* src/gui/menus/menubar.c:
+	Clean the code and remove a deprecated function. Refresh all menu accesses
+	in a better way.
+
+	* src/gui/status.c:
+	Fix a bug involving the use of an uninitialised variable.
+
+	* src/gui/tb/source.c:
+	Update code.
+
+16-02-10  Cyrille Bagard <nocbos@gmail.com>
+
 	* src/analysis/disass/fetch.c:
 	Do not allow half defined locations before running the disassembling
 	process.
diff --git a/src/analysis/project.c b/src/analysis/project.c
index 1befb8f..b787262 100644
--- a/src/analysis/project.c
+++ b/src/analysis/project.c
@@ -645,8 +645,6 @@ size_t g_study_project_attach_binary(GStudyProject *project, GLoadedBinary *bina
                 break;
         }
 
-        manage_editor_items_view(GTK_VIEW_PANEL(view), true);
-
         gtk_widget_show(view);
 
         loaded->views[i] = GTK_VIEW_PANEL(view);
@@ -715,7 +713,6 @@ void g_study_project_detach_binary(GStudyProject *project, GLoadedBinary *binary
     //gtk_dock_panel_remove_item(dpanel, ditem);
 
 
-    //manage_editor_items_view(GObject *ref, GtkViewPanel *view, bool created)
 
     for (i = 0; i < project->binaries_count; i++)
         if (project->binaries[i]->binary == binary) break;
diff --git a/src/gtkext/easygtk.c b/src/gtkext/easygtk.c
index 5d255a5..3ba6664 100644
--- a/src/gtkext/easygtk.c
+++ b/src/gtkext/easygtk.c
@@ -953,13 +953,6 @@ void add_accelerator_to_menu_item(GtkWidget *item, const char *accelerator, GtkA
 
     gtk_accelerator_parse(accelerator, &key, &mods);
 
-    gboolean force_accel_activation(GtkWidget *widget, guint signal_id, gpointer data)
-    {
-        return TRUE;
-    }
-
-    g_signal_connect(item, "can-activate-accel", G_CALLBACK(force_accel_activation), NULL);
-
     gtk_widget_add_accelerator(item, "activate", group,
                                key, mods, GTK_ACCEL_VISIBLE);
 
diff --git a/src/gtkext/gtkbufferview-int.h b/src/gtkext/gtkbufferview-int.h
index 944ddc7..ea181f9 100644
--- a/src/gtkext/gtkbufferview-int.h
+++ b/src/gtkext/gtkbufferview-int.h
@@ -64,7 +64,6 @@ struct _GtkBufferViewClass
 
     /* Signaux */
 
-    void (* caret_moved) (GtkBufferView *, const vmpa2t *);
     void (* reach_limit) (GtkBufferView *, GdkScrollDirection);
 
 };
diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c
index 0e3beeb..d54560c 100644
--- a/src/gtkext/gtkbufferview.c
+++ b/src/gtkext/gtkbufferview.c
@@ -150,14 +150,6 @@ static void gtk_buffer_view_class_init(GtkBufferViewClass *class)
     panel_class->move_caret_to = (move_caret_to_fc)_gtk_buffer_view_move_caret_to;
     panel_class->cache_glance = (cache_glance_fc)gtk_buffer_view_cache_glance;
 
-    g_signal_new("caret-moved",
-                 GTK_TYPE_BUFFER_VIEW,
-                 G_SIGNAL_RUN_LAST,
-                 G_STRUCT_OFFSET(GtkBufferViewClass, caret_moved),
-                 NULL, NULL,
-                 g_cclosure_user_marshal_VOID__UINT64,
-                 G_TYPE_NONE, 1, G_TYPE_UINT64);
-
     g_signal_new("reach-limit",
                  GTK_TYPE_BUFFER_VIEW,
                  G_SIGNAL_RUN_LAST,
diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h
index 5fbcd76..9a2f885 100644
--- a/src/gtkext/gtkviewpanel-int.h
+++ b/src/gtkext/gtkviewpanel-int.h
@@ -101,6 +101,10 @@ struct _GtkViewPanelClass
     move_caret_to_fc move_caret_to;         /* Déplacement du curseur      */
     cache_glance_fc cache_glance;           /* Cache de la mignature       */
 
+    /* Signaux */
+
+    void (* caret_moved) (GtkViewPanel *, const vmpa2t *);
+
 };
 
 /* Propriétés propres au composant d'affichage */
diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c
index 861b46f..a347ad8 100644
--- a/src/gtkext/gtkviewpanel.c
+++ b/src/gtkext/gtkviewpanel.c
@@ -25,7 +25,6 @@
 
 
 #include "gtkviewpanel-int.h"
-#include "../glibext/chrysamarshal.h"
 
 
 
@@ -127,6 +126,14 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class)
 
     panel_class->compute_inc = gtk_view_panel_compute_scroll_inc;
 
+    g_signal_new("caret-moved",
+                 GTK_TYPE_VIEW_PANEL,
+                 G_SIGNAL_RUN_LAST,
+                 G_STRUCT_OFFSET(GtkViewPanelClass, caret_moved),
+                 NULL, NULL,
+                 g_cclosure_marshal_VOID__POINTER,
+                 G_TYPE_NONE, 1, G_TYPE_POINTER);
+
 }
 
 
diff --git a/src/gui/editem-int.h b/src/gui/editem-int.h
index fa62dc6..9918595 100644
--- a/src/gui/editem-int.h
+++ b/src/gui/editem-int.h
@@ -34,6 +34,7 @@
 
 #include "../common/dllist.h"
 #include "../gtkext/gtkbufferview.h"
+#include "../gtkext/gtkviewpanel.h"
 
 
 
@@ -41,13 +42,13 @@
 typedef void (* update_item_binary_fc) (GEditorItem *, GLoadedBinary *);
 
 /* Réagit à un changement d'affichage principal de contenu. */
-typedef void (* manage_item_view_fc) (GEditorItem *, GtkViewPanel *, bool);
-
-/* Réagit à un changement d'affichage principal de contenu. */
 typedef void (* update_item_view_fc) (GEditorItem *, GtkViewPanel *);
 
+/* Réagit à un changement de focus des panneaux d'affichage. */
+typedef void (* notify_focus_change_fc) (GEditorItem *, GtkViewPanel *);
+
 /* Suit les changements de position dans du code d'assembleur. */
-typedef void (* track_caret_in_view_fc) (GEditorItem *, GtkBufferView *, const vmpa2t *);
+typedef void (* track_caret_in_view_fc) (GEditorItem *, GtkViewPanel *, const vmpa2t *);
 
 /* Concentre l'attention de l'ensemble sur une adresse donnée. */
 typedef void (* focus_addr_fc) (GEditorItem *, GLoadedBinary *, const vmpa2t *);
@@ -77,10 +78,10 @@ struct _GEditorItemClass
     GObjectClass parent;                    /* A laisser en premier        */
 
     update_item_binary_fc update_binary;    /* Changement de binaire       */
-    manage_item_view_fc manage_view;        /* Gestion des vues manipulées */
     update_item_view_fc update_view;        /* Rechargement dû à une vue   */
-    track_caret_in_view_fc track_caret;     /* Suivi des positions         */
     update_item_view_fc update_content;     /* Rechargement dû à un contenu*/
+    notify_focus_change_fc notify_focus;    /* Gain ou perte de focus      */
+    track_caret_in_view_fc track_caret;     /* Suivi des positions         */
     focus_addr_fc focus_addr;               /* Prête attention à une addr. */
     update_project_fc update_project;       /* Actualisation des binaires  */
 
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);
 
     }
 
diff --git a/src/gui/editem.h b/src/gui/editem.h
index 67bc402..90b1919 100644
--- a/src/gui/editem.h
+++ b/src/gui/editem.h
@@ -79,9 +79,6 @@ void register_editor_item(GEditorItem *);
 /* Lance une actualisation du fait d'un changement de binaire. */
 void change_editor_items_current_binary(GObject *, GLoadedBinary *);
 
-/* Lance une actualisation liée à une modification du cheptel. */
-void manage_editor_items_view(GtkViewPanel *, bool) __attribute__ ((deprecated));;
-
 /* Lance une actualisation du fait d'un changement de vue. */
 void change_editor_items_current_view(GObject *, GtkViewPanel *);
 
diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c
index 2cc22b2..99ade8c 100644
--- a/src/gui/menus/edition.c
+++ b/src/gui/menus/edition.c
@@ -229,9 +229,9 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : bar  = barre de menus à actualiser.                          *
-*                addr = nouvelle adresse du curseur courant.                  *
-*                info = barre de statut présentant les informations.          *
+*  Paramètres  : ref    = espace de référencements à consulter.               *
+*                vpanel = panneau d'affichage actif ou NULL si aucun.         *
+*                addr   = nouvelle adresse du curseur courant.                *
 *                                                                             *
 *  Description : Met à jour les accès du menu "Edition" selon une position.   *
 *                                                                             *
@@ -241,7 +241,7 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b
 *                                                                             *
 ******************************************************************************/
 
-void update_access_in_menu_edition(GObject *ref, GtkBufferView *view, const vmpa2t *addr)
+void update_access_in_menu_edition(GObject *ref, GtkViewPanel *vpanel, const vmpa2t *addr)
 {
     bool state;                             /* Etat principal à considérer */
     gboolean access;                        /* Accès à déterminer          */
@@ -252,14 +252,14 @@ void update_access_in_menu_edition(GObject *ref, GtkBufferView *view, const vmpa
 
     /* Préliminaire */
 
-    if (view == NULL || addr == NULL)
+    if (vpanel == NULL || addr == NULL)
     {
         state = false;
         line = NULL;
         segment = NULL;
     }
     else
-        state = gtk_view_panel_get_position(GTK_VIEW_PANEL(view), &line, &segment);
+        state = gtk_view_panel_get_position(vpanel, &line, &segment);
 
     if (state)
         creator = g_buffer_segment_get_creator(segment);
@@ -292,6 +292,11 @@ void update_access_in_menu_edition(GObject *ref, GtkBufferView *view, const vmpa
     item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_follow_ref"));
     gtk_widget_set_sensitive(item, access);
 
+    access = state;
+
+    item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_list_xrefs"));
+    gtk_widget_set_sensitive(item, access);
+
     /* Nettoyage et sortie finale */
 
     if (creator != NULL) g_object_unref(G_OBJECT(creator));
diff --git a/src/gui/menus/edition.h b/src/gui/menus/edition.h
index 82a48bd..8be50f8 100644
--- a/src/gui/menus/edition.h
+++ b/src/gui/menus/edition.h
@@ -30,7 +30,7 @@
 
 
 #include "menubar.h"
-#include "../../gtkext/gtkbufferview.h"
+#include "../../gtkext/gtkviewpanel.h"
 
 
 
@@ -38,7 +38,7 @@
 GtkWidget *build_menu_edition(GObject *, GtkAccelGroup *, GMenuBar *);
 
 /* Met à jour les accès du menu "Edition" selon une position. */
-void update_access_in_menu_edition(GObject *, GtkBufferView *, const vmpa2t *);
+void update_access_in_menu_edition(GObject *, GtkViewPanel *, const vmpa2t *);
 
 
 
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c
index cbb6ae2..db1905c 100644
--- a/src/gui/menus/menubar.c
+++ b/src/gui/menus/menubar.c
@@ -74,14 +74,14 @@ static void g_menu_bar_dispose(GMenuBar *);
 /* Procède à la libération totale de la mémoire. */
 static void g_menu_bar_finalize(GMenuBar *);
 
-/* Lance une actualisation liée à une modification du cheptel. */
-static void manage_view_in_menu_bar(GMenuBar *, GtkViewPanel *, bool);
-
 /* Lance une actualisation du fait d'un changement de vue. */
 static void update_menu_bar_for_view(GMenuBar *, GtkViewPanel *);
 
+/* Réagit à un changement de focus des panneaux d'affichage. */
+static void notify_focus_change_for_menu_bar(GMenuBar *, GtkViewPanel *);
+
 /* Met à jour les accès aux menus en fonction de la position. */
-static void track_caret_address_for_menu_bar(GMenuBar *, GtkBufferView *, const vmpa2t *);
+static void track_caret_address_for_menu_bar(GMenuBar *, GtkViewPanel *, const vmpa2t *);
 
 /* Lance une actualisation relative à l'étendue du projet. */
 static void update_menu_bar_for_project(GMenuBar *, GStudyProject *);
@@ -116,8 +116,8 @@ static void g_menu_bar_class_init(GMenuBarClass *klass)
 
     editem = G_EDITOR_ITEM_CLASS(klass);
 
-    editem->manage_view = (manage_item_view_fc)manage_view_in_menu_bar;
     editem->update_view = (update_item_view_fc)update_menu_bar_for_view;
+    editem->notify_focus = (notify_focus_change_fc)notify_focus_change_for_menu_bar;
     editem->track_caret = (track_caret_in_view_fc)track_caret_address_for_menu_bar;
     editem->update_project = (update_project_fc)update_menu_bar_for_project;
 
@@ -262,11 +262,10 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup)
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : bar     = barre de menus à actualiser.                       *
-*                view    = nouveau panneau d'affichage nouveau.               *
-*                created = fait état d'une création ou d'une destruction.     *
+*  Paramètres  : bar  = barre de menus à actualiser.                          *
+*                view = nouveau panneau d'affichage actif.                    *
 *                                                                             *
-*  Description : Lance une actualisation liée à une modification du cheptel.  *
+*  Description : Lance une actualisation du fait d'un changement de vue.      *
 *                                                                             *
 *  Retour      : -                                                            *
 *                                                                             *
@@ -274,55 +273,9 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup)
 *                                                                             *
 ******************************************************************************/
 
-static void manage_view_in_menu_bar(GMenuBar *bar, GtkViewPanel *view, bool created)
+static void update_menu_bar_for_view(GMenuBar *bar, GtkViewPanel *view)
 {
-
-    gboolean view_got_focus(GtkWidget *widget, GtkDirectionType dir, GObject *ref)
-    {
-        GtkWidget *item;
-
-        item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_follow_ref"));
-
-        gtk_widget_set_sensitive(item, TRUE);
-
-        item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_list_xrefs"));
-
-        gtk_widget_set_sensitive(item, TRUE);
-
-        return FALSE;
-
-    }
-
-    gboolean view_lost_focus(GtkWidget *widget, GtkDirectionType dir, GObject *ref)
-    {
-        GtkWidget *item;
-
-        item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_follow_ref"));
-
-        gtk_widget_set_sensitive(item, FALSE);
-
-        item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_list_xrefs"));
-
-        gtk_widget_set_sensitive(item, FALSE);
-
-        return FALSE;
-
-    }
-
-
-    if (created)
-    {
-        g_signal_connect(view, "focus-in-event", G_CALLBACK(view_got_focus), G_EDITOR_ITEM(bar)->ref);
-        g_signal_connect(view, "focus-out-event", G_CALLBACK(view_lost_focus), G_EDITOR_ITEM(bar)->ref);
-    }
-    else
-    {
-        g_signal_handlers_disconnect_by_func(view, G_CALLBACK(view_got_focus), G_EDITOR_ITEM(bar)->ref);
-        g_signal_handlers_disconnect_by_func(view, G_CALLBACK(view_lost_focus), G_EDITOR_ITEM(bar)->ref);
-    }
-
-
-    //    update_menu_view_for_view(bar->view, view, bar);
+    update_menu_view_for_view(bar->view, view, bar);
 
 }
 
@@ -330,9 +283,9 @@ static void manage_view_in_menu_bar(GMenuBar *bar, GtkViewPanel *view, bool crea
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : bar  = barre de menus à actualiser.                          *
-*                view = nouveau panneau d'affichage actif.                    *
+*                panel = composant d'affichage concerné par l'opération.      *
 *                                                                             *
-*  Description : Lance une actualisation du fait d'un changement de vue.      *
+*  Description : Réagit à un changement de focus des panneaux d'affichage.    *
 *                                                                             *
 *  Retour      : -                                                            *
 *                                                                             *
@@ -340,18 +293,39 @@ static void manage_view_in_menu_bar(GMenuBar *bar, GtkViewPanel *view, bool crea
 *                                                                             *
 ******************************************************************************/
 
-static void update_menu_bar_for_view(GMenuBar *bar, GtkViewPanel *view)
+static void notify_focus_change_for_menu_bar(GMenuBar *bar, GtkViewPanel *panel)
 {
-    update_menu_view_for_view(bar->view, view, bar);
+    GBufferLine *line;                      /* Ligne de position courante  */
+    const mrange_t *range;                  /* Couverture en mémoire       */
+    const vmpa2t *addr;                     /* Position courante           */
+    GEditorItem *item;                      /* Autre version de l'élément  */
+
+    if (panel != NULL && gtk_view_panel_get_position(panel, &line, NULL))
+    {
+        range = g_buffer_line_get_range(line);
+        addr = get_mrange_addr(range);
+    }
+    else
+    {
+        line = NULL;
+        addr = NULL;
+    }
+
+    item = G_EDITOR_ITEM(bar);
+
+    update_access_in_menu_edition(item->ref, panel, addr);
+
+    if (line != NULL)
+        g_object_unref(G_OBJECT(line));
 
 }
 
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : bar  = barre de menus à actualiser.                          *
-*                addr = nouvelle adresse du curseur courant.                  *
-*                info = barre de statut présentant les informations.          *
+*  Paramètres  : bar    = barre de menus à actualiser.                        *
+*                vpanel = panneau d'affichage actif ou NULL si aucun.         *
+*                addr   = nouvelle adresse du curseur courant.                *
 *                                                                             *
 *  Description : Met à jour les accès aux menus en fonction de la position.   *
 *                                                                             *
@@ -361,13 +335,13 @@ static void update_menu_bar_for_view(GMenuBar *bar, GtkViewPanel *view)
 *                                                                             *
 ******************************************************************************/
 
-static void track_caret_address_for_menu_bar(GMenuBar *bar, GtkBufferView *view, const vmpa2t *addr)
+static void track_caret_address_for_menu_bar(GMenuBar *bar, GtkViewPanel *vpanel, const vmpa2t *addr)
 {
     GEditorItem *item;                      /* Autre version de l'élément  */
 
     item = G_EDITOR_ITEM(bar);
 
-    update_access_in_menu_edition(item->ref, view, addr);
+    update_access_in_menu_edition(item->ref, vpanel, addr);
 
 }
 
diff --git a/src/gui/status.c b/src/gui/status.c
index a3daded..f1171bd 100644
--- a/src/gui/status.c
+++ b/src/gui/status.c
@@ -250,9 +250,11 @@ static void track_caret_address_for_status_info(GStatusInfo *info, GtkBufferView
 
 static void focus_address_in_status_info(GStatusInfo *info, GLoadedBinary *binary, const vmpa2t *addr)
 {
+    GEditorItem *item;                      /* Autre version de l'élément  */
     GArchProcessor *proc;                   /* Architecture du binaire     */
     GArchInstruction *instr;                /* Instruction présente        */
-    GEditorItem *item;                      /* Autre version de l'élément  */
+
+    item = G_EDITOR_ITEM(info);
 
     if (addr == NULL)
         gtk_status_stack_reset_current_instruction(GTK_STATUS_STACK(item->widget));
@@ -264,7 +266,6 @@ static void focus_address_in_status_info(GStatusInfo *info, GLoadedBinary *binar
         instr = _g_arch_processor_find_instr_by_address(proc, addr, true);
         assert(instr != NULL);
 
-        item = G_EDITOR_ITEM(info);
         gtk_status_stack_update_current_instruction(GTK_STATUS_STACK(item->widget), binary, instr);
 
         g_object_unref(G_OBJECT(proc));
diff --git a/src/gui/tb/source.c b/src/gui/tb/source.c
index 61ad242..466bade 100644
--- a/src/gui/tb/source.c
+++ b/src/gui/tb/source.c
@@ -309,7 +309,7 @@ static void change_selected_source(GtkComboBox *widget, GSourceTbItem *item)
     binary = G_LOADED_BINARY(g_object_get_data(ref, "current_binary"));
     buffer = g_loaded_binary_get_decompiled_buffer(binary, index);
 
-    view = GTK_BUFFER_VIEW(g_object_get_data(ref, "current_view"));
+    view = GTK_BUFFER_VIEW(g_object_get_data(ref, /*"current_view"*/)); /* TODO : utiliser g_editor_item_get_current_view() */
     if (GTK_IS_BUFFER_VIEW(view))
         gtk_buffer_view_attach_buffer(view, buffer,
                                       g_loaded_binary_display_decomp_lines(binary), NULL);
-- 
cgit v0.11.2-87-g4458