summaryrefslogtreecommitdiff
path: root/src/gui/menus
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/menus')
-rw-r--r--src/gui/menus/edition.c129
-rw-r--r--src/gui/menus/edition.h4
-rw-r--r--src/gui/menus/menubar.c29
3 files changed, 130 insertions, 32 deletions
diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c
index c524891..b77f864 100644
--- a/src/gui/menus/edition.c
+++ b/src/gui/menus/edition.c
@@ -100,25 +100,25 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b
deepmenubar = gtk_menu_new();
gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), deepmenubar);
- deepmenuitem = qck_create_menu_item(NULL, NULL, _("Hexadecimal"),
+ deepmenuitem = qck_create_menu_item(ref, "mnu_edit_switch_hex", _("Hexadecimal"),
G_CALLBACK(mcb_edition_switch_numeric_operand), bar);
add_accelerator_to_menu_item(deepmenuitem, "H", accgroup);
g_object_set_data(G_OBJECT(deepmenuitem), "kind_of_switch", GUINT_TO_POINTER(IOD_HEX));
gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem);
- deepmenuitem = qck_create_menu_item(NULL, NULL, _("Decimal"),
+ deepmenuitem = qck_create_menu_item(ref, "mnu_edit_switch_dec", _("Decimal"),
G_CALLBACK(mcb_edition_switch_numeric_operand), bar);
add_accelerator_to_menu_item(deepmenuitem, "D", accgroup);
g_object_set_data(G_OBJECT(deepmenuitem), "kind_of_switch", GUINT_TO_POINTER(IOD_DEC));
gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem);
- deepmenuitem = qck_create_menu_item(NULL, NULL, _("Octal"),
+ deepmenuitem = qck_create_menu_item(ref, "mnu_edit_switch_oct", _("Octal"),
G_CALLBACK(mcb_edition_switch_numeric_operand), bar);
add_accelerator_to_menu_item(deepmenuitem, "O", accgroup);
g_object_set_data(G_OBJECT(deepmenuitem), "kind_of_switch", GUINT_TO_POINTER(IOD_OCT));
gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem);
- deepmenuitem = qck_create_menu_item(NULL, NULL, _("Binary"),
+ deepmenuitem = qck_create_menu_item(ref, "mnu_edit_switch_bin", _("Binary"),
G_CALLBACK(mcb_edition_switch_numeric_operand), bar);
add_accelerator_to_menu_item(deepmenuitem, "B", accgroup);
g_object_set_data(G_OBJECT(deepmenuitem), "kind_of_switch", GUINT_TO_POINTER(IOD_BIN));
@@ -127,7 +127,7 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b
deepmenuitem = qck_create_menu_separator();
gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem);
- deepmenuitem = qck_create_menu_item(NULL, NULL, _("Default"),
+ deepmenuitem = qck_create_menu_item(ref, "mnu_edit_switch_def", _("Default"),
G_CALLBACK(mcb_edition_switch_numeric_operand), bar);
g_object_set_data(G_OBJECT(deepmenuitem), "kind_of_switch", GUINT_TO_POINTER(IOD_COUNT));
gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem);
@@ -166,6 +166,77 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b
/******************************************************************************
* *
+* Paramètres : bar = barre de menus à actualiser. *
+* addr = nouvelle adresse du curseur courant. *
+* info = barre de statut présentant les informations. *
+* *
+* Description : Met à jour les accès du menu "Edition" selon une position. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void update_access_in_menu_edition(GObject *ref, GtkBufferView *view, const vmpa2t *addr)
+{
+ bool state; /* Etat principal à considérer */
+ gboolean access; /* Accès à déterminer */
+ GBufferLine *line; /* Ligne de position courante */
+ GBufferSegment *segment; /* Segment actif s'il existe */
+ GObject *creator; /* Créateur à l'orgine du seg. */
+ GtkWidget *item; /* Elément de menu à traiter */
+
+ /* Préliminaire */
+
+ if (view == NULL)
+ state = false;
+ else
+ state = gtk_view_panel_get_position(GTK_VIEW_PANEL(view), &line, &segment);
+
+ if (state)
+ creator = g_buffer_segment_get_creator(segment);
+ else
+ creator = NULL;
+
+ /* Bascule des opérandes numériques */
+
+ access = (state && G_IS_IMM_OPERAND(creator));
+
+ item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_hex"));
+ gtk_widget_set_sensitive(item, access);
+
+ item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_dec"));
+ gtk_widget_set_sensitive(item, access);
+
+ item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_oct"));
+ gtk_widget_set_sensitive(item, access);
+
+ item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_bin"));
+ gtk_widget_set_sensitive(item, access);
+
+ item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_def"));
+ gtk_widget_set_sensitive(item, access);
+
+ /* Suivi de cibles */
+
+ access = (state && (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);
+
+ /* Nettoyage et sortie finale */
+
+ if (creator != NULL) g_object_unref(G_OBJECT(creator));
+
+ if (segment != NULL) g_object_unref(G_OBJECT(segment));
+ if (line != NULL) g_object_unref(G_OBJECT(line));
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : menuitem = élément de menu sélectionné. *
* bar = barre de menu parente. *
* *
@@ -292,40 +363,34 @@ static void mcb_edition_follow_ref(GtkMenuItem *menuitem, GMenuBar *bar)
if (gtk_view_panel_get_position(vpanel, &line, &segment))
{
- if (segment != NULL)
- creator = g_buffer_segment_get_creator(segment);
- else
- creator = NULL;
-
- if (creator != NULL)
- {
- /**
- * On fait le pari de reposer uniquement sur des adresses virtuelles !
- * A changer dans un futur ?
- */
-
- virt = VMPA_NO_VIRTUAL;
+ creator = g_buffer_segment_get_creator(segment);
+ assert(creator != NULL);
- if (G_IS_TARGET_OPERAND(creator))
- virt = g_target_operand_get_addr(G_TARGET_OPERAND(creator));
+ /**
+ * On fait le pari de reposer uniquement sur des adresses virtuelles !
+ * A changer dans un futur ?
+ */
- else if (G_IS_IMM_OPERAND(creator))
- {
- if (!g_imm_operand_to_virt_t(G_IMM_OPERAND(creator), &virt))
- virt = VMPA_NO_VIRTUAL;
- }
+ virt = VMPA_NO_VIRTUAL;
- if (virt != VMPA_NO_VIRTUAL)
- {
- init_vmpa(&addr, VMPA_NO_PHYSICAL, virt);
- gtk_view_panel_scroll_to_address(vpanel, &addr, SPT_CENTER);
- }
+ if (G_IS_TARGET_OPERAND(creator))
+ virt = g_target_operand_get_addr(G_TARGET_OPERAND(creator));
- g_object_unref(creator);
+ else if (G_IS_IMM_OPERAND(creator))
+ {
+ if (!g_imm_operand_to_virt_t(G_IMM_OPERAND(creator), &virt))
+ virt = VMPA_NO_VIRTUAL;
+ }
+ if (virt != VMPA_NO_VIRTUAL)
+ {
+ init_vmpa(&addr, VMPA_NO_PHYSICAL, virt);
+ gtk_view_panel_scroll_to_address(vpanel, &addr, SPT_CENTER);
}
- if (segment != NULL) g_object_unref(G_OBJECT(segment));
+ g_object_unref(creator);
+
+ g_object_unref(G_OBJECT(segment));
g_object_unref(G_OBJECT(line));
}
diff --git a/src/gui/menus/edition.h b/src/gui/menus/edition.h
index b430a8b..82a48bd 100644
--- a/src/gui/menus/edition.h
+++ b/src/gui/menus/edition.h
@@ -30,12 +30,16 @@
#include "menubar.h"
+#include "../../gtkext/gtkbufferview.h"
/* Construit le menu "Edition". */
GtkWidget *build_menu_edition(GObject *, GtkAccelGroup *, GMenuBar *);
+/* Met à jour les accès du menu "Edition" selon une position. */
+void update_access_in_menu_edition(GObject *, GtkBufferView *, const vmpa2t *);
+
#endif /* _GUI_MENUS_EDITION_H */
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c
index 1fc1b6f..cbb6ae2 100644
--- a/src/gui/menus/menubar.c
+++ b/src/gui/menus/menubar.c
@@ -80,6 +80,9 @@ static void manage_view_in_menu_bar(GMenuBar *, GtkViewPanel *, bool);
/* Lance une actualisation du fait d'un changement de vue. */
static void update_menu_bar_for_view(GMenuBar *, GtkViewPanel *);
+/* Met à jour les accès aux menus en fonction de la position. */
+static void track_caret_address_for_menu_bar(GMenuBar *, GtkBufferView *, const vmpa2t *);
+
/* Lance une actualisation relative à l'étendue du projet. */
static void update_menu_bar_for_project(GMenuBar *, GStudyProject *);
@@ -115,6 +118,7 @@ static void g_menu_bar_class_init(GMenuBarClass *klass)
editem->manage_view = (manage_item_view_fc)manage_view_in_menu_bar;
editem->update_view = (update_item_view_fc)update_menu_bar_for_view;
+ editem->track_caret = (track_caret_in_view_fc)track_caret_address_for_menu_bar;
editem->update_project = (update_project_fc)update_menu_bar_for_project;
}
@@ -345,6 +349,31 @@ static void update_menu_bar_for_view(GMenuBar *bar, GtkViewPanel *view)
/******************************************************************************
* *
+* Paramètres : bar = barre de menus à actualiser. *
+* addr = nouvelle adresse du curseur courant. *
+* info = barre de statut présentant les informations. *
+* *
+* Description : Met à jour les accès aux menus en fonction de la position. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void track_caret_address_for_menu_bar(GMenuBar *bar, GtkBufferView *view, const vmpa2t *addr)
+{
+ GEditorItem *item; /* Autre version de l'élément */
+
+ item = G_EDITOR_ITEM(bar);
+
+ update_access_in_menu_edition(item->ref, view, addr);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : bar = barre de menus à actualiser. *
* project = projet visé par la procédure. *
* *