diff options
Diffstat (limited to 'src/gtkext/gtkblockview.c')
-rw-r--r-- | src/gtkext/gtkblockview.c | 217 |
1 files changed, 136 insertions, 81 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c index a4f0d3e..2ea7ae2 100644 --- a/src/gtkext/gtkblockview.c +++ b/src/gtkext/gtkblockview.c @@ -36,8 +36,11 @@ #include "../analysis/exporter.h" #include "../common/dllist.h" #include "../glibext/delayed-int.h" +#include "../glibext/gcodebuffer.h" +#include "../glibext/gbuffersegment.h" + #ifndef _ # define _(str) str @@ -104,6 +107,7 @@ struct _GtkBlockView bool show_vaddress; /* Affichage des adresses ? */ bool show_code; /* Affichage du code brut ? */ + GBufferView *buffer_view; /* Code sous forme de texte */ GtkTextBuffer *buffer; /* Code sous forme de texte */ GtkTextLayout *layout; /* Disposition du texte */ @@ -114,6 +118,12 @@ struct _GtkBlockView const exe_format *format; /* Format du contenu bianire */ + + + GCodeBuffer *_buffer; /* Code sous forme de texte */ + + + }; struct _GtkBlockViewClass @@ -205,6 +215,10 @@ static void gtk_block_view_size_allocate(GtkWidget *widget, static gboolean gtk_block_view_button_press(GtkWidget *, GdkEventButton *event); + +/* Imprime d'éventuelles informations liées à une ligne. */ +static void gtk_block_view_draw_line_extra(GBufferLine *, GdkDrawable *, GdkGC *, gint, gint, void *); + /* Met à jour l'affichage de la vue sous forme de bloc. */ static gboolean gtk_block_view_expose(GtkWidget *, GdkEventExpose *); @@ -308,11 +322,16 @@ static void g_delayed_insertion_process(GDelayedInsertion *insertion, GtkExtStat vmpa_t start; /* Adresse de début de parcours*/ vmpa_t end; /* Adresse de fin de parcours */ guint id; /* Identifiant de statut */ + GRenderingOptions *options; /* Options de rendu */ GRenderingLine *iter; /* Boucle de parcours */ GtkTextIter pos; /* Point d'insertion */ - GtkTextMark *mark; /* Marquage de ligne associée */ + GBufferLine *line; /* Ligne de destination */ + //GtkTextMark *mark; /* Marquage de ligne associée */ vmpa_t done; /* Quantité déjà parcourue */ + clock_t _start, _end; + double cpu_time_used; + view = insertion->view; lines = GTK_BIN_VIEW(view)->lines; @@ -332,6 +351,10 @@ static void g_delayed_insertion_process(GDelayedInsertion *insertion, GtkExtStat id = gtk_extended_status_bar_push(statusbar, _("Inserting lines..."), true); + options = g_openida_binary_get_options(GTK_BIN_VIEW(view)->binary); + + _start = clock(); + for (iter = lines; iter != NULL; iter = g_rendering_line_get_next_iter(lines, iter, last)) @@ -339,8 +362,16 @@ static void g_delayed_insertion_process(GDelayedInsertion *insertion, GtkExtStat g_signal_connect(iter, "rendering-line-flags-changed", G_CALLBACK(gtk_block_view_update_margin), view); - gdk_threads_enter(); + //gdk_threads_enter(); + line = g_code_buffer_append_new_line(view->_buffer); + + g_content_exporter_to_buffer(G_CONTENT_EXPORTER(iter), line, options); + g_object_set_data(G_OBJECT(line), "line", iter); + + + +#if 0 if (iter != lines) gtk_text_buffer_insert_with_tags(view->buffer, &pos, "\n", 1, NULL); @@ -351,17 +382,33 @@ static void g_delayed_insertion_process(GDelayedInsertion *insertion, GtkExtStat g_content_exporter_add_to_gtk_buffer(G_CONTENT_EXPORTER(iter), view->rendering, view->buffer, &pos, insertion->lengths); +#endif + /* gdk_flush (); gdk_threads_leave(); + */ done = get_rendering_line_address(iter) + get_rendering_line_length(iter) - start; gtk_extended_status_bar_update_activity(statusbar, id, done * 1.0 / end); } + + _end = clock(); + + cpu_time_used = ((double) (_end - _start)) / (CLOCKS_PER_SEC / 1000); + + printf(" ### TEMPS passé ::: %g ms (pid = %d)\n", cpu_time_used, getpid()); + + gtk_extended_status_bar_remove(statusbar, id); + view->buffer_view = g_buffer_view_new(view->_buffer); + + g_buffer_view_define_extra_drawing(view->buffer_view, gtk_block_view_draw_line_extra, view); + + } @@ -550,6 +597,10 @@ static void gtk_block_view_init(GtkBlockView *view) } + + view->_buffer = g_code_buffer_new(); + + } @@ -568,16 +619,11 @@ static void gtk_block_view_init(GtkBlockView *view) static void gtk_block_view_realize(GtkWidget *widget) { GtkBinViewClass *parent_class; /* Version pure du parent */ - PangoFontDescription *font_desc; parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(widget))); GTK_WIDGET_CLASS(parent_class)->realize(widget); - font_desc = pango_font_description_from_string("mono 10"); - gtk_widget_modify_font(widget, font_desc); - pango_font_description_free(font_desc); - } @@ -596,8 +642,11 @@ static void gtk_block_view_realize(GtkWidget *widget) static void gtk_block_view_size_request(GtkWidget *widget, GtkRequisition *requisition) { - gtk_text_layout_get_size(GTK_BLOCK_VIEW(widget)->layout, - &requisition->width, &requisition->height); + g_buffer_view_get_size(GTK_BLOCK_VIEW(widget)->buffer_view, + &requisition->width, &requisition->height); + + printf(" === size req :: (%d ; %d)\n", + requisition->width, requisition->height); } @@ -637,7 +686,7 @@ static void gtk_block_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc if (view->hadjustment == NULL || view->vadjustment == NULL) return; - gtk_text_layout_get_size(GTK_BLOCK_VIEW(view)->layout, &width, &height); + g_buffer_view_get_size(GTK_BLOCK_VIEW(view)->buffer_view, &width, &height); gtk_bin_view_compute_allocation(view, &valloc); @@ -786,6 +835,74 @@ static void gtk_block_view_compute_real_coord(GtkBlockView *view, gint *x, gint /****************************************************************************** * * +* Paramètres : line = ligne de texte à manipuler. * +* drawable = surface de rendu où travailler. * +* gc = contexte graphique à utiliser pour les pinceaux. * +* x = abscisse du point d'impression décallé. * +* y = ordonnée du point d'impression décallé. * +* data = pointeur vers le composant GTK de support. * +* * +* Description : Imprime d'éventuelles informations liées à une ligne. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_block_view_draw_line_extra(GBufferLine *line, GdkDrawable *drawable, GdkGC *gc, gint x, gint y, void *data) +{ + GRenderingLine *rline; /* Ligne de rendu représentée */ + GtkBlockViewClass *class; /* Classe contenant les images */ + gint line_height; /* Hauteur d'une ligne */ + RenderingLineFlag flags; /* Propriétés de la ligne */ + int height; /* Hauteur de l'image */ + GdkPixbuf *pixbuf; /* Données utiles au dessin */ + + rline = G_RENDERING_LINE(g_object_get_data(G_OBJECT(line), "line")); + class = GTK_BLOCK_VIEW_GET_CLASS(data); + + line_height = g_buffer_view_get_line_height(GTK_BLOCK_VIEW(data)->buffer_view); + + flags = g_rendering_line_get_flags(rline); + + if (flags & RLF_RUNNING_BP) + pixbuf = class->stopped_pix; + + else if (flags & RLF_BREAK_POINT) + pixbuf = class->breakpoint_pix; + + else pixbuf = NULL; + + if (pixbuf != NULL) + { + height = gdk_pixbuf_get_height(pixbuf); + + gdk_draw_pixbuf(drawable, gc, pixbuf, 0, 0, x + 10, + y + (line_height - height) / 2, + gdk_pixbuf_get_width(pixbuf), height, + GDK_RGB_DITHER_NORMAL, 0, 0); + + } + + /* Le point d'entrée prime */ + if (flags & RLF_ENTRY_POINT) + { + pixbuf = class->entry_pix; + height = gdk_pixbuf_get_height(pixbuf); + + gdk_draw_pixbuf(drawable, gc, pixbuf, 0, 0, x + 10, + y + (line_height - height) / 2, + gdk_pixbuf_get_width(pixbuf), height, + GDK_RGB_DITHER_NORMAL, 0, 0); + + } + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à redessiner. * * event = informations liées à l'événement. * * * @@ -802,33 +919,18 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event) GtkBlockView *view; /* Autre version du composant */ GtkBinView *bview; /* Autre version du composant */ GtkStyle *style; /* Style associé au composant */ + GdkDrawable *drawable; /* Surface de dessin */ gint fake_x; /* Abscisse virtuelle */ gint fake_y; /* Ordonnée virtuelle */ GtkBinViewClass *parent_class; /* Version pure du parent */ - GtkTextIter iter; /* Point d'insertion */ - GdkRectangle rect; /* Zone d'un point */ - GtkTextMark *mark; /* Marquage de ligne associée */ - GRenderingLine *line; /* Ligne de rendu */ - RenderingLineFlag flags; /* Propriétés de la ligne */ - GdkPixbuf *pixbuf; /* Données utiles au dessin */ - - - //GdkGCValues values; /* Propriétés du contexte */ - //GdkColor white; /* Couleur du fond */ - //int width; /* Largeur de l'élément */ - //int height; /* Hauteur de l'élément */ - //int y; /* Ordonnée du haut d'une ligne*/ - //GRenderingLine *iter; /* Boucle de parcours */ - - - GList *child_exposes; view = GTK_BLOCK_VIEW(widget); - widget = GTK_WIDGET(view); bview = GTK_BIN_VIEW(widget); - gdk_window_begin_paint_region(GDK_DRAWABLE(widget->window), event->region); + drawable = GDK_DRAWABLE(event->window); + + gdk_window_begin_paint_region(drawable, event->region); gdk_gc_set_clip_region(bview->gc, event->region); @@ -842,12 +944,12 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event) gdk_gc_set_foreground(bview->gc, &style->mid[GTK_WIDGET_STATE(widget)]); - gdk_draw_rectangle(GDK_DRAWABLE(widget->window), bview->gc, TRUE, + gdk_draw_rectangle(drawable, bview->gc, TRUE, fake_x, event->area.y, view->left_margin, event->area.y + event->area.height); gdk_gc_set_foreground(bview->gc, &style->dark[GTK_WIDGET_STATE(widget)]); - gdk_draw_line(GDK_DRAWABLE(widget->window), bview->gc, + gdk_draw_line(drawable, bview->gc, fake_x + view->left_margin, event->area.y, fake_x + view->left_margin, event->area.y + event->area.height); @@ -857,58 +959,11 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event) GTK_WIDGET_CLASS(parent_class)->expose_event(widget, event); - /* Informations individuelles des lignes */ - - gtk_text_layout_get_line_at_y(view->layout, &iter, fake_y, NULL); - gtk_text_layout_get_iter_location(view->layout, &iter, &rect); - - while (rect.y < (fake_y + event->area.height)) - { - gtk_block_view_compute_real_coord(view, &rect.x, &rect.y); - - mark = gtk_text_iter_get_marks(&iter)->data; - - line = g_object_get_data(G_OBJECT(mark), "line"); - if (line == NULL) break; - - flags = g_rendering_line_get_flags(line); - - if (flags & RLF_RUNNING_BP) - pixbuf = GTK_BLOCK_VIEW_GET_CLASS(view)->stopped_pix; - - else if (flags & RLF_BREAK_POINT) - pixbuf = GTK_BLOCK_VIEW_GET_CLASS(view)->breakpoint_pix; - - else pixbuf = NULL; - - if (pixbuf != NULL) - gdk_draw_pixbuf(GDK_DRAWABLE(widget->window), bview->gc, pixbuf, 0, 0, fake_x + 10, rect.y, - gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), - GDK_RGB_DITHER_NORMAL, 0, 0); - - /* Le point d'entrée prime */ - if (flags & RLF_ENTRY_POINT) - { - pixbuf = GTK_BLOCK_VIEW_GET_CLASS(view)->entry_pix; - - gdk_draw_pixbuf(GDK_DRAWABLE(widget->window), bview->gc, pixbuf, 0, 0, fake_x + 10, rect.y, - gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf), - GDK_RGB_DITHER_NORMAL, 0, 0); - - } - - if (!gtk_text_layout_move_iter_to_next_line(view->layout, &iter)) break; - gtk_text_layout_get_iter_location(view->layout, &iter, &rect); - - } - /* Impression du désassemblage */ - gtk_text_layout_draw(GTK_BLOCK_VIEW(bview)->layout, widget, GDK_DRAWABLE(widget->window), - NULL, -fake_x + view->left_text, fake_y, event->area.x, event->area.y, - event->area.width, event->area.height, &child_exposes); + g_buffer_view_draw(view->buffer_view, event, bview->gc, fake_x, fake_y); - gdk_window_end_paint(GDK_DRAWABLE(widget->window)); + gdk_window_end_paint(drawable); return TRUE; @@ -1160,7 +1215,7 @@ void gtk_block_view_recompute_size_request(GtkBlockView *view) gint width; /* Largeur de l'objet actuelle */ gint height; /* Hauteur de l'objet actuelle */ - gtk_text_layout_get_size(view->layout, &width, &height); + g_buffer_view_get_size(view->buffer_view, &width, &height); width += -view->left_text + 1; height += 1; |