diff options
Diffstat (limited to 'src/gtkext/gtkbinview.c')
-rw-r--r-- | src/gtkext/gtkbinview.c | 267 |
1 files changed, 52 insertions, 215 deletions
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 } |