diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-09-27 21:48:32 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-09-27 21:48:32 (GMT) |
commit | fa83bc71888fed39bcc77ad610ffd6f6980444f8 (patch) | |
tree | 38144f021e53bc5bfcf163002191076ef4766794 /src/gtkext/gtkblockview.c | |
parent | f32b173243cf46f8a9cf84b610139b3d4bd20803 (diff) |
Selected segments for highlighting.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@264 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/gtkblockview.c')
-rw-r--r-- | src/gtkext/gtkblockview.c | 85 |
1 files changed, 84 insertions, 1 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index 398856f..e026cbe 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -52,6 +52,12 @@ static void gtk_block_view_class_init(GtkBlockViewClass *); /* Procède à l'initialisation de l'afficheur de bloc assembleur. */ static void gtk_block_view_init(GtkBlockView *); +/* Assure la gestion des clics de souris sur le composant. */ +static gboolean gtk_block_view_button_press_event(GtkBlockView *, GdkEventButton *, gpointer); + +/* Redessine l'affichage suite à un changement visuel. */ +static gboolean gtk_block_view_need_redraw(GBufferView *, GtkBlockView *); + /* Prend acte de l'association d'un binaire chargé. */ static void gtk_block_view_attach_binary(GtkBlockView *, GLoadedBinary *, bool *, bool *); @@ -104,6 +110,9 @@ static void gtk_block_view_init(GtkBlockView *view) panel->attach = (attach_binary_fc)gtk_block_view_attach_binary; + g_signal_connect(G_OBJECT(view), "button_press_event", + G_CALLBACK(gtk_block_view_button_press_event), NULL); + } @@ -132,6 +141,75 @@ GtkWidget *gtk_block_view_new(void) /****************************************************************************** * * +* Paramètres : view = composant GTK visé par l'opération. * +* event = informations liées à l'événement. * +* data = donnée non utilisée ici. * +* * +* Description : Assure la gestion des clics de souris sur le composant. * +* * +* Retour : FALSE pour poursuivre la propagation de l'événement. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_block_view_button_press_event(GtkBlockView *view, GdkEventButton *event, gpointer data) +{ + GtkBufferView *bview; /* Autre vision du composant */ + gint real_x; /* Abscisse absolue réelle */ + gint real_y; /* Ordonnée absolue réelle */ + + if (event->type == GDK_2BUTTON_PRESS) + { + + + + printf("I feel %s clicked with button %d\n", + event->type == GDK_2BUTTON_PRESS ? "double" : "triple", + event->button); + + bview = GTK_BUFFER_VIEW(view); + + real_x = event->x; + real_y = event->y; + + gtk_buffer_view_compute_real_coord(bview, &real_x, &real_y); + + g_buffer_view_highlight_segments(gtk_buffer_view_get_buffer(bview), real_x, real_y); + + + + } + + return FALSE; + +} + + +/****************************************************************************** +* * +* Paramètres : view = composant GLib interne. * +* block = composant GTK d'affichage. * +* * +* Description : Redessine l'affichage suite à un changement visuel. * +* * +* Retour : FALSE pour poursuivre la propagation de l'événement. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_block_view_need_redraw(GBufferView *view, GtkBlockView *block) +{ + gtk_widget_queue_draw(GTK_WIDGET(block)); + + return FALSE; + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à mettre à jour. * * binary = binaire associé à intégrer. * * addr = indique si les positions doivent être affichées. * @@ -148,9 +226,14 @@ GtkWidget *gtk_block_view_new(void) static void gtk_block_view_attach_binary(GtkBlockView *view, GLoadedBinary *binary, bool *addr, bool *code) { GCodeBuffer *buffer; /* Tampon par défaut */ + GBufferView *bview; /* Vue sur ce même tampon */ buffer = g_loaded_binary_get_disassembled_buffer(binary); + bview = g_buffer_view_new(buffer); + + gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), bview, addr, code); - gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), g_buffer_view_new(buffer), addr, code); + g_signal_connect(G_OBJECT(bview), "need-redraw", + G_CALLBACK(gtk_block_view_need_redraw), view); } |