summaryrefslogtreecommitdiff
path: root/src/gtkext/gtkblockview.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2010-12-20 00:28:36 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2010-12-20 00:28:36 (GMT)
commit56deaf395c65658102ef0111cfc072d65335331a (patch)
treeba6d6fd0dbc781e9ad3b3cf6b2eb529a7d7a6aa3 /src/gtkext/gtkblockview.c
parentd9fdfcf887a7a596a68db2500bb5e4d0b692abb6 (diff)
Begun to clean the code by moving the disassembling process into disass/.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@202 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gtkext/gtkblockview.c')
-rw-r--r--src/gtkext/gtkblockview.c1039
1 files changed, 34 insertions, 1005 deletions
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c
index acce2d6..1964ea5 100644
--- a/src/gtkext/gtkblockview.c
+++ b/src/gtkext/gtkblockview.c
@@ -24,266 +24,53 @@
#include "gtkblockview.h"
-#include <malloc.h>
-#include <string.h>
-
-
-#include "gtkbinview-int.h"
-#include "support.h"
-#include "../analysis/exporter.h"
-#include "../common/dllist.h"
-#include "../glibext/delayed-int.h"
-#include "../glibext/gcodebuffer.h"
-
-
-
-
-#ifndef _
-# define _(str) str
-#endif
-
-
-static void gtk_block_view_compute_real_coord(GtkBlockView *view, gint *x, gint *y);
-
-
-
-
-/* -------------------------- INSERTION DIFFEREE DE LIGNES -------------------------- */
-
-
-#define G_TYPE_DELAYED_INSERTION g_delayed_insertion_get_type()
-#define G_DELAYED_INSERTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_delayed_insertion_get_type(), GDelayedInsertion))
-#define G_IS_DELAYED_INSERTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_delayed_insertion_get_type()))
-#define G_DELAYED_INSERTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DELAYED_INSERTION, GDelayedInsertionClass))
-#define G_IS_DELAYED_INSERTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DELAYED_INSERTION))
-#define G_DELAYED_INSERTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DELAYED_INSERTION, GDelayedInsertionClass))
-
-
-/* Ensembles binaires à désassembler (instance) */
-typedef struct _GDelayedInsertion
-{
- GDelayedWork parent; /* A laisser en premier */
-
- GtkBlockView *view; /* Visualisation à constituer */
-
-} GDelayedInsertion;
-
-/* Ensembles binaires à désassembler (classe) */
-typedef struct _GDelayedInsertionClass
-{
- GDelayedWorkClass parent; /* A laisser en premier */
-
-} GDelayedInsertionClass;
-
-
-/* Indique le type défini pour les tâches d'insertions différées. */
-static GType g_delayed_insertion_get_type(void);
-
-/* Initialise la classe des tâches d'insertions différées. */
-static void g_delayed_insertion_class_init(GDelayedInsertionClass *);
-
-/* Initialise une tâche d'insertions différées. */
-static void g_delayed_insertion_init(GDelayedInsertion *);
-
-/* Crée une tâche d'insertions différées. */
-static GDelayedInsertion *g_delayed_insertion_new(GtkBlockView *);
-
-/* Assure des insertion de lignes en différé. */
-static void g_delayed_insertion_process(GDelayedInsertion *, GtkExtStatusBar *);
+#include "gtkbufferview-int.h"
+/* -------------------------- INTERACTION DIRECTE AVEC GTK -------------------------- */
+/* Composant d'affichage de bloc d'assembleur (instance) */
struct _GtkBlockView
{
- GtkBinView parent; /* A laisser en premier */
-
- MainRendering rendering; /* Support final des lignes */
-
- bool show_vaddress; /* Affichage des adresses ? */
- bool show_code; /* Affichage du code brut ? */
-
- GBufferView *buffer_view; /* Code sous forme de texte */
-
- gint line_height; /* Hauteur maximale des lignes */
- gint left_margin; /* Marge gauche + espace */
- gint left_text; /* Début d'impression du code */
-
-
- const exe_format *format; /* Format du contenu bianire */
-
-
-
- GCodeBuffer *_buffer; /* Code sous forme de texte */
-
-
+ GtkBufferView parent; /* A laisser en premier */
};
+/* Composant d'affichage de code d'assembleur (classe) */
struct _GtkBlockViewClass
{
- GtkBinViewClass parent; /* A laisser en premier */
-
- GdkPixbuf *entry_pix; /* Image du point d'entrée */
- GdkPixbuf *breakpoint_pix; /* Image de point d'arrêt */
- GdkPixbuf *stopped_pix; /* Image de point actif */
+ GtkBufferViewClass parent; /* A laisser en premier */
};
+/* Procède à l'initialisation des afficheurs de bloc assembleur. */
+static void gtk_block_view_class_init(GtkBlockViewClass *);
-
-
-
-
-/* Procède à l'initialisation de l'afficheur d'un bloc binaire. */
+/* Procède à l'initialisation de l'afficheur de bloc assembleur. */
static void gtk_block_view_init(GtkBlockView *);
-/* Encadre la construction graphique initiale de la visualisation. */
-static void gtk_block_view_realize(GtkWidget *);
-
-/* Fournit la taille de composant requise pour un plein rendu. */
-static void gtk_block_view_size_request(GtkWidget *, GtkRequisition *);
-
-/* S'adapte à la surface concédée par le composant parent. */
-static void gtk_block_view_size_allocate(GtkWidget *, GtkAllocation *);
-
-
-
-
-/* Réagit à un défilement quelconque. */
-static void gtk_block_view_scroll(GtkBlockView *);
-
-/* Définit les lignes du bloc de représentation. */
-static void gtk_block_view_set_rendering_lines(GtkBlockView *, GRenderingLine *, GRenderingLine *);
-
-/* Achève la construction de la visualisation des lignes. */
-static void gtk_block_view_complete_building_content(GDelayedInsertion *, GtkBlockView *);
-
-
-
-
-
-/* Redessine l'affichage suite une mise à jour dans la marge. */
-void gtk_block_view_update_margin(GRenderingLine *, GtkBlockView *);
-
-
-
-
-
-/* Réclame une nouvelle taille adaptée au contenu présent. */
-void gtk_block_view_recompute_size_request(GtkBlockView *);
-
-
-
-
-/* Indique la position d'affichage d'une adresse donnée. */
-static bool gtk_block_view_get_address_coordinates(const GtkBlockView *, vmpa_t, gint *, gint *);
-
-
-
-
-
-static void gtk_block_view_class_init(GtkBlockViewClass *klass);
-static void gtk_block_view_size_allocate(GtkWidget *widget,
- GtkAllocation *allocation);
-
-
-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 *);
-
-
-
-static void gtk_block_view_destroy(GtkObject *object);
-
-
+/* Prend acte de l'association d'un binaire chargé. */
+static void gtk_block_view_attach_binary(GtkBlockView *, GOpenidaBinary *);
/* ---------------------------------------------------------------------------------- */
-/* INSERTION DIFFEREE DE LIGNES */
+/* INTERACTION DIRECTE AVEC GTK */
/* ---------------------------------------------------------------------------------- */
-/* Indique le type défini pour les tâches d'insertions différées. */
-G_DEFINE_TYPE(GDelayedInsertion, g_delayed_insertion, G_TYPE_DELAYED_WORK);
-
-
-/******************************************************************************
-* *
-* Paramètres : klass = classe à initialiser. *
-* *
-* Description : Initialise la classe des tâches d'insertions différées. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_delayed_insertion_class_init(GDelayedInsertionClass *klass)
-{
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : insertion = instance à initialiser. *
-* *
-* Description : Initialise une tâche d'insertions différées. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void g_delayed_insertion_init(GDelayedInsertion *insertion)
-{
- G_DELAYED_WORK(insertion)->run = (run_task_fc)g_delayed_insertion_process;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = visualisation de lignes à constituer. *
-* *
-* Description : Crée une tâche d'insertions différées. *
-* *
-* Retour : Tâche créée. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static GDelayedInsertion *g_delayed_insertion_new(GtkBlockView *view)
-{
- GDelayedInsertion *result; /* Tâche à retourner */
-
- result = g_object_new(G_TYPE_DELAYED_INSERTION, NULL);
-
- result->view = view;
-
- return result;
-
-}
+/* Détermine le type du composant d'affichage de bloc en langage d'assemblage. */
+G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BUFFER_VIEW)
/******************************************************************************
* *
-* Paramètres : insertion = insertions de lignes à mener. *
-* statusbar = barre de statut à tenir informée. *
+* Paramètres : class = classe GTK à initialiser. *
* *
-* Description : Assure des insertion de lignes en différé. *
+* Description : Procède à l'initialisation des afficheurs de bloc assembleur.*
* *
* Retour : - *
* *
@@ -291,177 +78,8 @@ static GDelayedInsertion *g_delayed_insertion_new(GtkBlockView *view)
* *
******************************************************************************/
-static void g_delayed_insertion_process(GDelayedInsertion *insertion, GtkExtStatusBar *statusbar)
-{
- GtkBlockView *view; /* Visualisation à constituer */
- GRenderingLine *lines; /* Liste de lignes à intégrer */
- GRenderingLine *last; /* Dernière ligne ou NULL */
- 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 */
- GBufferLine *line; /* Ligne de destination */
- vmpa_t done; /* Quantité déjà parcourue */
-
- clock_t _start, _end;
- double cpu_time_used;
-
- view = insertion->view;
-
- lines = GTK_BIN_VIEW(view)->lines;
- last = GTK_BIN_VIEW(view)->last;
-
- if (lines == NULL) return;
-
- iter = g_rendering_line_loop_for_code(lines, last);
- start = get_rendering_line_address(lines);
-
- iter = g_rendering_line_get_last_iter(lines, last);
- end = get_rendering_line_address(iter) + get_rendering_line_length(iter) - start;
-
- 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))
- {
- g_signal_connect(iter, "rendering-line-flags-changed",
- G_CALLBACK(gtk_block_view_update_margin), view);
-
- //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);
-
-
- /*
- 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);
-
-
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/* Détermine le type du composant d'affichage en block. */
-G_DEFINE_TYPE(GtkBlockView, gtk_block_view, GTK_TYPE_BIN_VIEW)
-
-
-/******************************************************************************
-* *
-* Paramètres : rendering = support effectif des lignes au final. *
-* *
-* Description : Crée un nouveau composant pour l'affichage en block. *
-* *
-* Retour : Composant GTK créé. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GtkWidget * gtk_block_view_new(MainRendering rendering)
-{
- GtkBlockView *result;
-
- result = gtk_type_new(gtk_block_view_get_type());
-
- result->rendering = rendering;
-
- return GTK_WIDGET(result);
-
-}
-
-
-
-static void gtk_block_view_class_init(GtkBlockViewClass *klass)
+static void gtk_block_view_class_init(GtkBlockViewClass *class)
{
- GtkWidgetClass *widget_class; /* Classe version Widget */
- GtkObjectClass *object_class;
-
- gchar *filename; /* Fichier d'image à charger */
-
- widget_class = (GtkWidgetClass *) klass;
- object_class = (GtkObjectClass *) klass;
-
-
- widget_class->button_press_event = gtk_block_view_button_press;
- widget_class->realize = gtk_block_view_realize;
- widget_class->size_request = gtk_block_view_size_request;
- widget_class->size_allocate = gtk_block_view_size_allocate;
- widget_class->expose_event = gtk_block_view_expose;
-
- object_class->destroy = gtk_block_view_destroy;
-
-
-
- /* Image de la marge gauche */
-
- filename = find_pixmap_file("entry.png");
-
- if (filename == NULL) klass->entry_pix = NULL;
- else
- {
- klass->entry_pix = gdk_pixbuf_new_from_file(filename, NULL);
- g_free(filename);
- }
-
- filename = find_pixmap_file("breakpoint.png");
-
- if (filename == NULL) klass->breakpoint_pix = NULL;
- else
- {
- klass->breakpoint_pix = gdk_pixbuf_new_from_file(filename, NULL);
- g_free(filename);
- }
-
- filename = find_pixmap_file("stopped.png");
-
- if (filename == NULL) klass->stopped_pix = NULL;
- else
- {
- klass->stopped_pix = gdk_pixbuf_new_from_file(filename, NULL);
- g_free(filename);
- }
}
@@ -470,7 +88,7 @@ static void gtk_block_view_class_init(GtkBlockViewClass *klass)
* *
* Paramètres : view = composant GTK à initialiser. *
* *
-* Description : Procède à l'initialisation de l'afficheur d'un bloc binaire. *
+* Description : Procède à l'initialisation de l'afficheur de bloc assembleur.*
* *
* Retour : - *
* *
@@ -480,518 +98,44 @@ static void gtk_block_view_class_init(GtkBlockViewClass *klass)
static void gtk_block_view_init(GtkBlockView *view)
{
- GtkViewPanel *viewpanel; /* Instance parente #1 */
- GtkBinView *binview; /* Instance parente #2 */
-
- viewpanel = GTK_VIEW_PANEL(view);
-
- viewpanel->scroll = (scroll_fc)gtk_block_view_scroll;
-
- binview = GTK_BIN_VIEW(view);
-
- binview->set_lines = (set_rendering_lines_fc)gtk_block_view_set_rendering_lines;
- binview->get_coordinates = (get_addr_coordinates_fc)gtk_block_view_get_address_coordinates;
-
- view->_buffer = g_code_buffer_new();
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : widget = composant GTK à redessiner. *
-* *
-* Description : Encadre la construction graphique initiale de la visualisat°.*
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_realize(GtkWidget *widget)
-{
- GtkBinViewClass *parent_class; /* Version pure du parent */
-
- parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(widget)));
-
- GTK_WIDGET_CLASS(parent_class)->realize(widget);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : widget = composant GTK à consulter. *
-* requisition = dimensions souhaitées. [OUT] *
-* *
-* Description : Fournit la taille de composant requise pour un plein rendu. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_size_request(GtkWidget *widget, GtkRequisition *requisition)
-{
- 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);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* allocation = étendue accordée à la vue. *
-* *
-* Description : S'adapte à la surface concédée par le composant parent. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
-{
- GtkViewPanel *panel; /* Autre version du composant */
- gint width; /* Largeur de l'objet actuelle */
- gint height; /* Hauteur de l'objet actuelle */
- GtkAllocation valloc; /* Surface utilisable */
- gboolean changed; /* Changement de valeur ? */
-
- /* Mise à jour GTK */
-
- widget->allocation = *allocation;
-
- if (GTK_WIDGET_REALIZED(widget))
- gdk_window_move_resize(widget->window,
- allocation->x, allocation->y,
- allocation->width, allocation->height);
-
- panel = GTK_VIEW_PANEL(widget);
-
- if (panel->hadjustment == NULL || panel->vadjustment == NULL)
- return;
-
- g_buffer_view_get_size(GTK_BLOCK_VIEW(widget)->buffer_view, &width, &height);
-
- gtk_view_panel_compute_allocation(panel, &valloc);
-
- /* Défilement horizontal */
-
- panel->hadjustment->page_size = valloc.width;
- panel->hadjustment->step_increment = valloc.width * 0.1;
- panel->hadjustment->page_increment = valloc.width * 0.9;
-
- panel->hadjustment->upper = MAX(width, valloc.width);
-
- gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed);
-
- gtk_adjustment_changed(panel->hadjustment);
-
- if (changed)
- gtk_adjustment_value_changed(panel->hadjustment);
-
- /* Défilement vertical */
-
- panel->vadjustment->page_size = valloc.height;
- panel->vadjustment->step_increment = GTK_BLOCK_VIEW(widget)->line_height;
- panel->vadjustment->page_increment = panel->vadjustment->step_increment * 10.0;
-
- panel->vadjustment->upper = MAX(height, valloc.height);
-
- gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed);
-
- gtk_adjustment_changed(panel->vadjustment);
-
- if (changed)
- gtk_adjustment_value_changed(panel->vadjustment);
-
-}
-
-
-
-
-static gboolean gtk_block_view_button_press(GtkWidget *widget, GdkEventButton *event)
-{
- gboolean result; /* Décision à retourner */
- GtkBlockView *view; /* Composant GTK réel */
- gint real_x; /* Abscisse réelle du point */
- gint real_y; /* Ordonnée réelle du point */
- GBufferLine *bline; /* Ligne intégrée au tampon */
- GRenderingLine *line; /* Ligne de rendu interne */
-
- result = FALSE;
-
- view = GTK_BLOCK_VIEW(widget);
-
- real_x = event->x;
- real_y = event->y;
- gtk_block_view_compute_real_coord(view, &real_x, &real_y);
-
- /* Clic dans la marge */
- if (event->type == GDK_BUTTON_PRESS && real_x < view->left_margin)
- {
- bline = g_buffer_view_find_line_at(view->buffer_view, real_y);
-
- if (bline != NULL)
- {
- line = G_RENDERING_LINE(g_object_get_data(G_OBJECT(bline), "line"));
-
- g_openida_binary_toggle_breakpoint(GTK_BIN_VIEW(view)->binary,
- get_rendering_line_address(line));
-
- result = TRUE;
-
- }
-
- }
-
- return result;
-
-}
-
-
-
-/******************************************************************************
-* *
-* Paramètres : line = ligne dont un drapeau a évolué. *
-* view = composant GTK à mettre à jour. *
-* *
-* Description : Redessine l'affichage suite une mise à jour dans la marge. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void gtk_block_view_update_margin(GRenderingLine *line, GtkBlockView *view)
-{
-
-
- /* TODO : à améliorer ! */
- gtk_widget_queue_draw(GTK_WIDGET(view));
-
-
-
-
-}
-
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à redessiner. *
-* event = informations liées à l'événement. *
-* *
-* Description : Met à jour l'affichage de la vue sous forme de bloc. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_compute_fake_coord(GtkBlockView *view, gint *x, gint *y)
-{
- if (GTK_VIEW_PANEL(view)->hadjustment != NULL)
- *x -= gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->hadjustment);
-
- if (GTK_VIEW_PANEL(view)->vadjustment != NULL)
- *y += gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->vadjustment);
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à redessiner. *
-* event = informations liées à l'événement. *
-* *
-* Description : Met à jour l'affichage de la vue sous forme de bloc. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_compute_real_coord(GtkBlockView *view, gint *x, gint *y)
-{
- if (x != NULL && GTK_VIEW_PANEL(view)->hadjustment != NULL)
- *x += gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->hadjustment);
-
- if (y != NULL && GTK_VIEW_PANEL(view)->vadjustment != NULL)
- *y += gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->vadjustment);
-
-}
-
-
-/******************************************************************************
-* *
-* 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. *
-* *
-* Description : Met à jour l'affichage de la vue sous forme de bloc. *
-* *
-* Retour : FALSE pour poursuivre la propagation de l'événement. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
-{
- GtkBlockView *view; /* Autre version du composant */
- GtkViewPanel *pview; /* 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 */
-
- view = GTK_BLOCK_VIEW(widget);
- widget = GTK_WIDGET(view);
- pview = GTK_VIEW_PANEL(widget);
-
- drawable = GDK_DRAWABLE(event->window);
-
- gdk_window_begin_paint_region(drawable, event->region);
-
- gdk_gc_set_clip_region(pview->gc, event->region);
-
- style = gtk_widget_get_style(GTK_WIDGET(view));
-
- fake_x = 0;
- fake_y = 0;
- gtk_block_view_compute_fake_coord(view, &fake_x, &fake_y);
-
- /* Dessin de la marge gauche */
-
- gdk_gc_set_foreground(pview->gc, &style->mid[GTK_WIDGET_STATE(widget)]);
-
- gdk_draw_rectangle(drawable, pview->gc, TRUE,
- fake_x, event->area.y, view->left_margin, event->area.y + event->area.height);
-
- gdk_gc_set_foreground(pview->gc, &style->dark[GTK_WIDGET_STATE(widget)]);
-
- gdk_draw_line(drawable, pview->gc,
- fake_x + view->left_margin, event->area.y,
- fake_x + view->left_margin, event->area.y + event->area.height);
-
- /* Eventuelle bordure globale */
-
- parent_class = GTK_BIN_VIEW_CLASS(g_type_class_peek_parent(GTK_BLOCK_VIEW_GET_CLASS(view)));
-
- GTK_WIDGET_CLASS(parent_class)->expose_event(widget, event);
-
- /* Impression du désassemblage */
-
- g_buffer_view_draw(view->buffer_view, event, pview->gc, fake_x, fake_y);
-
- gdk_window_end_paint(drawable);
-
- return TRUE;
-
-}
-
-
-
-
-static void
-gtk_block_view_destroy(GtkObject *object)
-{
- GtkBlockView *cpu;
- GtkBlockViewClass *klass;
-
- g_return_if_fail(object != NULL);
- g_return_if_fail(GTK_IS_BLOCK_VIEW(object));
+ GtkViewPanel *panel; /* Instance parente */
- cpu = GTK_BLOCK_VIEW(object);
+ panel = GTK_VIEW_PANEL(view);
- klass = gtk_type_class(gtk_widget_get_type());
+ panel->attach = (attach_binary_fc)gtk_block_view_attach_binary;
- if (GTK_OBJECT_CLASS(klass)->destroy) {
- (* GTK_OBJECT_CLASS(klass)->destroy) (object);
- }
}
-
-
-
-
/******************************************************************************
* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* show = état de l'affichage auquel parvenir. *
+* Paramètres : - *
* *
-* Description : Choisit d'afficher les adresses virtuelles ou non. *
+* Description : Crée un nouveau composant pour l'affichage de bloc en ASM. *
* *
-* Retour : - *
+* Retour : Composant GTK créé. *
* *
* Remarques : - *
* *
******************************************************************************/
-void gtk_block_view_show_vaddress(GtkBlockView *view, gboolean show)
+GtkWidget *gtk_block_view_new(void)
{
- view->show_vaddress = show;
-
- //gtk_block_view_build_content(view);
-
-}
+ GtkBlockView *result; /* Composant à retourner */
+ result = gtk_type_new(GTK_TYPE_BLOCK_VIEW);
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* show = état de l'affichage auquel parvenir. *
-* *
-* Description : Choisit d'afficher le code brut ou non. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void gtk_block_view_show_code(GtkBlockView *view, gboolean show)
-{
- view->show_code = show;
-
- //gtk_block_view_build_content(view);
+ return GTK_WIDGET(result);
}
-
-
-
/******************************************************************************
* *
* Paramètres : view = composant GTK à mettre à jour. *
-* format = format du binaire affiché. *
-* *
-* Description : Définit le format auquel le contenu est lié. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void gtk_block_view_set_format(GtkBlockView *view, const exe_format *format)
-{
- view->format = format;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* *
-* Description : Réagit à un défilement quelconque. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_scroll(GtkBlockView *view)
-{
- gtk_widget_queue_draw(GTK_WIDGET(view));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* lines = informations à intégrer. *
-* last = dernière ligne à intégrer ou NULL pour toutes. *
+* binary = binaire associé à intégrer. *
* *
-* Description : Définit les lignes du bloc de représentation. *
+* Description : Prend acte de l'association d'un binaire chargé. *
* *
* Retour : - *
* *
@@ -999,127 +143,12 @@ static void gtk_block_view_scroll(GtkBlockView *view)
* *
******************************************************************************/
-static void gtk_block_view_set_rendering_lines(GtkBlockView *view, GRenderingLine *lines, GRenderingLine *last)
+static void gtk_block_view_attach_binary(GtkBlockView *view, GOpenidaBinary *binary)
{
- GWorkQueue *queue; /* Gestionnaire de différés */
- GDelayedInsertion *insertion; /* Insertions à mener */
-
- queue = get_work_queue();
-
- insertion = g_delayed_insertion_new(view);
-
- g_signal_connect(insertion, "work-completed",
- G_CALLBACK(gtk_block_view_complete_building_content), view);
-
- g_work_queue_schedule_work(queue, G_DELAYED_WORK(insertion));
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : insertion = travail d'insertion effectué. *
-* view = composant GTK à mettre à jour. *
-* *
-* Description : Achève la construction de la visualisation des lignes. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_block_view_complete_building_content(GDelayedInsertion *insertion, GtkBlockView *view)
-{
- gdk_threads_enter();
-
- /* Taille des marges */
-
- view->line_height = g_buffer_view_get_line_height(view->buffer_view);
- view->left_margin = 2 * view->line_height;
- view->left_text = -2.5 * view->line_height;
-
- /* Validation finale */
-
- gtk_block_view_recompute_size_request(view);
-
- gdk_flush ();
- gdk_threads_leave();
-
- g_signal_emit_by_name(view, "lines-set");
-
-}
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à mettre à jour. *
-* *
-* Description : Réclame une nouvelle taille adaptée au contenu présent. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void gtk_block_view_recompute_size_request(GtkBlockView *view)
-{
- gint width; /* Largeur de l'objet actuelle */
- gint height; /* Hauteur de l'objet actuelle */
-
- g_buffer_view_get_size(view->buffer_view, &width, &height);
-
- width += -view->left_text + 1;
- height += 1;
-
- gtk_widget_set_size_request(GTK_WIDGET(view), width, height);
-
-}
-
-
-
-
-
-
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à consulter. *
-* addr = adresse à présenter à l'écran. *
-* x = position horizontale au sein du composant. [OUT] *
-* y = position verticale au sein du composant. [OUT] *
-* *
-* Description : Indique la position d'affichage d'une adresse donnée. *
-* *
-* Retour : TRUE si l'adresse fait partie du composant, FALSE sinon. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static bool gtk_block_view_get_address_coordinates(const GtkBlockView *view, vmpa_t addr, gint *x, gint *y)
-{
- bool result; /* Bilan à retourner */
- GRenderingLine *iter; /* Boucle de parcours */
-
- result = false;
-
- *x = 0;
- *y = 0;
+ GCodeBuffer *buffer; /* Tampon par défaut */
- for (iter = GTK_BIN_VIEW(view)->lines;
- iter != NULL && !result;
- iter = g_rendering_line_get_next_iter(GTK_BIN_VIEW(view)->lines, iter, GTK_BIN_VIEW(view)->last))
- {
- if (get_rendering_line_address(iter) == addr) result = true;
- else *y += view->line_height;
- }
+ buffer = g_openida_binary_get_disassembled_buffer(binary);
- return result;
+ gtk_buffer_view_attach_buffer(GTK_BUFFER_VIEW(view), buffer);
}