summaryrefslogtreecommitdiff
path: root/src/gtkext
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtkext')
-rw-r--r--src/gtkext/Makefile.am3
-rw-r--r--src/gtkext/gtkbinview-int.h18
-rw-r--r--src/gtkext/gtkbinview.c267
-rw-r--r--src/gtkext/gtkbinview.h3
-rw-r--r--src/gtkext/gtkblockview.c80
-rw-r--r--src/gtkext/gtkgraphview.c51
-rw-r--r--src/gtkext/gtksourceview.c147
-rw-r--r--src/gtkext/gtksourceview.h57
-rw-r--r--src/gtkext/gtkviewpanel-int.h81
-rw-r--r--src/gtkext/gtkviewpanel.c361
-rw-r--r--src/gtkext/gtkviewpanel.h61
11 files changed, 835 insertions, 294 deletions
diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am
index fbfa0b6..d253edc 100644
--- a/src/gtkext/Makefile.am
+++ b/src/gtkext/Makefile.am
@@ -14,6 +14,9 @@ libgtkext_la_SOURCES = \
gtkdropwindow.h gtkdropwindow.c \
gtkgraphview.h gtkgraphview.c \
gtklinkrenderer.h gtklinkrenderer.c \
+ gtksourceview.h gtksourceview.c \
+ gtkviewpanel-int.h \
+ gtkviewpanel.h gtkviewpanel.c \
iodamarshal.h iodamarshal.c \
support.h support.c
diff --git a/src/gtkext/gtkbinview-int.h b/src/gtkext/gtkbinview-int.h
index ab72a84..51bc786 100644
--- a/src/gtkext/gtkbinview-int.h
+++ b/src/gtkext/gtkbinview-int.h
@@ -26,6 +26,7 @@
#include "gtkbinview.h"
+#include "gtkviewpanel-int.h"
#include <stdbool.h>
@@ -33,9 +34,6 @@
-/* Réagit à un défilement quelconque. */
-typedef void (* scroll_fc) (GtkBinView *);
-
/* Définit les lignes à associer à la représentation. */
typedef void (* set_rendering_lines_fc) (GtkBinView *, GRenderingLine *, GRenderingLine *);
@@ -48,21 +46,13 @@ typedef bool (* get_addr_coordinates_fc) (const GtkBinView *, vmpa_t, gint *, gi
struct _GtkBinView
{
- GtkFixed parent; /* A laisser en premier */
-
- GtkAdjustment *hadjustment; /* Barre de défilement horiz. */
- GtkAdjustment *vadjustment; /* Barre de défilement vert. */
-
- GdkGC *gc; /* Contexte graphique du rendu */
-
- bool show_border; /* Affichage d'une bordure ? */
+ GtkViewPanel parent; /* A laisser en premier */
GOpenidaBinary *binary; /* Contenu binaire affiché */
GRenderingLine *lines; /* Contenu à représenter */
GRenderingLine *last; /* Dernière ligne associée */
- scroll_fc scroll; /* Défilement du contenu */
set_rendering_lines_fc set_lines; /* Association des lignes */
define_main_address_fc define_address; /* Sélection externe d'adresse */
get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */
@@ -71,12 +61,10 @@ struct _GtkBinView
struct _GtkBinViewClass
{
- GtkFixedClass parent; /* A laisser en premier */
+ GtkViewPanelClass parent; /* A laisser en premier */
/* Signaux */
- void (* set_scroll_adjustments) (GtkBinView *, GtkAdjustment *, GtkAdjustment *);
-
void (* lines_set) (GtkBinView *);
};
diff --git a/src/gtkext/gtkbinview.c b/src/gtkext/gtkbinview.c
index 0a9ce6e..46fc9ce 100644
--- a/src/gtkext/gtkbinview.c
+++ b/src/gtkext/gtkbinview.c
@@ -25,27 +25,32 @@
#include "gtkbinview-int.h"
-#include "iodamarshal.h"
-/* Enregistrement les défilements à associer au composant GTK. */
-static void gtk_binview_set_scroll_adjustments(GtkBinView *, GtkAdjustment *, GtkAdjustment *);
+/* Acquitement d'une fin d'attachement */
+typedef struct _bv_loading_ack
+{
+ bool lines_set; /* Construction complète */
+ GMutex *mutex; /* Accès à la variable */
+ GCond *cond; /* Attente de changement */
+
+} bv_loading_ack;
+
+
+/* Prend acte de l'association d'un binaire chargé. */
+static void gtk_bin_view_attach_binary(GtkBinView *, GOpenidaBinary *);
-/* Encadre la construction graphique initiale de la visualisation. */
-static void gtk_bin_view_realize(GtkWidget *);
+/* Prend note de la fin d'une construction d'une visualisation. */
+static void ack_loaded_lines_for_bin_view(GtkBinView *, bv_loading_ack *);
-/* Met à jour l'affichage de la visualisation de code binaire. */
-static gboolean gtk_bin_view_expose(GtkBinView *, GdkEventExpose *);
-/* Prend acte d'un nouveau défilement. */
-static void gtk_bin_view_adj_value_changed(GtkAdjustment *, GtkBinView *);
/* Détermine le type du composant d'affichage des morceaux. */
-G_DEFINE_TYPE(GtkBinView, gtk_binview, GTK_TYPE_FIXED)
+G_DEFINE_TYPE(GtkBinView, gtk_binview, GTK_TYPE_VIEW_PANEL)
@@ -66,26 +71,6 @@ G_DEFINE_TYPE(GtkBinView, gtk_binview, GTK_TYPE_FIXED)
static void gtk_binview_class_init(GtkBinViewClass *class)
{
- GtkWidgetClass *widget_class; /* Classe de haut niveau */
-
- widget_class = GTK_WIDGET_CLASS(class);
-
- widget_class->realize = gtk_bin_view_realize;
- widget_class->expose_event = gtk_bin_view_expose;
-
- class->set_scroll_adjustments = gtk_binview_set_scroll_adjustments;
-
- widget_class->set_scroll_adjustments_signal =
- g_signal_new(("set_scroll_adjustments"),
- GTK_TYPE_BIN_VIEW,
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET(GtkBinViewClass, set_scroll_adjustments),
- NULL, NULL,
- g_cclosure_user_marshal_VOID__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ADJUSTMENT,
- GTK_TYPE_ADJUSTMENT);
-
g_signal_new("lines-set",
GTK_TYPE_BIN_VIEW,
G_SIGNAL_RUN_LAST,
@@ -99,34 +84,6 @@ static void gtk_binview_class_init(GtkBinViewClass *class)
/******************************************************************************
* *
-* Paramètres : view = vue à compléter. *
-* hadjustment = nouveau défilement horizontal à intégrer. *
-* vadjustment = nouveau défilement vertical à intégrer. *
-* *
-* Description : Enregistrement les défilements à associer au composant GTK. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_binview_set_scroll_adjustments(GtkBinView *view, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment)
-{
- view->hadjustment = hadjustment;
- view->vadjustment = vadjustment;
-
- g_signal_connect(hadjustment, "value_changed",
- G_CALLBACK(gtk_bin_view_adj_value_changed), view);
-
- g_signal_connect(vadjustment, "value_changed",
- G_CALLBACK(gtk_bin_view_adj_value_changed), view);
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : view = composant GTK à initialiser. *
* *
* Description : Procède à l'initialisation de l'afficheur de morceaux. *
@@ -139,7 +96,11 @@ static void gtk_binview_set_scroll_adjustments(GtkBinView *view, GtkAdjustment *
static void gtk_binview_init(GtkBinView *view)
{
- gtk_fixed_set_has_window(GTK_FIXED(view), TRUE);
+ GtkViewPanel *panel; /* Instance parente */
+
+ panel = GTK_VIEW_PANEL(view);
+
+ panel->attach = (attach_binary_fc)gtk_bin_view_attach_binary;
}
@@ -165,9 +126,10 @@ GtkWidget* gtk_binview_new(void)
/******************************************************************************
* *
-* Paramètres : widget = composant GTK à redessiner. *
+* Paramètres : view = composant GTK à mettre à jour. *
+* binary = binaire associé à intégrer. *
* *
-* Description : Encadre la construction graphique initiale de la visualisat°.*
+* Description : Prend acte de l'association d'un binaire chargé. *
* *
* Retour : - *
* *
@@ -175,88 +137,39 @@ GtkWidget* gtk_binview_new(void)
* *
******************************************************************************/
-static void gtk_bin_view_realize(GtkWidget *widget)
+static void gtk_bin_view_attach_binary(GtkBinView *view, GOpenidaBinary *binary)
{
- GdkWindowAttr attributes; /* Propriétés du composant */
- guint attributes_mask; /* Masque de prise en compte */
- GdkColor white; /* Couleur de fond normale */
-
- GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
+ bv_loading_ack ack; /* Informations d'acquitement */
- attributes.window_type = GDK_WINDOW_CHILD;
- attributes.x = widget->allocation.x;
- attributes.y = widget->allocation.y;
- attributes.width = widget->allocation.width;
- attributes.height = widget->allocation.height;
+ ack.lines_set = false;
+ ack.mutex = g_mutex_new();
+ ack.cond = g_cond_new();
- attributes.wclass = GDK_INPUT_OUTPUT;
- attributes.event_mask = gtk_widget_get_events(widget)
- | GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK;
+ g_signal_connect(view, "lines-set", G_CALLBACK(ack_loaded_lines_for_bin_view), &ack);
- attributes_mask = GDK_WA_X | GDK_WA_Y;
+ gtk_bin_view_set_rendering_lines(view, binary,
+ g_openida_binary_get_lines(binary), NULL);
- widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
- &attributes, attributes_mask);
+ /* Attente de la fin de construction */
+ g_mutex_lock(ack.mutex);
+ while (!ack.lines_set)
+ g_cond_wait(ack.cond, ack.mutex);
+ g_mutex_unlock(ack.mutex);
- gdk_window_set_user_data(widget->window, widget);
+ g_signal_handlers_disconnect_by_func(view, G_CALLBACK(ack_loaded_lines_for_bin_view), &ack);
- widget->style = gtk_style_attach(widget->style, widget->window);
-
- gdk_color_white(gtk_widget_get_colormap(widget), &white);
- gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white);
-
- GTK_BIN_VIEW(widget)->gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
+ g_mutex_free(ack.mutex);
+ g_cond_free(ack.cond);
}
/******************************************************************************
* *
-* Paramètres : view = composant GTK à redessiner. *
-* event = informations liées à l'événement. *
-* *
-* Description : Met à jour l'affichage de la visualisation de code binaire. *
+* Paramètres : view = composant d'affichage prêt à utilisation. *
+* ack = paramètres nécessaires à l'acquitement. *
* *
-* Retour : FALSE pour poursuivre la propagation de l'événement. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static gboolean gtk_bin_view_expose(GtkBinView *view, GdkEventExpose *event)
-{
- GdkGCValues values; /* Propriétés du contexte */
- GtkStyle *style; /* Style associé au composant */
- int width; /* Largeur de l'élément */
- int height; /* Hauteur de l'élément */
-
- if (view->show_border)
- {
- gdk_gc_get_values(view->gc, &values);
- style = gtk_widget_get_style(GTK_WIDGET(view));
-
- gtk_widget_get_size_request(GTK_WIDGET(view), &width, &height);
-
- gdk_gc_set_foreground(view->gc, &style->dark[GTK_WIDGET_STATE(GTK_WIDGET(view))]);
-
- gdk_draw_rectangle(GDK_DRAWABLE(GTK_WIDGET(view)->window), view->gc,
- FALSE, 0, 0, width - 1, height - 1);
-
- gdk_gc_set_foreground(view->gc, &values.foreground);
-
- }
-
- return FALSE;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à consulter. *
-* alloc = étendue à accorder à la vue. *
-* *
-* Description : Calcule la surface pleine utilisable pour la vue. *
+* Description : Prend note de la fin d'une construction d'une visualisation. *
* *
* Retour : - *
* *
@@ -264,82 +177,22 @@ static gboolean gtk_bin_view_expose(GtkBinView *view, GdkEventExpose *event)
* *
******************************************************************************/
-void gtk_bin_view_compute_allocation(GtkBinView *view, GtkAllocation *alloc)
+static void ack_loaded_lines_for_bin_view(GtkBinView *view, bv_loading_ack *ack)
{
- GtkWidget *widget; /* Autre version de la vue */
- GtkAllocation *allocation; /* Raccourci d'utilisation #1 */
- gint border_width; /* Raccourci d'utilisation #2 */
-
- widget = GTK_WIDGET(view);
- allocation = &widget->allocation;
- border_width = GTK_CONTAINER(view)->border_width;
+ g_mutex_lock(ack->mutex);
- alloc->x = 0;
- alloc->y = 0;
-
- /*
- if (viewport->shadow_type != GTK_SHADOW_NONE)
- {
- alloc->x = widget->style->xthickness;
- alloc->y = widget->style->ythickness;
- }
- */
+ ack->lines_set = true;
- alloc->width = MAX(1, allocation->width - alloc->x * 2 - border_width * 2);
- alloc->height = MAX(1, allocation->height - alloc->y * 2 - border_width * 2);
+ g_cond_signal(ack->cond);
+ g_mutex_unlock(ack->mutex);
}
-/******************************************************************************
-* *
-* Paramètres : adj = valeurs de défilement à consulter. *
-* changed = note une mise à jour de valeur. [OUT] *
-* *
-* Description : S'assure que la valeur de défilement actuelle est valable. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-void gtk_bin_view_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed)
-{
- gdouble value; /* Valeur actuelle */
- value = adj->value;
-
- value = CLAMP(value, 0, adj->upper - adj->page_size);
- if (value != adj->value)
- {
- adj->value = value;
- *changed = TRUE;
- }
- else *changed = FALSE;
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : adj = défilement à l'origine de l'action. *
-* view = composant GTK à redessiner. *
-* *
-* Description : Prend acte d'un nouveau défilement. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void gtk_bin_view_adj_value_changed(GtkAdjustment *adj, GtkBinView *view)
-{
- view->scroll(view);
-
-}
/******************************************************************************
@@ -357,7 +210,8 @@ static void gtk_bin_view_adj_value_changed(GtkAdjustment *adj, GtkBinView *view)
void gtk_bin_view_show_border(GtkBinView *view, bool show)
{
- view->show_border = show;
+ /* FIXME : à déplacer vers GtkViewPanel */
+ GTK_VIEW_PANEL(view)->show_border = show;
}
@@ -395,25 +249,6 @@ void gtk_bin_view_set_rendering_lines(GtkBinView *view, GOpenidaBinary *binary,
* *
* Paramètres : view = composant GTK à consulter. *
* *
-* Description : Fournit le binaire associé à la représentation. *
-* *
-* Retour : Représentation de contenu binaire. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-GOpenidaBinary *gtk_bin_view_get_binary(const GtkBinView *view)
-{
- return view->binary;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : view = composant GTK à consulter. *
-* *
* Description : Fournit la liste des lignes associées à la représentation. *
* *
* Retour : Ligne de représentation. *
@@ -566,6 +401,8 @@ bool gtk_bin_view_contain_address(const GtkBinView *view, vmpa_t addr)
void gtk_bin_view_scroll_to_address(GtkBinView *view, vmpa_t addr)
{
+ /* FIXME */
+#if 0
gint x; /* Abscisse à garantir */
gint y; /* Ordonnée à garantir */
GtkAdjustment *adj; /* Défilement à mettre à jour */
@@ -590,5 +427,5 @@ void gtk_bin_view_scroll_to_address(GtkBinView *view, vmpa_t addr)
gtk_adjustment_set_value(adj, y);
}
-
+#endif
}
diff --git a/src/gtkext/gtkbinview.h b/src/gtkext/gtkbinview.h
index 2dae0eb..945eefb 100644
--- a/src/gtkext/gtkbinview.h
+++ b/src/gtkext/gtkbinview.h
@@ -59,9 +59,6 @@ void gtk_bin_view_show_border(GtkBinView *, bool);
/* Définit les lignes à associer à la représentation. */
void gtk_bin_view_set_rendering_lines(GtkBinView *, GOpenidaBinary *, GRenderingLine *, GRenderingLine *);
-/* Fournit le binaire associé à la représentation. */
-GOpenidaBinary *gtk_bin_view_get_binary(const GtkBinView *);
-
/* Fournit la liste des lignes associées à la représentation. */
GRenderingLine *gtk_bin_view_get_lines(const GtkBinView *);
diff --git a/src/gtkext/gtkblockview.c b/src/gtkext/gtkblockview.c
index a19c17a..66177b8 100644
--- a/src/gtkext/gtkblockview.c
+++ b/src/gtkext/gtkblockview.c
@@ -501,18 +501,20 @@ static void gtk_block_view_class_init(GtkBlockViewClass *klass)
static void gtk_block_view_init(GtkBlockView *view)
{
- GtkBinView *binview; /* Instance parente */
+ 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->scroll = (scroll_fc)gtk_block_view_scroll;
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();
-
}
@@ -578,7 +580,7 @@ static void gtk_block_view_size_request(GtkWidget *widget, GtkRequisition *requi
static void gtk_block_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
- GtkBinView *view; /* Autre version du composant */
+ GtkViewPanel *panel; /* Autre version du composant */
gint width; /* Largeur de l'objet actuelle */
gint height; /* Hauteur de l'objet actuelle */
GtkAllocation valloc; /* Surface utilisable */
@@ -593,44 +595,44 @@ static void gtk_block_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc
allocation->x, allocation->y,
allocation->width, allocation->height);
- view = GTK_BIN_VIEW(widget);
+ panel = GTK_VIEW_PANEL(widget);
- if (view->hadjustment == NULL || view->vadjustment == NULL)
+ if (panel->hadjustment == NULL || panel->vadjustment == NULL)
return;
- g_buffer_view_get_size(GTK_BLOCK_VIEW(view)->buffer_view, &width, &height);
+ g_buffer_view_get_size(GTK_BLOCK_VIEW(widget)->buffer_view, &width, &height);
- gtk_bin_view_compute_allocation(view, &valloc);
+ gtk_view_panel_compute_allocation(panel, &valloc);
/* Défilement horizontal */
- view->hadjustment->page_size = valloc.width;
- view->hadjustment->step_increment = valloc.width * 0.1;
- view->hadjustment->page_increment = valloc.width * 0.9;
+ panel->hadjustment->page_size = valloc.width;
+ panel->hadjustment->step_increment = valloc.width * 0.1;
+ panel->hadjustment->page_increment = valloc.width * 0.9;
- view->hadjustment->upper = MAX(width, valloc.width);
+ panel->hadjustment->upper = MAX(width, valloc.width);
- gtk_bin_view_reclamp_adjustment(view->hadjustment, &changed);
+ gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed);
- gtk_adjustment_changed(view->hadjustment);
+ gtk_adjustment_changed(panel->hadjustment);
if (changed)
- gtk_adjustment_value_changed(view->hadjustment);
+ gtk_adjustment_value_changed(panel->hadjustment);
/* Défilement vertical */
- view->vadjustment->page_size = valloc.height;
- view->vadjustment->step_increment = GTK_BLOCK_VIEW(view)->line_height;
- view->vadjustment->page_increment = view->vadjustment->step_increment * 10.0;
+ 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;
- view->vadjustment->upper = MAX(height, valloc.height);
+ panel->vadjustment->upper = MAX(height, valloc.height);
- gtk_bin_view_reclamp_adjustment(view->vadjustment, &changed);
+ gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed);
- gtk_adjustment_changed(view->vadjustment);
+ gtk_adjustment_changed(panel->vadjustment);
if (changed)
- gtk_adjustment_value_changed(view->vadjustment);
+ gtk_adjustment_value_changed(panel->vadjustment);
}
@@ -723,11 +725,11 @@ void gtk_block_view_update_margin(GRenderingLine *line, GtkBlockView *view)
static void gtk_block_view_compute_fake_coord(GtkBlockView *view, gint *x, gint *y)
{
- if (GTK_BIN_VIEW(view)->hadjustment != NULL)
- *x -= gtk_adjustment_get_value(GTK_BIN_VIEW(view)->hadjustment);
+ if (GTK_VIEW_PANEL(view)->hadjustment != NULL)
+ *x -= gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->hadjustment);
- if (GTK_BIN_VIEW(view)->vadjustment != NULL)
- *y += gtk_adjustment_get_value(GTK_BIN_VIEW(view)->vadjustment);
+ if (GTK_VIEW_PANEL(view)->vadjustment != NULL)
+ *y += gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->vadjustment);
}
@@ -747,11 +749,11 @@ static void gtk_block_view_compute_fake_coord(GtkBlockView *view, gint *x, gint
static void gtk_block_view_compute_real_coord(GtkBlockView *view, gint *x, gint *y)
{
- if (x != NULL && GTK_BIN_VIEW(view)->hadjustment != NULL)
- *x += gtk_adjustment_get_value(GTK_BIN_VIEW(view)->hadjustment);
+ if (x != NULL && GTK_VIEW_PANEL(view)->hadjustment != NULL)
+ *x += gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->hadjustment);
- if (y != NULL && GTK_BIN_VIEW(view)->vadjustment != NULL)
- *y += gtk_adjustment_get_value(GTK_BIN_VIEW(view)->vadjustment);
+ if (y != NULL && GTK_VIEW_PANEL(view)->vadjustment != NULL)
+ *y += gtk_adjustment_get_value(GTK_VIEW_PANEL(view)->vadjustment);
}
@@ -840,7 +842,7 @@ static void gtk_block_view_draw_line_extra(GBufferLine *line, GdkDrawable *drawa
static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
{
GtkBlockView *view; /* Autre version du composant */
- GtkBinView *bview; /* 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 */
@@ -849,13 +851,13 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
view = GTK_BLOCK_VIEW(widget);
widget = GTK_WIDGET(view);
- bview = GTK_BIN_VIEW(widget);
+ pview = GTK_VIEW_PANEL(widget);
drawable = GDK_DRAWABLE(event->window);
gdk_window_begin_paint_region(drawable, event->region);
- gdk_gc_set_clip_region(bview->gc, event->region);
+ gdk_gc_set_clip_region(pview->gc, event->region);
style = gtk_widget_get_style(GTK_WIDGET(view));
@@ -865,14 +867,14 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
/* Dessin de la marge gauche */
- gdk_gc_set_foreground(bview->gc, &style->mid[GTK_WIDGET_STATE(widget)]);
+ gdk_gc_set_foreground(pview->gc, &style->mid[GTK_WIDGET_STATE(widget)]);
- gdk_draw_rectangle(drawable, bview->gc, TRUE,
+ 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(bview->gc, &style->dark[GTK_WIDGET_STATE(widget)]);
+ gdk_gc_set_foreground(pview->gc, &style->dark[GTK_WIDGET_STATE(widget)]);
- gdk_draw_line(drawable, bview->gc,
+ 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);
@@ -884,7 +886,7 @@ static gboolean gtk_block_view_expose(GtkWidget *widget, GdkEventExpose *event)
/* Impression du désassemblage */
- g_buffer_view_draw(view->buffer_view, event, bview->gc, fake_x, fake_y);
+ g_buffer_view_draw(view->buffer_view, event, pview->gc, fake_x, fake_y);
gdk_window_end_paint(drawable);
diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c
index 34e0e80..756c00a 100644
--- a/src/gtkext/gtkgraphview.c
+++ b/src/gtkext/gtkgraphview.c
@@ -144,12 +144,16 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *klass)
static void gtk_graph_view_init(GtkGraphView *view)
{
- GtkBinView *binview; /* Instance parente */
+ GtkViewPanel *viewpanel; /* Instance parente #1 */
+ GtkBinView *binview; /* Instance parente #2 */
GdkColor white; /* Couleur de fond normale */
+ viewpanel = GTK_VIEW_PANEL(view);
+
+ viewpanel->scroll = (scroll_fc)gtk_graph_view_scroll;
+
binview = GTK_BIN_VIEW(view);
- binview->scroll = (scroll_fc)gtk_graph_view_scroll;
binview->set_lines = (set_rendering_lines_fc)gtk_graph_view_set_rendering_lines;
binview->define_address = (define_main_address_fc)gtk_graph_view_define_main_address;
binview->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates;
@@ -218,7 +222,7 @@ static void gtk_graph_view_size_request(GtkWidget *widget, GtkRequisition *requi
static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
{
gpointer fixed_class; /* Classe parente */
- GtkBinView *view; /* Autre version du composant */
+ GtkViewPanel *panel; /* Autre version du composant */
GtkAllocation valloc; /* Surface utilisable */
gboolean changed; /* Changement de valeur ? */
@@ -228,39 +232,42 @@ static void gtk_graph_view_size_allocate(GtkWidget *widget, GtkAllocation *alloc
GTK_WIDGET_CLASS(fixed_class)->size_allocate(GTK_FIXED(widget), allocation);
- view = GTK_BIN_VIEW(widget);
+ panel = GTK_VIEW_PANEL(widget);
+
+ if (panel->hadjustment == NULL || panel->vadjustment == NULL)
+ return;
- gtk_bin_view_compute_allocation(view, &valloc);
+ gtk_view_panel_compute_allocation(panel, &valloc);
/* Défilement horizontal */
- view->hadjustment->page_size = valloc.width;
- view->hadjustment->step_increment = valloc.width * 0.1;
- view->hadjustment->page_increment = valloc.width * 0.9;
+ panel->hadjustment->page_size = valloc.width;
+ panel->hadjustment->step_increment = valloc.width * 0.1;
+ panel->hadjustment->page_increment = valloc.width * 0.9;
- view->hadjustment->upper = MAX(GTK_GRAPH_VIEW(view)->requisition.width, valloc.width);
+ panel->hadjustment->upper = MAX(GTK_GRAPH_VIEW(widget)->requisition.width, valloc.width);
- gtk_bin_view_reclamp_adjustment(view->hadjustment, &changed);
+ gtk_view_panel_reclamp_adjustment(panel->hadjustment, &changed);
- gtk_adjustment_changed(view->hadjustment);
+ gtk_adjustment_changed(panel->hadjustment);
if (changed)
- gtk_adjustment_value_changed(view->hadjustment);
+ gtk_adjustment_value_changed(panel->hadjustment);
/* Défilement vertical */
- view->vadjustment->page_size = valloc.height;
- view->vadjustment->step_increment = valloc.width * 0.1;
- view->vadjustment->page_increment = valloc.width * 0.9;
+ panel->vadjustment->page_size = valloc.height;
+ panel->vadjustment->step_increment = valloc.width * 0.1;
+ panel->vadjustment->page_increment = valloc.width * 0.9;
- view->vadjustment->upper = MAX(GTK_GRAPH_VIEW(view)->requisition.height, valloc.height);
+ panel->vadjustment->upper = MAX(GTK_GRAPH_VIEW(widget)->requisition.height, valloc.height);
- gtk_bin_view_reclamp_adjustment(view->vadjustment, &changed);
+ gtk_view_panel_reclamp_adjustment(panel->vadjustment, &changed);
- gtk_adjustment_changed(view->vadjustment);
+ gtk_adjustment_changed(panel->vadjustment);
if (changed)
- gtk_adjustment_value_changed(view->vadjustment);
+ gtk_adjustment_value_changed(panel->vadjustment);
}
@@ -310,7 +317,7 @@ static gboolean gtk_graph_view_expose(GtkWidget *widget, GdkEventExpose *event,
for (i = 0; i < view->links_count; i++)
gtk_link_renderer_draw(view->links[i],
GDK_DRAWABLE(widget->window),
- GTK_BIN_VIEW(view)->gc);
+ GTK_VIEW_PANEL(view)->gc);
return FALSE;
@@ -387,8 +394,8 @@ static void gtk_graph_view_reset(GtkGraphView *view)
static void gtk_graph_view_scroll(GtkGraphView *view)
{
gtk_fixed_move(GTK_FIXED(view), GTK_WIDGET(view->support),
- -GTK_BIN_VIEW(view)->hadjustment->value,
- -GTK_BIN_VIEW(view)->vadjustment->value);
+ -GTK_VIEW_PANEL(view)->hadjustment->value,
+ -GTK_VIEW_PANEL(view)->vadjustment->value);
}
diff --git a/src/gtkext/gtksourceview.c b/src/gtkext/gtksourceview.c
new file mode 100644
index 0000000..14f7f95
--- /dev/null
+++ b/src/gtkext/gtksourceview.c
@@ -0,0 +1,147 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * gtksourceview.c - affichage de code source
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "gtksourceview.h"
+
+
+#include "gtkviewpanel-int.h"
+
+
+
+/* -------------------------- INTERACTION DIRECTE AVEC GTK -------------------------- */
+
+
+/* Composant d'affichage de code source (instance) */
+struct _GtkSourceView
+{
+ GtkViewPanel parent; /* A laisser en premier */
+
+};
+
+/* Composant d'affichage de code source (classe) */
+struct _GtkSourceViewClass
+{
+ GtkViewPanelClass parent; /* A laisser en premier */
+
+};
+
+
+/* Procède à l'initialisation de l'afficheur de code source. */
+static void gtk_source_view_class_init(GtkSourceViewClass *);
+
+/* Procède à l'initialisation de l'afficheur de code source. */
+static void gtk_source_view_init(GtkSourceView *);
+
+/* Prend acte de l'association d'un binaire chargé. */
+static void gtk_source_view_attach_binary(GtkSourceView *, GOpenidaBinary *);
+
+
+/* ---------------------------------------------------------------------------------- */
+/* INTERACTION DIRECTE AVEC GTK */
+/* ---------------------------------------------------------------------------------- */
+
+
+/* Détermine le type du composant d'affichage de code source. */
+G_DEFINE_TYPE(GtkSourceView, gtk_source_view, GTK_TYPE_VIEW_PANEL)
+
+
+/******************************************************************************
+* *
+* Paramètres : class = classe GTK à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'afficheur de code source. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_source_view_class_init(GtkSourceViewClass *class)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = composant GTK à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'afficheur de code source. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_source_view_init(GtkSourceView *view)
+{
+ GtkViewPanel *panel; /* Instance parente */
+
+ panel = GTK_VIEW_PANEL(view);
+
+ panel->attach = (attach_binary_fc)gtk_source_view_attach_binary;
+
+}
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Crée un nouveau composant pour l'affichage de code source. *
+* *
+* Retour : Composant GTK créé. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *gtk_source_view_new(void)
+{
+ GtkSourceView *result;
+
+ result = gtk_type_new(GTK_TYPE_SOURCE_VIEW);
+
+ return GTK_WIDGET(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = composant GTK à mettre à jour. *
+* binary = binaire associé à intégrer. *
+* *
+* Description : Prend acte de l'association d'un binaire chargé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_source_view_attach_binary(GtkSourceView *view, GOpenidaBinary *binary)
+{
+
+}
diff --git a/src/gtkext/gtksourceview.h b/src/gtkext/gtksourceview.h
new file mode 100644
index 0000000..3e78a20
--- /dev/null
+++ b/src/gtkext/gtksourceview.h
@@ -0,0 +1,57 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * gtksourceview.h - prototypes pour l'affichage de code source
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GTK_SOURCEVIEW_H
+#define _GTK_SOURCEVIEW_H
+
+
+
+#include <glib-object.h>
+#include <gtk/gtkwidget.h>
+
+
+
+#define GTK_TYPE_SOURCE_VIEW (gtk_source_view_get_type())
+#define GTK_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_SOURCE_VIEW, GtkSourceView))
+#define GTK_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_SOURCE_VIEW, GtkSourceViewClass))
+#define GTK_IS_SOURCE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_SOURCE_VIEW))
+#define GTK_IS_SOURCE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_SOURCE_VIEW))
+#define GTK_SOURCE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_SOURCE_VIEW, GtkSourceViewClass))
+
+
+/* Composant d'affichage de code source (instance) */
+typedef struct _GtkSourceView GtkSourceView;
+
+/* Composant d'affichage de code source (classe) */
+typedef struct _GtkSourceViewClass GtkSourceViewClass;
+
+
+/* Détermine le type du composant d'affichage de code source. */
+GType gtk_source_view_get_type(void);
+
+/* Crée un nouveau composant pour l'affichage de code source. */
+GtkWidget *gtk_source_view_new(void);
+
+
+
+#endif /* _GTK_SOURCEVIEW_H */
diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h
new file mode 100644
index 0000000..7480807
--- /dev/null
+++ b/src/gtkext/gtkviewpanel-int.h
@@ -0,0 +1,81 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * gtkviewpanel-int.h - définitions internes propre à l'affichage de contenu de binaire
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GTK_VIEWPANEL_INT_H
+#define _GTK_VIEWPANEL_INT_H
+
+
+#include "gtkviewpanel.h"
+
+
+#include <stdbool.h>
+#include <gtk/gtkfixed.h>
+
+
+
+/* Prend acte de l'association d'un binaire chargé. */
+typedef void (* attach_binary_fc) (GtkViewPanel *, GOpenidaBinary *);
+
+/* Réagit à un défilement quelconque. */
+typedef void (* scroll_fc) (GtkViewPanel *);
+
+
+/* Composant d'affichage générique (instance) */
+struct _GtkViewPanel
+{
+ GtkFixed parent; /* A laisser en premier */
+
+ GtkAdjustment *hadjustment; /* Barre de défilement horiz. */
+ GtkAdjustment *vadjustment; /* Barre de défilement vert. */
+
+ GdkGC *gc; /* Contexte graphique du rendu */
+ bool show_border; /* Affichage d'une bordure ? */
+
+ GOpenidaBinary *binary; /* Binaire à visualiser */
+
+ attach_binary_fc attach; /* Association avec un binaire */
+ scroll_fc scroll; /* Défilement du contenu */
+
+};
+
+/* Composant d'affichage générique (classe) */
+struct _GtkViewPanelClass
+{
+ GtkFixedClass parent; /* A laisser en premier */
+
+ /* Signaux */
+
+ void (* set_scroll_adjustments) (GtkViewPanel *, GtkAdjustment *, GtkAdjustment *);
+
+};
+
+
+/* S'assure que la valeur de défilement actuelle est valable. */
+void gtk_view_panel_reclamp_adjustment(GtkAdjustment *, gboolean *);
+
+/* Calcule la surface pleine utilisable pour le panneau. */
+void gtk_view_panel_compute_allocation(GtkViewPanel *, GtkAllocation *);
+
+
+
+#endif /* _GTK_VIEWPANEL_INT_H */
diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c
new file mode 100644
index 0000000..03279b2
--- /dev/null
+++ b/src/gtkext/gtkviewpanel.c
@@ -0,0 +1,361 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * gtkviewpanel.c - affichage de contenu de binaire
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "gtkviewpanel.h"
+
+
+#include "gtkviewpanel-int.h"
+#include "iodamarshal.h"
+
+
+
+/* Procède à l'initialisation de l'afficheur générique. */
+static void gtk_view_panel_class_init(GtkViewPanelClass *);
+
+/* Procède à l'initialisation de l'afficheur générique. */
+static void gtk_view_panel_init(GtkViewPanel *);
+
+/* Enregistre les défilements à associer au composant GTK. */
+static void gtk_view_panel_set_scroll_adjustments(GtkViewPanel *, GtkAdjustment *, GtkAdjustment *);
+
+/* Prend acte d'un nouveau défilement. */
+static void gtk_view_panel_adj_value_changed(GtkAdjustment *, GtkViewPanel *);
+
+/* Encadre la construction graphique initiale de l'affichage. */
+static void gtk_view_panel_realize(GtkWidget *);
+
+/* Met à jour l'affichage du composant d'affichage. */
+static gboolean gtk_view_panel_expose(GtkWidget *, GdkEventExpose *);
+
+
+
+/* Détermine le type du composant d'affichage générique. */
+G_DEFINE_TYPE(GtkViewPanel, gtk_view_panel, GTK_TYPE_FIXED)
+
+
+/******************************************************************************
+* *
+* Paramètres : class = classe GTK à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'afficheur générique. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_view_panel_class_init(GtkViewPanelClass *class)
+{
+ GtkWidgetClass *widget_class; /* Classe de haut niveau */
+
+ widget_class = GTK_WIDGET_CLASS(class);
+
+ widget_class->realize = gtk_view_panel_realize;
+ widget_class->expose_event = gtk_view_panel_expose;
+
+ class->set_scroll_adjustments = gtk_view_panel_set_scroll_adjustments;
+
+ widget_class->set_scroll_adjustments_signal =
+ g_signal_new(("set_scroll_adjustments"),
+ GTK_TYPE_VIEW_PANEL,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(GtkViewPanelClass, set_scroll_adjustments),
+ NULL, NULL,
+ g_cclosure_user_marshal_VOID__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ADJUSTMENT,
+ GTK_TYPE_ADJUSTMENT);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : view = composant GTK à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'afficheur générique. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_view_panel_init(GtkViewPanel *panel)
+{
+ gtk_fixed_set_has_window(GTK_FIXED(panel), TRUE);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = vue à compléter. *
+* hadjustment = nouveau défilement horizontal à intégrer. *
+* vadjustment = nouveau défilement vertical à intégrer. *
+* *
+* Description : Enregistre les défilements à associer au composant GTK. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_view_panel_set_scroll_adjustments(GtkViewPanel *panel, GtkAdjustment *hadjustment, GtkAdjustment *vadjustment)
+{
+ panel->hadjustment = hadjustment;
+ panel->vadjustment = vadjustment;
+
+ g_signal_connect(hadjustment, "value_changed",
+ G_CALLBACK(gtk_view_panel_adj_value_changed), panel);
+
+ g_signal_connect(vadjustment, "value_changed",
+ G_CALLBACK(gtk_view_panel_adj_value_changed), panel);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : adj = défilement à l'origine de l'action. *
+* panel = composant GTK à redessiner. *
+* *
+* Description : Prend acte d'un nouveau défilement. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_view_panel_adj_value_changed(GtkAdjustment *adj, GtkViewPanel *panel)
+{
+ panel->scroll(panel);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : adj = valeurs de défilement à consulter. *
+* changed = note une mise à jour de valeur. [OUT] *
+* *
+* Description : S'assure que la valeur de défilement actuelle est valable. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_view_panel_reclamp_adjustment(GtkAdjustment *adj, gboolean *changed)
+{
+ gdouble value; /* Valeur actuelle */
+
+ value = adj->value;
+
+ value = CLAMP(value, 0, adj->upper - adj->page_size);
+
+ if (value != adj->value)
+ {
+ adj->value = value;
+ *changed = TRUE;
+ }
+ else *changed = FALSE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = composant GTK à consulter. *
+* alloc = étendue à accorder à la vue. *
+* *
+* Description : Calcule la surface pleine utilisable pour le panneau. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_view_panel_compute_allocation(GtkViewPanel *panel, GtkAllocation *alloc)
+{
+ GtkWidget *widget; /* Autre version de la vue */
+ GtkAllocation *allocation; /* Raccourci d'utilisation #1 */
+ gint border_width; /* Raccourci d'utilisation #2 */
+
+ widget = GTK_WIDGET(panel);
+ allocation = &widget->allocation;
+ border_width = GTK_CONTAINER(panel)->border_width;
+
+ alloc->x = 0;
+ alloc->y = 0;
+
+ /*
+ if (viewport->shadow_type != GTK_SHADOW_NONE)
+ {
+ alloc->x = widget->style->xthickness;
+ alloc->y = widget->style->ythickness;
+ }
+ */
+
+ alloc->width = MAX(1, allocation->width - alloc->x * 2 - border_width * 2);
+ alloc->height = MAX(1, allocation->height - alloc->y * 2 - border_width * 2);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant GTK à préparer. *
+* *
+* Description : Encadre la construction graphique initiale de l'affichage. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void gtk_view_panel_realize(GtkWidget *widget)
+{
+ GdkWindowAttr attributes; /* Propriétés du composant */
+ guint attributes_mask; /* Masque de prise en compte */
+ GdkColor white; /* Couleur de fond normale */
+
+ GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.event_mask = gtk_widget_get_events(widget)
+ | GDK_BUTTON_PRESS_MASK | GDK_EXPOSURE_MASK;
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y;
+
+ widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
+ &attributes, attributes_mask);
+
+ gdk_window_set_user_data(widget->window, widget);
+
+ widget->style = gtk_style_attach(widget->style, widget->window);
+
+ gdk_color_white(gtk_widget_get_colormap(widget), &white);
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white);
+
+ GTK_VIEW_PANEL(widget)->gc = gdk_gc_new(GDK_DRAWABLE(widget->window));
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = composant GTK à redessiner. *
+* event = informations liées à l'événement. *
+* *
+* Description : Met à jour l'affichage du composant d'affichage. *
+* *
+* Retour : FALSE pour poursuivre la propagation de l'événement. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static gboolean gtk_view_panel_expose(GtkWidget *widget, GdkEventExpose *event)
+{
+ GtkViewPanel *panel;
+ GdkGCValues values; /* Propriétés du contexte */
+ GtkStyle *style; /* Style associé au composant */
+ int width; /* Largeur de l'élément */
+ int height; /* Hauteur de l'élément */
+
+ panel = GTK_VIEW_PANEL(widget);
+
+ if (panel->show_border)
+ {
+ gdk_gc_get_values(panel->gc, &values);
+ style = gtk_widget_get_style(widget);
+
+ gtk_widget_get_size_request(widget, &width, &height);
+
+ gdk_gc_set_foreground(panel->gc, &style->dark[GTK_WIDGET_STATE(widget)]);
+
+ gdk_draw_rectangle(GDK_DRAWABLE(widget->window), panel->gc,
+ FALSE, 0, 0, width - 1, height - 1);
+
+ gdk_gc_set_foreground(panel->gc, &values.foreground);
+
+ }
+
+ return FALSE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = composant GTK à mettre à jour. *
+* binary = binaire associé à intégrer. *
+* *
+* Description : Associe à un panneau d'affichage un binaire chargé. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void gtk_view_panel_attach_binary(GtkViewPanel *panel, GOpenidaBinary *binary)
+{
+ g_object_ref(G_OBJECT(binary));
+ panel->binary = binary;
+
+ panel->attach(panel, binary);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : panel = composant GTK à consulter. *
+* *
+* Description : Fournit le binaire associé à la représentation. *
+* *
+* Retour : Représentation de contenu binaire. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GOpenidaBinary *gtk_view_panel_get_binary(const GtkViewPanel *panel)
+{
+ return panel->binary;
+
+}
diff --git a/src/gtkext/gtkviewpanel.h b/src/gtkext/gtkviewpanel.h
new file mode 100644
index 0000000..ad6cc46
--- /dev/null
+++ b/src/gtkext/gtkviewpanel.h
@@ -0,0 +1,61 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * gtkviewpanel.h - prototypes pour l'affichage de contenu de binaire
+ *
+ * Copyright (C) 2010 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GTK_VIEWPANEL_H
+#define _GTK_VIEWPANEL_H
+
+
+#include <glib-object.h>
+
+
+#include "../analysis/binary.h"
+
+
+
+#define GTK_TYPE_VIEW_PANEL (gtk_view_panel_get_type())
+#define GTK_VIEW_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_VIEW_PANEL, GtkViewPanel))
+#define GTK_VIEW_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_VIEW_PANEL, GtkViewPanelClass))
+#define GTK_IS_VIEW_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_VIEW_PANEL))
+#define GTK_IS_VIEW_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_VIEW_PANEL))
+#define GTK_VIEW_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_VIEW_PANEL, GtkViewPanelClass))
+
+
+/* Composant d'affichage générique (instance) */
+typedef struct _GtkViewPanel GtkViewPanel;
+
+/* Composant d'affichage générique (classe) */
+typedef struct _GtkViewPanelClass GtkViewPanelClass;
+
+
+/* Détermine le type du composant d'affichage générique. */
+GType gtk_view_panel_get_type(void);
+
+/* Associe à un panneau d'affichage un binaire chargé. */
+void gtk_view_panel_attach_binary(GtkViewPanel *, GOpenidaBinary *);
+
+/* Fournit le binaire associé à la représentation. */
+GOpenidaBinary *gtk_view_panel_get_binary(const GtkViewPanel *);
+
+
+
+#endif /* _GTK_VIEWPANEL_H */