diff options
Diffstat (limited to 'src/gtkext/gtkgraphdisplay.c')
-rw-r--r-- | src/gtkext/gtkgraphdisplay.c | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/gtkext/gtkgraphdisplay.c b/src/gtkext/gtkgraphdisplay.c index 0915f3a..0865e04 100644 --- a/src/gtkext/gtkgraphdisplay.c +++ b/src/gtkext/gtkgraphdisplay.c @@ -27,11 +27,15 @@ #include <assert.h> +#include <i18n.h> + + #include "gtkblockdisplay.h" #include "gtkbufferdisplay.h" #include "gtkdisplaypanel-int.h" #include "graph/cluster.h" #include "../analysis/routine.h" +#include "../common/extstr.h" #include "../format/format.h" #include "../glibext/gbinarycursor.h" #include "../glibext/gloadedpanel.h" @@ -115,6 +119,9 @@ 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 *); +/* Prépare l'affichage d'une astuce. */ +static gboolean gtk_graph_display_query_tooltip(GtkWidget *, gint, gint, gboolean, GtkTooltip *, GtkGraphDisplay *); + /* Ajuste au besoin la zone affichée pour un curseur. */ static void gtk_graph_display_prepare_for_cursor(GtkGraphDisplay *, const GLineCursor *); @@ -213,6 +220,10 @@ static void gtk_graph_display_init(GtkGraphDisplay *display) G_CALLBACK(gtk_graph_display_button_release), display); g_signal_connect(G_OBJECT(display->support), "motion-notify-event", G_CALLBACK(gtk_graph_display_motion_notify), display); + g_signal_connect(G_OBJECT(display->support), "query-tooltip", + G_CALLBACK(gtk_graph_display_query_tooltip), display); + + g_object_set(G_OBJECT(display->support), "has-tooltip", TRUE, NULL); gtk_widget_add_events(display->support, GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -649,6 +660,66 @@ static gboolean gtk_graph_display_motion_notify(GtkWidget *widget, GdkEventMotio /****************************************************************************** * * +* 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] * +* display = support maître à consulter. * +* * +* Description : Prépare l'affichage d'une astuce. * +* * +* Retour : TRUE pour un affichage validé, FALSE sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_graph_display_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard, GtkTooltip *tooltip, GtkGraphDisplay *display) +{ + gboolean result; /* Bilan à retourner */ + GCodeBlock *src; /* Bloc d'origine du lien */ + GCodeBlock *dst; /* Bloc de destination du lien */ + char *info; /* Information à faire paraître*/ + char *desc; /* Description d'un bloc */ + + result = FALSE; + + if (display->hl_edge_index < display->edges_count) + { + g_graph_edge_get_boundaries(display->edges[display->hl_edge_index], &src, &dst); + + info = stradd(NULL, _("<b>Source:</b> ")); + + desc = g_code_block_build_tooltip(src); + info = stradd(info, desc); + free(desc); + + info = stradd(info, "\n\n"); + + info = stradd(info, _("<b>Destination:</b> ")); + + desc = g_code_block_build_tooltip(dst); + info = stradd(info, desc); + free(desc); + + gtk_tooltip_set_markup(tooltip, info); + free(info); + + g_object_unref(G_OBJECT(src)); + g_object_unref(G_OBJECT(dst)); + + result = TRUE; + + } + + return result; + +} + + +/****************************************************************************** +* * * Paramètres : display = composant GTK à mettre à jour. * * cursor = emplacement à présenter à l'écran. * * * |