From 4bc86c5dc8d3cfa9780103b56f52024a49913c22 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Sat, 26 Mar 2016 22:21:24 +0100 Subject: Fixed various bugs and mistakes. --- ChangeLog | 18 ++++++++++++++++++ src/glibext/delayed.c | 2 +- src/gtkext/gtkbufferview.c | 43 ++++++++++++++++++++++++------------------- src/gtkext/gtkbufferview.h | 3 --- src/gtkext/gtkgraphview.c | 24 ++++++++++++++++++++++++ src/gtkext/gtkviewpanel-int.h | 4 ++++ src/gtkext/gtkviewpanel.c | 14 ++++++++------ src/gui/menus/edition.c | 5 +---- src/gui/menus/view.c | 2 -- 9 files changed, 80 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc07b31..87ff9df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,23 @@ 16-03-26 Cyrille Bagard + * src/glibext/delayed.c: + Temporary avoid a crash. This needs to be fixed. + + * src/gtkext/gtkbufferview.c: + * src/gtkext/gtkbufferview.h: + * src/gtkext/gtkgraphview.c: + * src/gtkext/gtkviewpanel-int.h: + Provide the caret location in memory and in the right way. + + * src/gtkext/gtkviewpanel.c: + Update code. Restore the computing of the preferred size. + + * src/gui/menus/edition.c: + * src/gui/menus/view.c: + Update code. + +16-03-26 Cyrille Bagard + * src/analysis/disass/Makefile.am: Add the 'dragon.[ch]' files to libanalysisdisass_la_SOURCES. diff --git a/src/glibext/delayed.c b/src/glibext/delayed.c index a83fae4..1d27448 100644 --- a/src/glibext/delayed.c +++ b/src/glibext/delayed.c @@ -603,7 +603,7 @@ static void *g_work_group_process(GWorkGroup *group) g_delayed_work_process(work, group->statusbar); - g_object_unref(G_OBJECT(work)); + //g_object_unref(G_OBJECT(work)); // FIXME if (g_atomic_int_dec_and_test(&group->pending)) g_cond_broadcast(&group->wait_cond); diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index d54560c..f775de5 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -73,6 +73,9 @@ static void gtk_buffer_view_compute_scroll_inc(GtkBufferView *, gint, GtkOrienta /* Réagit à un défilement chez une barre associée au composant. */ static void gtk_buffer_view_adjust_scroll_value(GtkBufferView *, GtkAdjustment *, GtkOrientation); +/* Indique la position courante du curseur. */ +static const vmpa2t *gtk_buffer_view_get_caret_location(const GtkBufferView *); + /* Indique la position d'affichage d'une adresse donnée. */ static bool gtk_buffer_view_get_address_coordinates(const GtkBufferView *, const vmpa2t *, gint *, gint *, ScrollPositionTweak); @@ -145,6 +148,8 @@ static void gtk_buffer_view_class_init(GtkBufferViewClass *class) panel_class->compute_size = (compute_requested_size_fc)gtk_buffer_view_compute_requested_size; panel_class->compute_inc = (compute_scroll_inc_fc)gtk_buffer_view_compute_scroll_inc; panel_class->adjust = (adjust_scroll_value_fc)gtk_buffer_view_adjust_scroll_value; + + panel_class->get_caret_loc = (get_caret_location_fc)gtk_buffer_view_get_caret_location; panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_buffer_view_get_address_coordinates; panel_class->get_position = (get_view_position_fc)gtk_buffer_view_get_position; panel_class->move_caret_to = (move_caret_to_fc)_gtk_buffer_view_move_caret_to; @@ -723,6 +728,25 @@ static void gtk_buffer_view_adjust_scroll_value(GtkBufferView *view, GtkAdjustme /****************************************************************************** * * +* Paramètres : view = composant GTK à manipuler. * +* * +* Description : Indique la position courante du curseur. * +* * +* Retour : Emplacement courant du curseur ou NULL si aucun. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const vmpa2t *gtk_buffer_view_get_caret_location(const GtkBufferView *view) +{ + return view->caret_addr; + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à consulter. * * addr = adresse à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * @@ -1052,25 +1076,6 @@ static void gtk_buffer_view_relocate_caret(GtkBufferView *view, const GdkRectang * * * Paramètres : view = composant GTK à manipuler. * * * -* Description : Indique la position courante du curseur. * -* * -* Retour : Emplacement courant du curseur. * -* * -* Remarques : - * -* * -******************************************************************************/ - -const vmpa2t *gtk_buffer_view_get_caret_location(const GtkBufferView *view) -{ - return view->caret_addr; - -} - - -/****************************************************************************** -* * -* Paramètres : view = composant GTK à manipuler. * -* * * Description : Redémarre l'affichage du curseur à l'emplacement courant. * * * * Retour : - * diff --git a/src/gtkext/gtkbufferview.h b/src/gtkext/gtkbufferview.h index 6b5cf30..06249cf 100644 --- a/src/gtkext/gtkbufferview.h +++ b/src/gtkext/gtkbufferview.h @@ -65,9 +65,6 @@ GBufferView *gtk_buffer_view_get_buffer(const GtkBufferView *); /* Déplace le curseur à un emplacement en extrémité. */ bool gtk_buffer_view_move_caret_to(GtkBufferView *, bool, gint *); -/* Indique la position courante du curseur. */ -const vmpa2t *gtk_buffer_view_get_caret_location(const GtkBufferView *); - #endif /* _GTK_BUFFERVIEW_H */ diff --git a/src/gtkext/gtkgraphview.c b/src/gtkext/gtkgraphview.c index c10d9c1..a2c0cd3 100644 --- a/src/gtkext/gtkgraphview.c +++ b/src/gtkext/gtkgraphview.c @@ -83,6 +83,9 @@ static void gtk_graph_view_prepare_resize(GtkGraphView *); /* Réagit à la sélection externe d'une adresse. */ static void gtk_graph_view_define_main_address(GtkGraphView *, const vmpa2t *); +/* Indique la position courante du curseur. */ +static const vmpa2t *gtk_graph_view_get_caret_location(const GtkGraphView *); + /* Indique la position d'affichage d'une adresse donnée. */ static bool gtk_graph_view_get_address_coordinates(const GtkGraphView *, const vmpa2t *addr, gint *x, gint *y, ScrollPositionTweak tweak); @@ -131,6 +134,8 @@ static void gtk_graph_view_class_init(GtkGraphViewClass *class) panel_class->compute_size = (compute_requested_size_fc)gtk_graph_view_compute_requested_size; panel_class->adjust = (adjust_scroll_value_fc)gtk_graph_view_adjust_scroll_value; panel_class->define = (define_address_fc)gtk_graph_view_define_main_address; + + panel_class->get_caret_loc = (get_caret_location_fc)gtk_graph_view_get_caret_location; panel_class->get_coordinates = (get_addr_coordinates_fc)gtk_graph_view_get_address_coordinates; panel_class->move_caret_to = (move_caret_to_fc)gtk_graph_view_move_caret_to; panel_class->cache_glance = (cache_glance_fc)gtk_graph_view_cache_glance; @@ -380,6 +385,25 @@ static void gtk_graph_view_define_main_address(GtkGraphView *view, const vmpa2t /****************************************************************************** * * +* Paramètres : view = composant GTK à manipuler. * +* * +* Description : Indique la position courante du curseur. * +* * +* Retour : Emplacement courant du curseur ou NULL si aucun. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static const vmpa2t *gtk_graph_view_get_caret_location(const GtkGraphView *view) +{ + return NULL; /* FIXME */ + +} + + +/****************************************************************************** +* * * Paramètres : view = composant GTK à consulter. * * addr = adresse à présenter à l'écran. * * x = position horizontale au sein du composant. [OUT] * diff --git a/src/gtkext/gtkviewpanel-int.h b/src/gtkext/gtkviewpanel-int.h index fcd6ffb..9f53051 100644 --- a/src/gtkext/gtkviewpanel-int.h +++ b/src/gtkext/gtkviewpanel-int.h @@ -51,6 +51,9 @@ typedef void (* define_address_fc) (GtkViewPanel *, const vmpa2t *); /* Actualise les besoins internes avant un redimensionnement. */ typedef void (* prepare_resize_fc) (GtkViewPanel *); +/* Indique la position courante du curseur. */ +typedef const vmpa2t * (* get_caret_location_fc) (const GtkViewPanel *); + /* Indique la position d'affichage d'une adresse donnée. */ typedef bool (* get_addr_coordinates_fc) (const GtkViewPanel *, const vmpa2t *, gint *, gint *, ScrollPositionTweak); @@ -96,6 +99,7 @@ struct _GtkViewPanelClass compute_scroll_inc_fc compute_inc; /* Calcul des bonds */ adjust_scroll_value_fc adjust; /* Réaction à un défilement */ define_address_fc define; /* Centrage sur une partie */ + get_caret_location_fc get_caret_loc; /* Adresse du curseur */ get_addr_coordinates_fc get_coordinates;/* Conversion adresse <-> pos. */ get_view_position_fc get_position; /* Indications sur la position */ move_caret_to_fc move_caret_to; /* Déplacement du curseur */ diff --git a/src/gtkext/gtkviewpanel.c b/src/gtkext/gtkviewpanel.c index 7dab444..4d5a57e 100644 --- a/src/gtkext/gtkviewpanel.c +++ b/src/gtkext/gtkviewpanel.c @@ -121,8 +121,8 @@ static void gtk_view_panel_class_init(GtkViewPanelClass *class) widget_class->realize = gtk_view_panel_realize; widget_class->size_allocate = gtk_view_panel_size_allocate; widget_class->draw = gtk_view_panel_draw; - //widget_class->get_preferred_height = gtk_view_panel_get_preferred_height; - //widget_class->get_preferred_width = gtk_view_panel_get_preferred_width; + widget_class->get_preferred_height = gtk_view_panel_get_preferred_height; + widget_class->get_preferred_width = gtk_view_panel_get_preferred_width; panel_class->compute_inc = gtk_view_panel_compute_scroll_inc; @@ -825,17 +825,19 @@ GLoadedBinary *gtk_view_panel_get_binary(const GtkViewPanel *panel) * * * Description : Indique la position courante du curseur. * * * -* Retour : Emplacement courant du curseur. * +* Retour : Emplacement courant du curseur ou NULL si aucun. * * * * Remarques : - * * * ******************************************************************************/ -#include "gtkbufferview.h" // FIXME + const vmpa2t *gtk_view_panel_get_caret_location(const GtkViewPanel *panel) { - /* FIXME */ + const vmpa2t *result; /* Adresse à retourner */ + + result = GTK_VIEW_PANEL_GET_CLASS(panel)->get_caret_loc(panel); - return gtk_buffer_view_get_caret_location(GTK_BUFFER_VIEW(panel)); + return result; } diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c index 3be2a8e..b507f0a 100644 --- a/src/gui/menus/edition.c +++ b/src/gui/menus/edition.c @@ -595,10 +595,7 @@ static void mcb_edition_bookmarks_toggle(GtkMenuItem *menuitem, GMenuBar *bar) panel = g_editor_item_get_current_view(editem); - if (!GTK_IS_BUFFER_VIEW(panel)) - curloc = NULL; - else - curloc = gtk_buffer_view_get_caret_location(GTK_BUFFER_VIEW(panel)); + curloc = gtk_view_panel_get_caret_location(panel); /* Accès à la collection */ diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index def1859..d3bebc3 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -397,14 +397,12 @@ static void mcb_view_change_support(GtkRadioMenuItem *menuitem, GMenuBar *bar) * * - GtkBlockView / GtkGraphView / GtkSourceView (avec GtkViewport intégré) * - GtkScrolledWindow - * - GtkNotebook * - GtkDockStation * */ vpanel = g_editor_item_get_current_view(G_EDITOR_ITEM(bar)); station = gtk_widget_get_parent(GTK_WIDGET(vpanel)); /* ScrollWindow */ - station = gtk_widget_get_parent(station); /* NoteBook */ station = gtk_widget_get_parent(station); /* DockStation */ binary = g_editor_item_get_current_binary(G_EDITOR_ITEM(bar)); -- cgit v0.11.2-87-g4458