summaryrefslogtreecommitdiff
path: root/src/gui/menus
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-01-31 22:50:42 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-01-31 22:50:42 (GMT)
commitf6eb49749d627de7d556139a392f73f0ca2862e8 (patch)
treedf84f4c54f9f4f59e9b392b66d4d3ee1ce8633c0 /src/gui/menus
parent7ba93e4d9e3e722d8771d665c5217510105375d2 (diff)
Provided the current active object in display panels.
Diffstat (limited to 'src/gui/menus')
-rw-r--r--src/gui/menus/edition.c75
-rw-r--r--src/gui/menus/menubar.c15
2 files changed, 34 insertions, 56 deletions
diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c
index 848d04c..08745b6 100644
--- a/src/gui/menus/edition.c
+++ b/src/gui/menus/edition.c
@@ -239,26 +239,21 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b
void update_access_in_menu_edition(GObject *ref, GtkDisplayPanel *panel, const vmpa2t *addr)
{
- bool state; /* Etat principal à considérer */
- gboolean access; /* Accès à déterminer */
- GBufferLine *line; /* Ligne de position courante */
GObject *creator; /* Créateur à l'orgine du seg. */
+ gboolean access; /* Accès à déterminer */
GtkWidget *item; /* Elément de menu à traiter */
/* Préliminaire */
if (panel == NULL || addr == NULL)
- {
- state = false;
- line = NULL;
creator = NULL;
- }
+
else
- state = gtk_display_panel_get_position(panel, &line, &creator);
+ creator = gtk_display_panel_get_active_object(panel);
/* Bascule des opérandes numériques */
- access = (state && G_IS_IMM_OPERAND(creator));
+ access = (G_IS_IMM_OPERAND(creator));
item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_hex"));
gtk_widget_set_sensitive(item, access);
@@ -277,12 +272,12 @@ void update_access_in_menu_edition(GObject *ref, GtkDisplayPanel *panel, const v
/* Suivi de cibles */
- access = (state && (G_IS_TARGET_OPERAND(creator) || G_IS_IMM_OPERAND(creator)));
+ access = ((G_IS_TARGET_OPERAND(creator) || G_IS_IMM_OPERAND(creator)));
item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_follow_ref"));
gtk_widget_set_sensitive(item, access);
- access = state;
+ access = (addr != NULL);;
item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_list_xrefs"));
gtk_widget_set_sensitive(item, access);
@@ -290,7 +285,6 @@ void update_access_in_menu_edition(GObject *ref, GtkDisplayPanel *panel, const v
/* Nettoyage et sortie finale */
if (creator != NULL) g_object_unref(G_OBJECT(creator));
- if (line != NULL) g_object_unref(G_OBJECT(line));
}
@@ -355,29 +349,28 @@ static void mcb_edition_switch_numeric_operand(GtkMenuItem *menuitem, gpointer u
{
ImmOperandDisplay display; /* Type de basculement */
GLoadedPanel *panel; /* Afficheur effectif de code */
- GBufferLine *line; /* Ligne de position courante */
GObject *creator; /* Créateur à l'orgine du seg. */
- GDbSwitcher *switcher; /* Bascule à mettre en place */
- const mrange_t *range; /* Emplacement de la ligne */
+ const vmpa2t *addr; /* Position courante */
GLoadedBinary *binary; /* Binaire en cours d'étude */
GArchProcessor *proc; /* Propriétaire d'instructions */
GArchInstruction *instr; /* Instruction liée à la ligne */
+ GDbSwitcher *switcher; /* Bascule à mettre en place */
display = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(menuitem), "kind_of_switch"));
panel = get_current_view();
- if (GTK_IS_DISPLAY_PANEL(panel)
- && gtk_display_panel_get_position(GTK_DISPLAY_PANEL(panel), &line, &creator))
+ if (GTK_IS_DISPLAY_PANEL(panel))
{
+ creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel));
assert(G_IS_IMM_OPERAND(creator));
- range = g_buffer_line_get_range(line);
+ addr = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel));
binary = get_current_binary();
proc = g_loaded_binary_get_processor(binary);
- instr = g_arch_processor_find_instr_by_address(proc, get_mrange_addr(range));
+ instr = g_arch_processor_find_instr_by_address(proc, addr);
assert(instr != NULL);
switcher = g_db_switcher_new(instr, G_IMM_OPERAND(creator), display);
@@ -390,7 +383,6 @@ static void mcb_edition_switch_numeric_operand(GtkMenuItem *menuitem, gpointer u
g_object_unref(G_OBJECT(binary));
g_object_unref(creator);
- g_object_unref(G_OBJECT(line));
}
@@ -434,7 +426,6 @@ static void mcb_edition_go_back(GtkMenuItem *menuitem, GMenuBar *bar)
static void mcb_edition_follow_ref(GtkMenuItem *menuitem, gpointer unused)
{
GLoadedPanel *panel; /* Afficheur effectif de code */
- GBufferLine *line; /* Ligne de position courante */
GObject *creator; /* Créateur à l'orgine du seg. */
bool defined; /* Adresse définie ? */
vmpa2t addr; /* Adresse de destination */
@@ -442,9 +433,9 @@ static void mcb_edition_follow_ref(GtkMenuItem *menuitem, gpointer unused)
panel = get_current_view();
- if (GTK_IS_DISPLAY_PANEL(panel)
- && gtk_display_panel_get_position(GTK_DISPLAY_PANEL(panel), &line, &creator))
+ if (GTK_IS_DISPLAY_PANEL(panel))
{
+ creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel));
assert(creator != NULL);
defined = false;
@@ -468,7 +459,6 @@ static void mcb_edition_follow_ref(GtkMenuItem *menuitem, gpointer unused)
gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), &addr);
g_object_unref(creator);
- g_object_unref(G_OBJECT(line));
}
@@ -493,21 +483,19 @@ static void mcb_edition_follow_ref(GtkMenuItem *menuitem, gpointer unused)
static void mcb_edition_list_xrefs(GtkMenuItem *menuitem, GMenuBar *bar)
{
GLoadedPanel *panel; /* Afficheur effectif de code */
- GBufferLine *line; /* Ligne de position courante */
- const mrange_t *range; /* Couverture en mémoire */
+ const vmpa2t *addr; /* Position courante */
GLoadedBinary *binary; /* Représentation binaire */
GArchProcessor *proc; /* Processeur de l'architecture*/
GArchInstruction *instr; /* Point de croisements */
GObject *ref; /* Espace de référencements */
GtkWidget *dialog; /* Boîte de dialogue à montrer */
- vmpa2t *addr; /* Adresse de destination */
+ vmpa2t *dest; /* Adresse de destination */
panel = get_current_view();
- if (GTK_IS_DISPLAY_PANEL(panel)
- && gtk_display_panel_get_position(GTK_DISPLAY_PANEL(panel), &line, NULL))
+ if (GTK_IS_DISPLAY_PANEL(panel))
{
- range = g_buffer_line_get_range(line);
+ addr = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel));
binary = get_current_binary();
proc = g_loaded_binary_get_processor(binary);
@@ -520,32 +508,33 @@ static void mcb_edition_list_xrefs(GtkMenuItem *menuitem, GMenuBar *bar)
* Il faut ainsi être plus souple, et se baser sur l'espace couvert par
* une ligne mais sur l'adresse uniquement.
*/
- instr = g_arch_processor_find_instr_by_address(proc, get_mrange_addr(range));
+ instr = g_arch_processor_find_instr_by_address(proc, addr);
- ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar));
+ if (instr != NULL)
+ {
+ ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar));
- dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), binary, instr, true);
+ dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), binary, instr, true);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
- {
- addr = get_address_from_gotox_dialog(dialog);
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+ {
+ dest = get_address_from_gotox_dialog(dialog);
- gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), addr);
+ gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), dest);
- delete_vmpa(addr);
+ delete_vmpa(dest);
- }
+ }
- gtk_widget_destroy(dialog);
+ gtk_widget_destroy(dialog);
- if (instr != NULL)
g_object_unref(G_OBJECT(instr));
+ }
+
g_object_unref(G_OBJECT(proc));
g_object_unref(G_OBJECT(binary));
- g_object_unref(G_OBJECT(line));
-
}
g_object_unref(G_OBJECT(panel));
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c
index 32a8f20..989d964 100644
--- a/src/gui/menus/menubar.c
+++ b/src/gui/menus/menubar.c
@@ -308,21 +308,13 @@ static void update_menu_bar_for_view(GMenuBar *bar, GtkDisplayPanel *panel)
static void notify_focus_change_for_menu_bar(GMenuBar *bar, GtkDisplayPanel *panel)
{
- GBufferLine *line; /* Ligne de position courante */
- const mrange_t *range; /* Couverture en mémoire */
const vmpa2t *addr; /* Position courante */
GEditorItem *item; /* Autre version de l'élément */
- if (panel != NULL && gtk_display_panel_get_position(panel, &line, NULL))
- {
- range = g_buffer_line_get_range(line);
- addr = get_mrange_addr(range);
- }
+ if (panel != NULL)
+ addr = gtk_display_panel_get_caret_location(panel);
else
- {
- line = NULL;
addr = NULL;
- }
item = G_EDITOR_ITEM(bar);
@@ -332,9 +324,6 @@ static void notify_focus_change_for_menu_bar(GMenuBar *bar, GtkDisplayPanel *pan
update_access_in_menu_binary(item->ref, panel);
- if (line != NULL)
- g_object_unref(G_OBJECT(line));
-
}