From 223c2d906ccdb1ae680a474884448c799878a06f Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Fri, 21 Dec 2018 15:58:27 +0100
Subject: Updated the graph view when updating the current location.

---
 src/glibext/gloadedpanel-int.h   |  4 ----
 src/glibext/gloadedpanel.c       | 24 -------------------
 src/glibext/gloadedpanel.h       |  3 ---
 src/gtkext/gtkblockdisplay.c     | 28 ----------------------
 src/gtkext/gtkdisplaypanel-int.h | 10 +++-----
 src/gtkext/gtkdisplaypanel.c     | 35 +++++----------------------
 src/gtkext/gtkgraphdisplay.c     | 51 ++++++++++------------------------------
 src/gui/menus/view.c             |  2 --
 8 files changed, 22 insertions(+), 135 deletions(-)

diff --git a/src/glibext/gloadedpanel-int.h b/src/glibext/gloadedpanel-int.h
index 36a1437..f9c451c 100644
--- a/src/glibext/gloadedpanel-int.h
+++ b/src/glibext/gloadedpanel-int.h
@@ -38,9 +38,6 @@ typedef GLoadedContent * (* get_loaded_panel_content_fc) (const GLoadedPanel *);
 /* Fournit le position courante dans un panneau de chargement. */
 typedef GLineCursor * (* get_loaded_cursor_fc) (const GLoadedPanel *);
 
-/* Définit le position courante dans un panneau de chargement. */
-typedef void (* set_loaded_cursor_fc) (GLoadedPanel *, const GLineCursor *);
-
 /* S'assure qu'un emplacement donné est visible à l'écran. */
 typedef void (* scroll_loaded_to_cursor_fc) (GLoadedPanel *, const GLineCursor *, ScrollPositionTweak, bool);
 
@@ -59,7 +56,6 @@ struct _GLoadedPanelIface
     get_loaded_panel_content_fc get_content;/* Récupération du contenu     */
 
     get_loaded_cursor_fc get_cursor;        /* Fourniture d'une position   */
-    set_loaded_cursor_fc set_cursor;        /* Application d'une position  */
     scroll_loaded_to_cursor_fc scroll;      /* Défilement de la vue        */
 
     cache_loaded_glance_fc cache_glance;    /* Cache de la mignature       */
diff --git a/src/glibext/gloadedpanel.c b/src/glibext/gloadedpanel.c
index ead34b7..76af0d6 100644
--- a/src/glibext/gloadedpanel.c
+++ b/src/glibext/gloadedpanel.c
@@ -151,30 +151,6 @@ GLineCursor *g_loaded_panel_get_cursor(const GLoadedPanel *panel)
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : panel  = composant GTK à mettre à jour.                      *
-*                cursor = informations relatives à la position du curseur.    *
-*                                                                             *
-*  Description : Définit le position courante dans un panneau de chargement.  *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-void g_loaded_panel_set_cursor(GLoadedPanel *panel, const GLineCursor *cursor)
-{
-    GLoadedPanelIface *iface;               /* Interface utilisée          */
-
-    iface = G_LOADED_PANEL_GET_IFACE(panel);
-
-    iface->set_cursor(panel, cursor);
-
-}
-
-
-/******************************************************************************
-*                                                                             *
 *  Paramètres  : panel  = composant GTK à manipuler.                          *
 *                cursor = emplacement à cibler pour un déplacement.           *
 *                save   = le changement est-il majeur ?                       *
diff --git a/src/glibext/gloadedpanel.h b/src/glibext/gloadedpanel.h
index 50ea058..9d460c7 100644
--- a/src/glibext/gloadedpanel.h
+++ b/src/glibext/gloadedpanel.h
@@ -62,9 +62,6 @@ GLoadedContent *g_loaded_panel_get_content(const GLoadedPanel *);
 /* Fournit le position courante dans un panneau de chargement. */
 GLineCursor *g_loaded_panel_get_cursor(const GLoadedPanel *);
 
-/* Définit le position courante dans un panneau de chargement. */
-void g_loaded_panel_set_cursor(GLoadedPanel *, const GLineCursor *);
-
 /* Demande à qui veut répondre un déplacement du curseur. */
 void g_loaded_panel_request_move(GLoadedPanel *, const GLineCursor *, gboolean);
 
