summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-12-26 23:52:44 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-12-26 23:52:44 (GMT)
commit2c28d59fb3671c0fdd1987784076d4968c58b651 (patch)
treea301f6cd9c1fd9f92191fba7fe7b59a7e3a01b5a /src/gtkext
parent67b4887317b7394d63b543aa48cb368406374103 (diff)
Created the GLoadedContent interface to load all kinds of content.
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/graph/cluster.c7
-rw-r--r--src/gtkext/gtkblockdisplay.c32
-rw-r--r--src/gtkext/gtkblockdisplay.h3
-rw-r--r--src/gtkext/gtkbufferdisplay.c10
-rw-r--r--src/gtkext/gtkdisplaypanel-int.h4
-rw-r--r--src/gtkext/gtkdisplaypanel.c175
-rw-r--r--src/gtkext/gtkdisplaypanel.h6
7 files changed, 140 insertions, 97 deletions
diff --git a/src/gtkext/graph/cluster.c b/src/gtkext/graph/cluster.c
index 413af86..b8cba94 100644
--- a/src/gtkext/graph/cluster.c
+++ b/src/gtkext/graph/cluster.c
@@ -34,6 +34,7 @@
#include "../gtkbufferdisplay.h"
#include "../gtkdisplaypanel.h"
#include "../../common/sort.h"
+#include "../../glibext/gloadedpanel.h"
@@ -313,9 +314,11 @@ GGraphCluster *g_graph_cluster_new(GLoadedBinary *binary, const GBlockList *list
g_object_ref(G_OBJECT(result->block));
result->display = gtk_block_display_new();
-
gtk_widget_show(result->display);
- gtk_display_panel_attach_binary(GTK_DISPLAY_PANEL(result->display), binary, BVW_GRAPH);
+
+ g_loaded_panel_set_content(G_LOADED_PANEL(result->display), G_LOADED_CONTENT(binary));
+
+ gtk_block_display_override_view_index(GTK_BLOCK_DISPLAY(result->display), BVW_GRAPH);
gtk_display_panel_show_border(GTK_DISPLAY_PANEL(result->display), true);
diff --git a/src/gtkext/gtkblockdisplay.c b/src/gtkext/gtkblockdisplay.c
index b39b561..e4d9d48 100644
--- a/src/gtkext/gtkblockdisplay.c
+++ b/src/gtkext/gtkblockdisplay.c
@@ -26,6 +26,7 @@
#include "gtkbufferdisplay-int.h"
#include "../arch/operand.h"
+#include "../analysis/loaded.h"
@@ -249,7 +250,7 @@ static gboolean gtk_block_display_button_press(GtkWidget *widget, GdkEventButton
view = gtk_buffer_display_get_view(GTK_BUFFER_DISPLAY(display));
- changed = g_buffer_view_highlight_segments(view, real_x, real_y, GTK_DISPLAY_PANEL(display)->display);
+ changed = g_buffer_view_highlight_segments(view, real_x, real_y, GTK_DISPLAY_PANEL(display)->display_options);
g_object_unref(G_OBJECT(view));
@@ -300,7 +301,7 @@ static gboolean gtk_block_display_query_tooltip(GtkWidget *widget, gint x, gint
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);
+ creator = g_buffer_view_find_creator(GTK_BUFFER_DISPLAY(display)->view, real_x, real_y, panel->display_options);
if (creator != NULL)
{
@@ -400,7 +401,7 @@ static bool gtk_block_display_notify_caret_relocation(GtkBlockDisplay *display,
view = gtk_buffer_display_get_view(GTK_BUFFER_DISPLAY(display));
- result = g_buffer_view_highlight_segments(view, area->x, area->y, GTK_DISPLAY_PANEL(display)->display);
+ result = g_buffer_view_highlight_segments(view, area->x, area->y, GTK_DISPLAY_PANEL(display)->display_options);
g_object_unref(G_OBJECT(view));
@@ -410,3 +411,28 @@ static bool gtk_block_display_notify_caret_relocation(GtkBlockDisplay *display,
return result;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : display = composant GTK d'affichage. *
+* index = indice de type de vue effectif. *
+* *
+* Description : Force un type de vue pour les options de rendu. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_block_display_override_view_index(GtkBlockDisplay *display, unsigned int index)
+{
+ GtkDisplayPanel *panel; /* Version de plus haut niveau */
+
+ panel = GTK_DISPLAY_PANEL(display);
+
+ panel->view_index = index;
+ panel->display_options = g_loaded_content_get_all_display_options(G_LOADED_CONTENT(panel->binary), index);
+
+}
diff --git a/src/gtkext/gtkblockdisplay.h b/src/gtkext/gtkblockdisplay.h
index 1455690..b394a01 100644
--- a/src/gtkext/gtkblockdisplay.h
+++ b/src/gtkext/gtkblockdisplay.h
@@ -51,6 +51,9 @@ GType gtk_block_display_get_type(void);
/* Crée un nouveau composant pour l'affichage de bloc en ASM. */
GtkWidget *gtk_block_display_new(void);
+/* Force un type de vue pour les options de rendu. */
+void gtk_block_display_override_view_index(GtkBlockDisplay *, unsigned int);
+
#endif /* _GTKEXT_GTKBLOCKDISPLAY_H */
diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c
index ff70032..c1311c5 100644
--- a/src/gtkext/gtkbufferdisplay.c
+++ b/src/gtkext/gtkbufferdisplay.c
@@ -488,7 +488,7 @@ static gboolean gtk_buffer_display_draw(GtkWidget *widget, cairo_t *cr)
area.x -= virt_x;
virt_y += area.y;
- g_buffer_view_draw(display->view, cr, virt_y, &area, parent->display, selected);
+ g_buffer_view_draw(display->view, cr, virt_y, &area, parent->display_options, selected);
}
@@ -571,7 +571,7 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve
ctrl = (event->state & GDK_CONTROL_MASK);
area = display->caret;
- status = g_buffer_view_move_caret(display->view, ctrl, dir, panel->display, &area, &addr);
+ status = g_buffer_view_move_caret(display->view, ctrl, dir, panel->display_options, &area, &addr);
if (status)
{
@@ -607,7 +607,7 @@ static void gtk_buffer_display_compute_requested_size(GtkBufferDisplay *display,
if (width != NULL)
{
if (display->view != NULL)
- *width = g_buffer_view_get_width(display->view, GTK_DISPLAY_PANEL(display)->display);
+ *width = g_buffer_view_get_width(display->view, GTK_DISPLAY_PANEL(display)->display_options);
else
*width = 0;
}
@@ -737,7 +737,7 @@ static bool gtk_buffer_display_get_address_coordinates(const GtkBufferDisplay *d
if (result)
{
- *x += g_buffer_view_get_margin(display->view, GTK_DISPLAY_PANEL(display)->display);
+ *x += g_buffer_view_get_margin(display->view, GTK_DISPLAY_PANEL(display)->display_options);
height = gtk_widget_get_allocated_height(GTK_WIDGET(display));
@@ -874,7 +874,7 @@ static bool _gtk_buffer_display_move_caret_to(GtkBufferDisplay *display, gint x,
panel = GTK_DISPLAY_PANEL(display);
- result = g_buffer_view_compute_caret_full(display->view, x, y, panel->display, &new, &addr);
+ result = g_buffer_view_compute_caret_full(display->view, x, y, panel->display_options, &new, &addr);
if (result)
gtk_buffer_display_relocate_caret(display, &new, &addr);
diff --git a/src/gtkext/gtkdisplaypanel-int.h b/src/gtkext/gtkdisplaypanel-int.h
index a2170e7..4425427 100644
--- a/src/gtkext/gtkdisplaypanel-int.h
+++ b/src/gtkext/gtkdisplaypanel-int.h
@@ -76,8 +76,8 @@ struct _GtkDisplayPanel
GtkScrollablePolicy vscroll_policy; /* Politique verticale */
bool show_border; /* Affichage d'une bordure ? */
- BinaryView content; /* Type de contenu */
- const bool *display; /* Affichage des colonnes ? */
+ unsigned int view_index; /* Indice du type de contenu */
+ bool *display_options; /* Affichage des colonnes ? */
GLoadedBinary *binary; /* Binaire à visualiser */
diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c
index 003ac5f..620a1b1 100644
--- a/src/gtkext/gtkdisplaypanel.c
+++ b/src/gtkext/gtkdisplaypanel.c
@@ -87,6 +87,17 @@ static void gtk_display_panel_adjustment_value_changed(GtkAdjustment *, GtkDispl
/* Réagit à un changement des règles d'affichage. */
static void on_view_panel_binary_display_change(GLoadedBinary *, BinaryView, BufferLineColumn, GtkDisplayPanel *);
+
+
+/* ----------------------- INTERFACE DE PANNEAU DE CHARGEMENT ----------------------- */
+
+
+/* Associe à un panneau d'affichage un binaire chargé. */
+static void gtk_display_panel_set_content(GtkDisplayPanel *, GLoadedContent *);
+
+/* Fournit le contenu associé à un panneau de chargement. */
+static GLoadedContent *gtk_display_panel_get_content(const GtkDisplayPanel *);
+
/* Place en cache un rendu destiné à l'aperçu graphique rapide. */
static void gtk_display_panel_cache_glance(GtkDisplayPanel *, cairo_t *, const GtkAllocation *, double);
@@ -190,6 +201,9 @@ static void gtk_display_panel_init(GtkDisplayPanel *panel)
static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *iface)
{
+ iface->set_content = (set_loaded_panel_content_fc)gtk_display_panel_set_content;
+ iface->get_content = (get_loaded_panel_content_fc)gtk_display_panel_get_content;
+
iface->cache_glance = (cache_loaded_glance_fc)gtk_display_panel_cache_glance;
}
@@ -677,25 +691,6 @@ static void gtk_display_panel_adjustment_value_changed(GtkAdjustment *adj, GtkDi
/******************************************************************************
* *
-* Paramètres : panel = composant GTK à consulter. *
-* *
-* Description : Indique le type de contenu représenté par le composant. *
-* *
-* Retour : Identifiant d'un type de représentation de contenu. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-BinaryView gtk_display_panel_describe_content(const GtkDisplayPanel *panel)
-{
- return panel->content;
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : panel = composant GTK à mettre à jour. *
* show = état de l'affichage auquel parvenir. *
* *
@@ -814,36 +809,6 @@ void gtk_display_panel_draw_border(GtkDisplayPanel *panel, cairo_t *cr)
/******************************************************************************
* *
-* Paramètres : panel = composant GTK à mettre à jour. *
-* binary = binaire associé à intégrer. *
-* view = aspect du binaire à présenter. *
-* *
-* Description : Associe à un panneau d'affichage un binaire chargé. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-void gtk_display_panel_attach_binary(GtkDisplayPanel *panel, GLoadedBinary *binary, BinaryView view)
-{
- g_object_ref(G_OBJECT(binary));
- panel->binary = binary;
-
- panel->content = view;
- panel->display = g_loaded_binary_get_column_display(binary, view);
-
- if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->attach != NULL) /* REMME */
- GTK_DISPLAY_PANEL_GET_CLASS(panel)->attach(panel, binary);
-
- g_signal_connect(binary, "display-changed", G_CALLBACK(on_view_panel_binary_display_change), panel);
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : binary = bianire dont les consignes d'affichage ont évolué. *
* view = type d'affichage à considérer. *
* col = colonne dont le statut a changé. *
@@ -859,7 +824,7 @@ void gtk_display_panel_attach_binary(GtkDisplayPanel *panel, GLoadedBinary *bina
static void on_view_panel_binary_display_change(GLoadedBinary *binary, BinaryView view, BufferLineColumn col, GtkDisplayPanel *panel)
{
- if (panel->content == view)
+ if (panel->view_index == view)
{
gtk_widget_queue_resize(gtk_widget_get_parent(GTK_WIDGET(panel)));
gtk_widget_queue_resize(GTK_WIDGET(panel));
@@ -1067,35 +1032,6 @@ bool gtk_display_panel_get_position(const GtkDisplayPanel *panel, GBufferLine **
/******************************************************************************
* *
-* Paramètres : panel = composant GTK à manipuler. *
-* cairo = assistant pour la création de rendus. *
-* area = taille de la surface réduite à disposition. *
-* scale = échelle vis à vis de la taille réelle. *
-* *
-* Description : Place en cache un rendu destiné à l'aperçu graphique rapide. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_display_panel_cache_glance(GtkDisplayPanel *panel, cairo_t *cairo, const GtkAllocation *area, double scale)
-{
- if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->cache_glance != NULL)
- GTK_DISPLAY_PANEL_GET_CLASS(panel)->cache_glance(panel, cairo, area, scale);
-
-}
-
-
-
-/* ---------------------------------------------------------------------------------- */
-/* CONVERSIONS DE COORDONNEES */
-/* ---------------------------------------------------------------------------------- */
-
-
-/******************************************************************************
-* *
* Paramètres : panel = composant GTK à consulter. *
* event = informations liées à l'événement. *
* *
@@ -1165,3 +1101,84 @@ void gtk_display_panel_compute_relative_coords(GtkDisplayPanel *panel, gint *x,
*y -= gtk_adjustment_get_value(panel->vadjustment);
}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* INTERFACE DE PANNEAU DE CHARGEMENT */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = composant GTK à mettre à jour. *
+* content = binaire associé à intégrer. *
+* *
+* Description : Associe à un panneau d'affichage un binaire chargé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_display_panel_set_content(GtkDisplayPanel *panel, GLoadedContent *content)
+{
+ panel->view_index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel));
+
+ panel->display_options = g_loaded_content_get_all_display_options(content, panel->view_index);
+
+ panel->binary = G_LOADED_BINARY(content);
+
+ if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->attach != NULL) /* REMME */
+ GTK_DISPLAY_PANEL_GET_CLASS(panel)->attach(panel, panel->binary);
+
+ g_signal_connect(content, "display-changed", G_CALLBACK(on_view_panel_binary_display_change), panel);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = composant GTK à consulter. *
+* *
+* Description : Fournit le contenu associé à un panneau de chargement. *
+* *
+* Retour : Contenu quelconque chargé en mémoire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GLoadedContent *gtk_display_panel_get_content(const GtkDisplayPanel *panel)
+{
+ GLoadedContent *result; /* Contenu à retourner */
+
+ result = G_LOADED_CONTENT(panel->binary);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = composant GTK à manipuler. *
+* cairo = assistant pour la création de rendus. *
+* area = taille de la surface réduite à disposition. *
+* scale = échelle vis à vis de la taille réelle. *
+* *
+* Description : Place en cache un rendu destiné à l'aperçu graphique rapide. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_display_panel_cache_glance(GtkDisplayPanel *panel, cairo_t *cairo, const GtkAllocation *area, double scale)
+{
+ if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->cache_glance != NULL)
+ GTK_DISPLAY_PANEL_GET_CLASS(panel)->cache_glance(panel, cairo, area, scale);
+
+}
diff --git a/src/gtkext/gtkdisplaypanel.h b/src/gtkext/gtkdisplaypanel.h
index 3ea967a..7d4c824 100644
--- a/src/gtkext/gtkdisplaypanel.h
+++ b/src/gtkext/gtkdisplaypanel.h
@@ -50,15 +50,9 @@ typedef struct _GtkDisplayPanelClass GtkDisplayPanelClass;
/* Détermine le type du composant d'affichage générique. */
GType gtk_display_panel_get_type(void);
-/* Indique le type de contenu représenté par le composant. */
-BinaryView gtk_display_panel_describe_content(const GtkDisplayPanel *);
-
/* Définit si une bordure est à afficher. */
void gtk_display_panel_show_border(GtkDisplayPanel *, bool);
-/* Associe à un panneau d'affichage un binaire chargé. */
-void gtk_display_panel_attach_binary(GtkDisplayPanel *, GLoadedBinary *, BinaryView);
-
/* Définit si les adresses doivent apparaître dans le rendu. */
void gtk_display_panel_set_addresses_display(GtkDisplayPanel *, bool);