From 7a009c76657478c9270acec0c2b236523bfd68eb Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 14 Jul 2018 17:03:49 +0200 Subject: Used abstract locations to scroll into displays. --- src/analysis/db/items/move.c | 10 +++++++++- src/gtkext/gtkbufferdisplay.c | 32 ++++++++------------------------ src/gtkext/gtkdisplaypanel-int.h | 4 ++-- src/gtkext/gtkdisplaypanel.c | 16 +++++++++------- src/gtkext/gtkdisplaypanel.h | 7 +++---- src/gtkext/gtkgraphdisplay.c | 12 ++++++------ src/gui/core/items.c | 11 ++++++++++- 7 files changed, 47 insertions(+), 45 deletions(-) diff --git a/src/analysis/db/items/move.c b/src/analysis/db/items/move.c index 6300a86..e0e726a 100644 --- a/src/analysis/db/items/move.c +++ b/src/analysis/db/items/move.c @@ -36,6 +36,7 @@ #include "../collection-int.h" #include "../item-int.h" #include "../../../gui/core/global.h" +#include "../../../glibext/gbinarycursor.h" // REMME #include "../../../gtkext/gtkdisplaypanel.h" @@ -437,7 +438,14 @@ static bool g_db_move_run(const GDbMove *move, const vmpa2t *addr) gboolean do_move_in_main_loop(move_params *p) { - gtk_display_panel_scroll_to_address(p->panel, &p->addr, SPT_CENTER); + GLineCursor *___tmp; + + ___tmp = g_binary_cursor_new(); + g_binary_cursor_update(G_BINARY_CURSOR(___tmp), &p->addr); + + gtk_display_panel_scroll_to_cursor(p->panel, ___tmp, SPT_CENTER); + + g_object_unref(G_OBJECT(___tmp)); return G_SOURCE_REMOVE; diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c index c09a1fe..ff651c8 100644 --- a/src/gtkext/gtkbufferdisplay.c +++ b/src/gtkext/gtkbufferdisplay.c @@ -74,8 +74,8 @@ static void gtk_buffer_display_adjust_scroll_value(GtkBufferDisplay *, GtkAdjust /* Indique la position courante du curseur. */ static const vmpa2t *gtk_buffer_display_get_caret_location(const GtkBufferDisplay *); -/* Indique la position d'affichage d'une adresse donnée. */ -static bool gtk_buffer_display_get_address_coordinates(const GtkBufferDisplay *, const vmpa2t *, gint *, gint *, ScrollPositionTweak); +/* Indique la position d'affichage d'un emplacement donné. */ +static bool gtk_buffer_display_get_cursor_coordinates(const GtkBufferDisplay *, const GLineCursor *, gint *, gint *, ScrollPositionTweak); /* Fournit l'élément actif lié à la position courante. */ GObject *gtk_buffer_display_get_active_object(const GtkBufferDisplay *); @@ -154,7 +154,7 @@ static void gtk_buffer_display_class_init(GtkBufferDisplayClass *class) panel_class->compute_inc = (compute_scroll_inc_fc)gtk_buffer_display_compute_scroll_inc; panel_class->adjust = (adjust_scroll_value_fc)gtk_buffer_display_adjust_scroll_value; panel_class->get_caret_loc = (get_caret_location_fc)gtk_buffer_display_get_caret_location; - panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_buffer_display_get_address_coordinates; + panel_class->get_coordinates = (get_coordinates_fc)gtk_buffer_display_get_cursor_coordinates; panel_class->get_active = (get_active_object_fc)gtk_buffer_display_get_active_object; panel_class->move_caret_to = (move_caret_to_fc)_gtk_buffer_display_move_caret_to; panel_class->cache_glance = (cache_glance_fc)gtk_buffer_display_cache_glance; @@ -478,7 +478,6 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve bool ctrl; /* Statut de la touche Contrôle*/ cairo_rectangle_int_t area; /* Emplacement de curseur #1 */ GLineCursor *cursor; /* Emplacement de curseur #2 */ - vmpa2t addr; /* Adresse du nouveau curseur */ bool status; /* Validité d'un déplacement */ switch (event->keyval) @@ -521,13 +520,8 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve if (status) { - //////////////////////// - g_binary_cursor_get_info(G_BINARY_CURSOR(cursor), &addr); - //g_object_unref(G_OBJECT(cursor)); - //////////////////////// - gtk_buffer_display_relocate_caret(display, &area, cursor); - _gtk_display_panel_scroll_to_address(panel, &addr, SPT_RAW, false); + _gtk_display_panel_scroll_to_cursor(panel, cursor, SPT_RAW, false); } else g_signal_emit_by_name(display, "reach-limit", dir); @@ -660,12 +654,12 @@ static const vmpa2t *gtk_buffer_display_get_caret_location(const GtkBufferDispla /****************************************************************************** * * * Paramètres : display = composant GTK à consulter. * -* addr = adresse à présenter à l'écran. * +* cursor = emplacement à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * * y = position verticale au sein du composant. [OUT] * * tweak = adaptation finale à effectuer. * * * -* Description : Indique la position d'affichage d'une adresse donnée. * +* Description : Indique la position d'affichage d'un emplacement donné. * * * * Retour : true si l'adresse fait partie du composant, false sinon. * * * @@ -673,28 +667,18 @@ static const vmpa2t *gtk_buffer_display_get_caret_location(const GtkBufferDispla * * ******************************************************************************/ -static bool gtk_buffer_display_get_address_coordinates(const GtkBufferDisplay *display, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak) +static bool gtk_buffer_display_get_cursor_coordinates(const GtkBufferDisplay *display, const GLineCursor *cursor, gint *x, gint *y, ScrollPositionTweak tweak) { bool result; /* Bilan à remonter */ bool need_code; /* Recherche plus raffinée */ GBufferCache *cache; /* Gestionnaire de lignes */ - GLineCursor *___tmp; int height; /* Hauteur allouée */ need_code = (tweak == SPT_BOTTOM); cache = g_buffer_view_get_cache(display->view); - - ___tmp = g_binary_cursor_new(); - g_binary_cursor_update(G_BINARY_CURSOR(___tmp), addr); - - - result = g_buffer_view_get_cursor_coordinates(display->view, ___tmp, need_code, x, y); - - - g_object_unref(G_OBJECT(___tmp)); - + result = g_buffer_view_get_cursor_coordinates(display->view, cursor, need_code, x, y); if (result) { diff --git a/src/gtkext/gtkdisplaypanel-int.h b/src/gtkext/gtkdisplaypanel-int.h index 7a60152..f940212 100644 --- a/src/gtkext/gtkdisplaypanel-int.h +++ b/src/gtkext/gtkdisplaypanel-int.h @@ -55,7 +55,7 @@ typedef void (* define_address_fc) (GtkDisplayPanel *, const vmpa2t *); typedef const vmpa2t * (* get_caret_location_fc) (const GtkDisplayPanel *); /* Indique la position d'affichage d'une adresse donnée. */ -typedef bool (* get_addr_coordinates_fc) (const GtkDisplayPanel *, const vmpa2t *, gint *, gint *, ScrollPositionTweak); +typedef bool (* get_coordinates_fc) (const GtkDisplayPanel *, const GLineCursor *, gint *, gint *, ScrollPositionTweak); /* Fournit l'élément actif lié à la position courante. */ typedef GObject * (* get_active_object_fc) (const GtkDisplayPanel *); @@ -106,7 +106,7 @@ struct _GtkDisplayPanelClass adjust_scroll_value_fc adjust; /* Réaction à un défilement */ define_address_fc define; /* Centrage sur une partie */ get_caret_location_fc get_caret_loc; /* Adresse du curseur */ - get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */ + 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 */ diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c index 2cb05ea..12a6af4 100644 --- a/src/gtkext/gtkdisplaypanel.c +++ b/src/gtkext/gtkdisplaypanel.c @@ -931,10 +931,10 @@ GObject *gtk_display_panel_get_active_object(const GtkDisplayPanel *panel) /****************************************************************************** * * -* Paramètres : panel = composant GTK à manipuler. * -* addr = adresse à présenter à l'écran. * -* tweak = adaptation finale à effectuer. * -* move = doit-on déplacer le curseur à l'adresse indiquée ? * +* Paramètres : panel = composant GTK à manipuler. * +* cursor = emplacement à présenter à l'écran. * +* tweak = adaptation finale à effectuer. * +* move = doit-on déplacer le curseur à l'adresse indiquée ? * * * * Description : S'assure qu'une adresse donnée est visible à l'écran. * * * @@ -944,7 +944,7 @@ GObject *gtk_display_panel_get_active_object(const GtkDisplayPanel *panel) * * ******************************************************************************/ -void _gtk_display_panel_scroll_to_address(GtkDisplayPanel *panel, const vmpa2t *addr, ScrollPositionTweak tweak, bool move) +void _gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *panel, const GLineCursor *cursor, ScrollPositionTweak tweak, bool move) { GtkWidget *parent; /* Support parent à valider */ gint x; /* Abscisse à garantir */ @@ -966,10 +966,12 @@ void _gtk_display_panel_scroll_to_address(GtkDisplayPanel *panel, const vmpa2t * 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); + */ - if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, addr, &x, &y, tweak)) + if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, cursor, &x, &y, tweak)) { viewport = gtk_widget_get_parent(GTK_WIDGET(panel)); @@ -1003,7 +1005,7 @@ void _gtk_display_panel_scroll_to_address(GtkDisplayPanel *panel, const vmpa2t * /* Déplacement du curseur */ - if (move && GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, addr, &x, &y, SPT_RAW)) + if (move && GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, cursor, &x, &y, SPT_RAW)) GTK_DISPLAY_PANEL_GET_CLASS(panel)->move_caret_to(panel, x, y); } diff --git a/src/gtkext/gtkdisplaypanel.h b/src/gtkext/gtkdisplaypanel.h index 82259e9..c060c39 100644 --- a/src/gtkext/gtkdisplaypanel.h +++ b/src/gtkext/gtkdisplaypanel.h @@ -29,6 +29,7 @@ #include "../analysis/binary.h" +#include "../glibext/glinecursor.h" @@ -82,11 +83,9 @@ const vmpa2t *gtk_display_panel_get_caret_location(const GtkDisplayPanel *); GObject *gtk_display_panel_get_active_object(const GtkDisplayPanel *); /* S'assure qu'une adresse donnée est visible à l'écran. */ -void _gtk_display_panel_scroll_to_address(GtkDisplayPanel *, const vmpa2t *, ScrollPositionTweak, bool); - -#define gtk_display_panel_scroll_to_address(p, a, t) _gtk_display_panel_scroll_to_address(p, a, t, true) - +void _gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *, const GLineCursor *, ScrollPositionTweak, bool); +#define gtk_display_panel_scroll_to_cursor(p, c, t) _gtk_display_panel_scroll_to_cursor(p, c, t, true) /* Demande à qui veut répondre un déplacement du curseur. */ void gtk_display_panel_request_move(GtkDisplayPanel *, const vmpa2t *); diff --git a/src/gtkext/gtkgraphdisplay.c b/src/gtkext/gtkgraphdisplay.c index 8c8e5da..0fe86ef 100644 --- a/src/gtkext/gtkgraphdisplay.c +++ b/src/gtkext/gtkgraphdisplay.c @@ -120,8 +120,8 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *, const vmpa2 /* Indique la position courante du curseur. */ static const vmpa2t *gtk_graph_display_get_caret_location(const GtkGraphDisplay *); -/* Indique la position d'affichage d'une adresse donnée. */ -static bool gtk_graph_display_get_address_coordinates(const GtkGraphDisplay *, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak); +/* Indique la position d'affichage d'un emplacement donné. */ +static bool gtk_graph_display_get_cursor_coordinates(const GtkGraphDisplay *, const GLineCursor *, gint *, gint *, ScrollPositionTweak); /* Déplace le curseur à un emplacement défini. */ static bool gtk_graph_display_move_caret_to(GtkGraphDisplay *, gint, gint); @@ -184,7 +184,7 @@ static void gtk_graph_display_class_init(GtkGraphDisplayClass *class) panel_class->define = (define_address_fc)gtk_graph_display_define_main_address; panel_class->get_caret_loc = (get_caret_location_fc)gtk_graph_display_get_caret_location; - panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_graph_display_get_address_coordinates; + 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; @@ -729,12 +729,12 @@ static const vmpa2t *gtk_graph_display_get_caret_location(const GtkGraphDisplay /****************************************************************************** * * * Paramètres : display = composant GTK à consulter. * -* addr = adresse à présenter à l'écran. * +* cursor = emplacement à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * * y = position verticale au sein du composant. [OUT] * * tweak = adaptation finale à effectuer. * * * -* Description : Indique la position d'affichage d'une adresse donnée. * +* Description : Indique la position d'affichage d'un emplacement donné. * * * * Retour : true si l'adresse fait partie du composant, false sinon. * * * @@ -742,7 +742,7 @@ static const vmpa2t *gtk_graph_display_get_caret_location(const GtkGraphDisplay * * ******************************************************************************/ -static bool gtk_graph_display_get_address_coordinates(const GtkGraphDisplay *display, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak) +static bool gtk_graph_display_get_cursor_coordinates(const GtkGraphDisplay *display, const GLineCursor *cursor, gint *x, gint *y, ScrollPositionTweak tweak) { /* TODO */ diff --git a/src/gui/core/items.c b/src/gui/core/items.c index a2320cd..fd78b41 100644 --- a/src/gui/core/items.c +++ b/src/gui/core/items.c @@ -140,6 +140,7 @@ static gboolean notify_view_panel_focus_change(GLoadedPanel *panel, GdkEventFocu static void start_moving_to_address_in_view_panel(GtkDisplayPanel *panel, const vmpa2t *addr, gpointer unused) { const vmpa2t *src; /* Position courante de curseur*/ + GLineCursor *___tmp; GDbMove *move; /* Déplacement à organiser */ GLoadedBinary *binary; /* Binaire en cours d'étude */ @@ -147,7 +148,15 @@ static void start_moving_to_address_in_view_panel(GtkDisplayPanel *panel, const /* S'il n'y a pas de passif, pas besoin d'historique */ if (src == NULL) - gtk_display_panel_scroll_to_address(panel, addr, SPT_CENTER); + { + ___tmp = g_binary_cursor_new(); + g_binary_cursor_update(G_BINARY_CURSOR(___tmp), addr); + + gtk_display_panel_scroll_to_cursor(panel, ___tmp, SPT_CENTER); + + g_object_unref(G_OBJECT(___tmp)); + + } else { -- cgit v0.11.2-87-g4458