summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-03-24 07:38:31 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-03-24 07:38:31 (GMT)
commitb7347c96930027fc11b9c5038157f972d58a41bf (patch)
tree182ddabae529e89b28db93acb3404cd7424086ed /src/gtkext
parent518ce6e1594ba80be4286bd3e561b0b7f73ce4b0 (diff)
Built routine digest for tooltip hints.
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/gtkbinarystrip.c4
-rw-r--r--src/gtkext/gtkblockdisplay.c113
2 files changed, 114 insertions, 3 deletions
diff --git a/src/gtkext/gtkbinarystrip.c b/src/gtkext/gtkbinarystrip.c
index d18a6ab..bc5a6ec 100644
--- a/src/gtkext/gtkbinarystrip.c
+++ b/src/gtkext/gtkbinarystrip.c
@@ -418,7 +418,9 @@ static gboolean gtk_binary_strip_query_tooltip(GtkWidget *widget, gint x, gint y
g_object_unref(G_OBJECT(format));
}
- else result = FALSE;
+
+ else
+ result = FALSE;
return result;
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. *
* *