diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-01-23 01:05:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-01-23 01:05:58 (GMT) |
commit | d761eddfd4b5a27620aaa5e67a0e2e2bc5d55cb1 (patch) | |
tree | dc0d69813fef1b982c3a0fbdc25a00a6183b0852 /src/gui | |
parent | d487ea54850c85ea22df22af3b21b57d9ad0fd2f (diff) |
Added menus to change the current displayed view. Do not try the source view.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@228 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/editem.c | 19 | ||||
-rw-r--r-- | src/gui/editem.h | 3 | ||||
-rw-r--r-- | src/gui/menus/view.c | 81 |
3 files changed, 103 insertions, 0 deletions
diff --git a/src/gui/editem.c b/src/gui/editem.c index 4afd7bd..0516f4d 100644 --- a/src/gui/editem.c +++ b/src/gui/editem.c @@ -117,6 +117,25 @@ GtkWidget *g_editor_item_get_widget(const GEditorItem *item) * * * Paramètres : item = instance à consulter. * * * +* Description : Fournit le gestionnaire du binaire courant. * +* * +* Retour : Instance en place ou NULL si aucune. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GOpenidaBinary *g_editor_item_get_current_binary(const GEditorItem *item) +{ + return g_object_get_data(item->ref, "current_binary"); + +} + + +/****************************************************************************** +* * +* Paramètres : item = instance à consulter. * +* * * Description : Fournit l'affichage de binaire courant. * * * * Retour : Instance en place ou NULL si aucune. * diff --git a/src/gui/editem.h b/src/gui/editem.h index 40be0c7..286013c 100644 --- a/src/gui/editem.h +++ b/src/gui/editem.h @@ -58,6 +58,9 @@ GType g_editor_item_get_type(void); /* Fournit le composant GTK associé à l'élément réactif. */ GtkWidget *g_editor_item_get_widget(const GEditorItem *); +/* Fournit le gestionnaire du binaire courant. */ +GOpenidaBinary *g_editor_item_get_current_binary(const GEditorItem *); + /* Fournit l'affichage de binaire courant. */ GtkViewPanel *g_editor_item_get_current_view(const GEditorItem *); diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index 85e65f7..273b41b 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -28,10 +28,16 @@ #include <i18n.h> +#include "../editem-int.h" +#include "../../project.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkdockstation.h" +/* Réagit avec le menu "Affichage -> Vue xxx". */ +static void mcb_view_change_support(GtkRadioMenuItem *, GMenuBar *); + /* Réagit avec le menu "Affichage -> Adresse virtuelle". */ static void mcb_view_addresses(GtkCheckMenuItem *, GMenuBar *); @@ -59,6 +65,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) GtkWidget *result; /* Support à retourner */ GtkWidget *menubar; /* Support pour éléments */ GtkWidget *submenuitem; /* Sous-élément de menu */ + GSList *rgroup; /* Groupe des boutons radio */ result = gtk_menu_item_new_with_mnemonic(_("_View")); gtk_widget_show(result); @@ -66,6 +73,28 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) menubar = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(result), menubar); + submenuitem = qck_create_radio_menu_item(ref, "textview", NULL, _("Text view"), + G_CALLBACK(mcb_view_change_support), bar); + add_accelerator_to_menu_item(submenuitem, "F2", accgroup); + g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_BLOCK)); + gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + + rgroup = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(submenuitem)); + + submenuitem = qck_create_radio_menu_item(ref, "graphview", rgroup, _("Graph view"), + G_CALLBACK(mcb_view_change_support), bar); + add_accelerator_to_menu_item(submenuitem, "F3", accgroup); + g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_GRAPH)); + gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + + rgroup = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(submenuitem)); + + submenuitem = qck_create_radio_menu_item(ref, "sourceview", rgroup, _("Source code"), + G_CALLBACK(mcb_view_change_support), bar); + add_accelerator_to_menu_item(submenuitem, "F4", accgroup); + g_object_set_data(G_OBJECT(submenuitem), "kind_of_view", GUINT_TO_POINTER(BVW_SOURCE)); + gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -134,6 +163,58 @@ void update_menu_view_for_view(GtkWidget *widget, GtkViewPanel *view, GMenuBar * * Paramètres : menuitem = élément de menu ayant basculé. * * bar = barre de menu parente. * * * +* Description : Réagit avec le menu "Affichage -> Vue xxx". * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void mcb_view_change_support(GtkRadioMenuItem *menuitem, GMenuBar *bar) +{ + GSList *group; /* Liste de menus radio */ + GSList *iter; /* Boucle de parcours */ + BinaryView view; /* Nouvelle vue à présenter */ + GtkViewPanel *vpanel; /* Afficheur effectif de code */ + GtkWidget *station; /* Base du remplacement */ + GOpenidaBinary *binary; /* Edition courante */ + GtkWidget *scroll; /* Nouveau support à utiliser */ + + /* On ne traite qu'une seule fois ! */ + if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem))) return; + + group = gtk_radio_menu_item_get_group(menuitem); + + for (iter = group; iter != NULL; iter = g_slist_next(iter)) + { + if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(iter->data))) continue; + + view = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(iter->data), "kind_of_view")); + + 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)); + scroll = get_view_for_openida_project_binary(get_current_openida_project(), + binary, view, &vpanel); + + gtk_dock_panel_change_active_widget(GTK_DOCK_STATION(station), scroll); + + change_editor_items_current_view(G_EDITOR_ITEM(bar)->ref, vpanel); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : menuitem = élément de menu ayant basculé. * +* bar = barre de menu parente. * +* * * Description : Réagit avec le menu "Affichage -> Adresse virtuelle". * * * * Retour : - * |