summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkblockdisplay.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext/gtkblockdisplay.c')
-rw-r--r--src/gtkext/gtkblockdisplay.c113
1 files changed, 111 insertions, 2 deletions
diff --git a/src/gtkext/gtkblockdisplay.c b/src/gtkext/gtkblockdisplay.c
index 26dbada..9698ee5 100644
--- a/src/gtkext/gtkblockdisplay.c
+++ b/src/gtkext/gtkblockdisplay.c
@@ -25,6 +25,7 @@
#include "gtkbufferdisplay-int.h"
+#include "../arch/target.h"
@@ -62,6 +63,9 @@ static void gtk_block_display_finalize(GtkBlockDisplay *);
/* Assure la gestion des clics de souris sur le composant. */
static gboolean gtk_block_display_button_press(GtkWidget *, GdkEventButton *);
+/* Prépare l'affichage d'une astuce. */
+static gboolean gtk_block_display_query_tooltip(GtkWidget *, gint, gint, gboolean, GtkTooltip *);
+
/* Redessine l'affichage suite à un changement visuel. */
static gboolean gtk_block_display_need_redraw(GtkBlockDisplay *, GBufferView *);
@@ -104,6 +108,7 @@ static void gtk_block_display_class_init(GtkBlockDisplayClass *class)
widget_class = GTK_WIDGET_CLASS(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);
@@ -128,7 +133,7 @@ static void gtk_block_display_class_init(GtkBlockDisplayClass *class)
/******************************************************************************
* *
-* Paramètres : view = composant GTK à initialiser. *
+* Paramètres : display = composant GTK à initialiser. *
* *
* Description : Procède à l'initialisation de l'afficheur de bloc assembleur.*
* *
@@ -138,8 +143,13 @@ static void gtk_block_display_class_init(GtkBlockDisplayClass *class)
* *
******************************************************************************/
-static void gtk_block_display_init(GtkBlockDisplay *view)
+static void gtk_block_display_init(GtkBlockDisplay *display)
{
+ GObject *object; /* Autre version de l'instance */
+
+ object = G_OBJECT(display);
+
+ g_object_set(object, "has-tooltip", TRUE, NULL);
}
@@ -255,6 +265,105 @@ static gboolean gtk_block_display_button_press(GtkWidget *widget, GdkEventButton
/******************************************************************************
* *
+* Paramètres : widget = composant GTK visé par l'opération. *
+* x = abscisse de la position du message. *
+* y = ordonnée de la position du message. *
+* keyboard = indique une demande suite à obtiention du focus. *
+* tooltip = astuce à compléter. [OUT] *
+* *
+* Description : Prépare l'affichage d'une astuce. *
+* *
+* Retour : TRUE pour un affichage validé, FALSE sinon. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean gtk_block_display_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard, GtkTooltip *tooltip)
+{
+ gboolean result; /* Bilan à retourner */
+ GtkBlockDisplay *display; /* Autre version du composant */
+ GtkDisplayPanel *panel; /* Version racine du composant */
+ gint real_x; /* Abscisse absolue réelle */
+ gint real_y; /* Ordonnée absolue réelle */
+ GObject *creator; /* Origine du segment pointé */
+ GBinSymbol *symbol; /* Eventuel symbole survolé */
+ GTargetOperand *operand; /* Operande associé */
+ phys_t diff; /* Différence avec la base */
+ SymbolType stype; /* Type de symbole identifié */
+ GBinRoutine *routine; /* Routine à manipuler */
+ char *info; /* Information à faire paraître*/
+
+ if (keyboard) return FALSE;
+
+ result = FALSE;
+
+ display = GTK_BLOCK_DISPLAY(widget);
+ panel = GTK_DISPLAY_PANEL(display);
+
+ real_x = x;
+ real_y = y;
+ gtk_display_panel_compute_real_coord(panel, &real_x, &real_y);
+
+ creator = g_buffer_view_find_creator(GTK_BUFFER_DISPLAY(display)->view, real_x, real_y, panel->display);
+
+ if (creator != NULL)
+ {
+ symbol = NULL;
+
+ if (!G_IS_TARGET_OPERAND(creator))
+ goto gbdqt_done;
+
+ operand = G_TARGET_OPERAND(creator);
+
+ symbol = g_target_operand_get_symbol(operand, &diff);
+
+ if (symbol == NULL || diff != 0)
+ goto gbdqt_done;
+
+ stype = g_binary_symbol_get_target_type(symbol);
+
+ switch (stype)
+ {
+ case STP_ROUTINE:
+ case STP_ENTRY_POINT:
+
+ routine = g_binary_symbol_get_routine(symbol);
+
+ info = g_binary_routine_build_tooltip(routine, panel->binary);
+
+ //g_object_unref(G_OBJECT(routine));
+
+ result = (info != NULL);
+ break;
+
+ default:
+ break;
+
+ }
+
+ if (result)
+ {
+ gtk_tooltip_set_markup(tooltip, info);
+ free(info);
+ }
+
+ gbdqt_done:
+
+ if (symbol != NULL)
+ g_object_unref(G_OBJECT(symbol));
+
+ g_object_unref(creator);
+
+ }
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : display = composant GTK d'affichage. *
* view = composant GLib interne. *
* *