diff --git a/src/gtkext/gtkblockdisplay.c b/src/gtkext/gtkblockdisplay.c
index c8d12ea..97136c9 100644
--- a/src/gtkext/gtkblockdisplay.c
+++ b/src/gtkext/gtkblockdisplay.c
@@ -72,9 +72,6 @@ static gboolean gtk_block_display_query_tooltip(GtkWidget *, gint, gint, gboolea
 /* Redessine l'affichage suite à un changement visuel. */
 static gboolean gtk_block_display_need_redraw(GtkBlockDisplay *, GBufferView *);
 
-/* Définit le position courante dans un panneau de chargement. */
-static void gtk_block_display_set_cursor(GtkBlockDisplay *, const GLineCursor *);
-
 /* Réagit à un déplacement de curseur. */
 static bool gtk_block_display_notify_caret_relocation(GtkBlockDisplay *, const GdkRectangle *);
 
@@ -100,7 +97,6 @@ static void gtk_block_display_class_init(GtkBlockDisplayClass *class)
 {
     GObjectClass *object;                   /* Autre version de la classe  */
     GtkWidgetClass *widget_class;           /* Classe version Widget       */
-    GtkDisplayPanelClass *panel_class;      /* Classe parente              */
     GtkBufferDisplayClass *buffer_class;    /* Classe supérieure           */
 
     object = G_OBJECT_CLASS(class);
@@ -113,10 +109,6 @@ static void gtk_block_display_class_init(GtkBlockDisplayClass *class)
     widget_class->button_press_event = gtk_block_display_button_press;
     widget_class->query_tooltip = gtk_block_display_query_tooltip;
 
-    panel_class = GTK_DISPLAY_PANEL_CLASS(class);
-
-    panel_class->set_cursor = (set_cursor_fc)gtk_block_display_set_cursor;
-
     buffer_class = GTK_BUFFER_DISPLAY_CLASS(class);
 
     buffer_class->notify_caret = (notify_caret_relocation_fc)gtk_block_display_notify_caret_relocation;
@@ -381,26 +373,6 @@ static gboolean gtk_block_display_need_redraw(GtkBlockDisplay *display, GBufferV
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : display = composant GTK à mettre à jour.                     *
-*                cursor  = informations relatives à la position du curseur.   *
-*                                                                             *
-*  Description : Définit le position courante dans un panneau de chargement.  *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static void gtk_block_display_set_cursor(GtkBlockDisplay *display, const GLineCursor *cursor)
-{
-
-
-}
-
-
-/******************************************************************************
-*                                                                             *
 *  Paramètres  : display = composant GTK à manipuler.                         *
 *                area    = emplacement pour le dessin d'un curseur.           *
 *                                                                             *
diff --git a/src/gtkext/gtkdisplaypanel-int.h b/src/gtkext/gtkdisplaypanel-int.h
index 90b146c..7d64925 100644
--- a/src/gtkext/gtkdisplaypanel-int.h
+++ b/src/gtkext/gtkdisplaypanel-int.h
@@ -46,8 +46,8 @@ typedef void (* compute_scroll_inc_fc) (GtkDisplayPanel *, gint, GtkOrientation,
 /* Réagit à un défilement chez une barre associée au composant. */
 typedef void (* adjust_scroll_value_fc) (GtkDisplayPanel *, GtkAdjustment *, GtkOrientation);
 
-/* Réagit à la sélection externe d'une adresse. */
-typedef void (* define_address_fc) (GtkDisplayPanel *, const vmpa2t *);
+/* Ajuste au besoin la zone affichée pour un curseur. */
+typedef void (* prepare_for_cursor_fc) (GtkDisplayPanel *, const GLineCursor *);
 
 /* Indique la position d'affichage d'une adresse donnée. */
 typedef bool (* get_coordinates_fc) (const GtkDisplayPanel *, const GLineCursor *, gint *, gint *, ScrollPositionTweak);
@@ -64,9 +64,6 @@ typedef bool (* move_caret_to_fc) (GtkDisplayPanel *, gint, gint);
 /* Fournit le position courante dans un panneau de chargement. */
 typedef GLineCursor * (* get_cursor_fc) (const GtkDisplayPanel *);
 
-/* Définit le position courante dans un panneau de chargement. */
-typedef void (* set_cursor_fc) (GtkDisplayPanel *, const GLineCursor *);
-
 /* Place en cache un rendu destiné à l'aperçu graphique rapide. */
 typedef void (* cache_glance_fc) (GtkDisplayPanel *, cairo_t *, const GtkAllocation *, double);
 
@@ -98,13 +95,12 @@ struct _GtkDisplayPanelClass
     compute_requested_size_fc compute_size; /* Calcul de la taille requise */
     compute_scroll_inc_fc compute_inc;      /* Calcul des bonds            */
     adjust_scroll_value_fc adjust;          /* Réaction à un défilement    */
-    define_address_fc define;               /* Centrage sur une partie     */
+    prepare_for_cursor_fc prepare;          /* Préparation de zone affichée*/
     get_coordinates_fc get_coordinates;     /* Conversion adresse <-> pos. */
     get_active_object_fc get_active;        /* Infos sur l'objet actif     */
     move_caret_to_fc move_caret_to;         /* Déplacement du curseur      */
 
     get_cursor_fc get_cursor;               /* Fourniture d'une position   */
-    set_cursor_fc set_cursor;               /* Application d'une position  */
     cache_glance_fc cache_glance;           /* Cache de la mignature       */
 
 };
diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c
index b937e2e..e548bf7 100644
--- a/src/gtkext/gtkdisplaypanel.c
+++ b/src/gtkext/gtkdisplaypanel.c
@@ -108,9 +108,6 @@ static GLoadedContent *gtk_display_panel_get_content(const GtkDisplayPanel *);
 /* Fournit le position courante dans un panneau de chargement. */
 static GLineCursor *gtk_display_panel_get_cursor(const GtkDisplayPanel *);
 
-/* Définit le position courante dans un panneau de chargement. */
-static void gtk_display_panel_set_cursor(GtkDisplayPanel *, const GLineCursor *);
-
 /* S'assure qu'un emplacement donné est visible à l'écran. */
 static void gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *, const GLineCursor *, ScrollPositionTweak, bool);
 
@@ -209,7 +206,6 @@ static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *iface
     iface->get_content = (get_loaded_panel_content_fc)gtk_display_panel_get_content;
 
     iface->get_cursor = (get_loaded_cursor_fc)gtk_display_panel_get_cursor;
-    iface->set_cursor = (set_loaded_cursor_fc)gtk_display_panel_set_cursor;
     iface->scroll = (scroll_loaded_to_cursor_fc)gtk_display_panel_scroll_to_cursor;
 
     iface->cache_glance = (cache_loaded_glance_fc)gtk_display_panel_cache_glance;
@@ -1126,26 +1122,6 @@ static GLineCursor *gtk_display_panel_get_cursor(const GtkDisplayPanel *panel)
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : panel  = composant GTK à mettre à jour.                      *
-*                cursor = informations relatives à la position du curseur.    *
-*                                                                             *
-*  Description : Définit le position courante dans un panneau de chargement.  *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static void gtk_display_panel_set_cursor(GtkDisplayPanel *panel, const GLineCursor *cursor)
-{
-    GTK_DISPLAY_PANEL_GET_CLASS(panel)->set_cursor(panel, cursor);
-
-}
-
-
-/******************************************************************************
-*                                                                             *
 *  Paramètres  : panel  = composant GTK à manipuler.                          *
 *                cursor = emplacement à présenter à l'écran.                  *
 *                tweak  = adaptation finale à effectuer.                      *
@@ -1162,6 +1138,7 @@ static void gtk_display_panel_set_cursor(GtkDisplayPanel *panel, const GLineCurs
 static void gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *panel, const GLineCursor *cursor, ScrollPositionTweak tweak, bool move)
 {
     GtkWidget *parent;                      /* Support parent à valider    */
+    GtkDisplayPanelClass *class;            /* Classe de l'instance        */
     gint x;                                 /* Abscisse à garantir         */
     gint y;                                 /* Ordonnée à garantir         */
     GtkWidget *viewport;                    /* Parent avec défilement      */
@@ -1181,10 +1158,10 @@ static void gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *panel, const GLi
     if (GTK_IS_DISPLAY_PANEL(parent))
         panel = GTK_DISPLAY_PANEL(parent);
 
-    /*
-    if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->define != NULL)
-        GTK_DISPLAY_PANEL_GET_CLASS(panel)->define(panel, addr);
-    */
+    class = GTK_DISPLAY_PANEL_GET_CLASS(panel);
+
+    if (class->prepare != NULL)
+        class->prepare(panel, cursor);
 
     if (gtk_display_panel_get_cursor_coordinates(panel, cursor, &x, &y, tweak))
     {
@@ -1221,7 +1198,7 @@ static void gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *panel, const GLi
         /* Déplacement du curseur */
 
         if (move && gtk_display_panel_get_cursor_coordinates(panel, cursor, &x, &y, SPT_RAW))
-            GTK_DISPLAY_PANEL_GET_CLASS(panel)->move_caret_to(panel, x, y);
+            class->move_caret_to(panel, x, y);
 
     }
 
diff --git a/src/gtkext/gtkgraphdisplay.c b/src/gtkext/gtkgraphdisplay.c
index 0aee486..a991ace 100644
--- a/src/gtkext/gtkgraphdisplay.c
+++ b/src/gtkext/gtkgraphdisplay.c
@@ -111,8 +111,8 @@ static gboolean gtk_graph_display_button_release(GtkWidget *, GdkEventButton *,
 /* Assure la suivi des déplacements de souris sur le composant. */
 static gboolean gtk_graph_display_motion_notify(GtkWidget *, GdkEventMotion *, GtkGraphDisplay *);
 
-/* Réagit à la sélection externe d'une adresse. */
-static void gtk_graph_display_define_main_address(GtkGraphDisplay *, const vmpa2t *);
+/* Ajuste au besoin la zone affichée pour un curseur. */
+static void gtk_graph_display_prepare_for_cursor(GtkGraphDisplay *, const GLineCursor *);
 
 /* Indique la position d'affichage d'un emplacement donné. */
 static bool gtk_graph_display_get_cursor_coordinates(const GtkGraphDisplay *, const GLineCursor *, gint *, gint *, ScrollPositionTweak);
@@ -123,9 +123,6 @@ static bool gtk_graph_display_move_caret_to(GtkGraphDisplay *, gint, gint);
 /* Fournit le position courante dans un panneau de chargement. */
 static GLineCursor *gtk_graph_display_get_cursor(const GtkGraphDisplay *);
 
-/* Définit le position courante dans un panneau de chargement. */
-static void gtk_graph_display_set_cursor(GtkGraphDisplay *, const GLineCursor *);
-
 /* Place en cache un rendu destiné à l'aperçu graphique rapide. */
 static void gtk_graph_display_cache_glance(GtkGraphDisplay *, cairo_t *, const GtkAllocation *, double);
 
@@ -175,12 +172,11 @@ static void gtk_graph_display_class_init(GtkGraphDisplayClass *class)
 
     panel_class->compute_size = (compute_requested_size_fc)gtk_graph_display_compute_requested_size;
     panel_class->adjust = (adjust_scroll_value_fc)gtk_graph_display_adjust_scroll_value;
-    panel_class->define = (define_address_fc)gtk_graph_display_define_main_address;
+    panel_class->prepare = (prepare_for_cursor_fc)gtk_graph_display_prepare_for_cursor;
 
     panel_class->get_coordinates = (get_coordinates_fc)gtk_graph_display_get_cursor_coordinates;
     panel_class->move_caret_to = (move_caret_to_fc)gtk_graph_display_move_caret_to;
     panel_class->get_cursor = (get_cursor_fc)gtk_graph_display_get_cursor;
-    panel_class->set_cursor = (set_cursor_fc)gtk_graph_display_set_cursor;
     panel_class->cache_glance = (cache_glance_fc)gtk_graph_display_cache_glance;
 
 }
@@ -587,9 +583,9 @@ static gboolean gtk_graph_display_motion_notify(GtkWidget *widget, GdkEventMotio
 /******************************************************************************
 *                                                                             *
 *  Paramètres  : display = composant GTK à mettre à jour.                     *
-*                addr    = adresse sélectionnée de manière externe.           *
+*                cursor  = emplacement à présenter à l'écran.                 *
 *                                                                             *
-*  Description : Réagit à la sélection externe d'une adresse.                 *
+*  Description : Ajuste au besoin la zone affichée pour un curseur.           *
 *                                                                             *
 *  Retour      : -                                                            *
 *                                                                             *
@@ -597,8 +593,9 @@ static gboolean gtk_graph_display_motion_notify(GtkWidget *widget, GdkEventMotio
 *                                                                             *
 ******************************************************************************/
 
-static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, const vmpa2t *addr)
+static void gtk_graph_display_prepare_for_cursor(GtkGraphDisplay *display, const GLineCursor *cursor)
 {
+    vmpa2t addr;                            /* Adresse ciblée              */
     bool need_update;                       /* Mise à jour du contenu ?    */
     const mrange_t *range;                  /* Couverture courante         */
     GExeFormat *format;                     /* Type de fichier chargé      */
@@ -610,12 +607,16 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, cons
     gint bottom;                            /* Ordonnée du coin inférieur  */
     GtkWidget *child;                       /* Composant sélectionné       */
 
+    assert(G_IS_BINARY_CURSOR(cursor));
+
+    g_binary_cursor_get_info(G_BINARY_CURSOR(cursor), &addr);
+
     if (display->routine == NULL)
         need_update = true;
     else
     {
         range = g_binary_symbol_get_range(display->routine);
-        need_update = !mrange_contains_addr(range, addr);
+        need_update = !mrange_contains_addr(range, &addr);
     }
 
     if (need_update)
@@ -624,7 +625,7 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, cons
 
         format = g_loaded_binary_get_format(GTK_DISPLAY_PANEL(display)->binary);
 
-        found = g_binary_format_find_symbol_for(G_BIN_FORMAT(format), addr, &symbol);
+        found = g_binary_format_find_symbol_for(G_BIN_FORMAT(format), &addr, &symbol);
 
         if (!found)
             goto ggddma_done;
@@ -826,32 +827,6 @@ static GLineCursor *gtk_graph_display_get_cursor(const GtkGraphDisplay *display)
 
 /******************************************************************************
 *                                                                             *
-*  Paramètres  : display = composant GTK à mettre à jour.                     *
-*                cursor  = informations relatives à la position du curseur.   *
-*                                                                             *
-*  Description : Définit le position courante dans un panneau de chargement.  *
-*                                                                             *
-*  Retour      : -                                                            *
-*                                                                             *
-*  Remarques   : -                                                            *
-*                                                                             *
-******************************************************************************/
-
-static void gtk_graph_display_set_cursor(GtkGraphDisplay *display, const GLineCursor *cursor)
-{
-    vmpa2t addr;                            /* Adresse ciblée              */
-
-    assert(G_IS_BINARY_CURSOR(cursor));
-
-    g_binary_cursor_get_info(G_BINARY_CURSOR(cursor), &addr);
-
-    gtk_graph_display_define_main_address(display, &addr);
-
-}
-
-
-/******************************************************************************
-*                                                                             *
 *  Paramètres  : display = composant GTK à manipuler.                         *
 *                cr      = assistant pour la création de rendus.              *
 *                area    = taille de la surface réduite à disposition.        *
diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c
index 059a598..6bbd484 100644
--- a/src/gui/menus/view.c
+++ b/src/gui/menus/view.c
@@ -825,8 +825,6 @@ static void change_current_view_support(unsigned int wanted)
 
     if (cursor != NULL)
     {
-        g_loaded_panel_set_cursor(new, cursor);
-
         /**
          * A ce stade, le nouveau composant d'affichage n'a pas encore connu son
          * premier gtk_widget_size_allocate(). Cela viendra avec un événement ultérieur
-- 
cgit v0.11.2-87-g4458