summaryrefslogtreecommitdiff
path: root/src/gui/menus
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/menus')
-rw-r--r--src/gui/menus/Makefile.am1
-rw-r--r--src/gui/menus/file.c4
-rw-r--r--src/gui/menus/menubar.c31
-rw-r--r--src/gui/menus/project.c227
-rw-r--r--src/gui/menus/project.h45
-rw-r--r--src/gui/menus/view.c2
-rw-r--r--src/gui/menus/view.h2
7 files changed, 308 insertions, 4 deletions
diff --git a/src/gui/menus/Makefile.am b/src/gui/menus/Makefile.am
index 1275394..4640fd8 100644
--- a/src/gui/menus/Makefile.am
+++ b/src/gui/menus/Makefile.am
@@ -6,6 +6,7 @@ libguimenus_la_SOURCES = \
file.h file.c \
help.h help.c \
menubar.h menubar.c \
+ project.h project.c \
view.h view.c
libguimenus_la_LDFLAGS =
diff --git a/src/gui/menus/file.c b/src/gui/menus/file.c
index fade47d..95b50cb 100644
--- a/src/gui/menus/file.c
+++ b/src/gui/menus/file.c
@@ -55,8 +55,8 @@ GtkWidget *build_menu_file(GObject *ref, GtkAccelGroup *accgroup)
{
GtkWidget *result; /* Support à retourner */
GtkWidget *menubar; /* Support pour éléments */
- GtkWidget *submenuitem; /* Sous-élément de menu #2 */
- GtkWidget *deepmenuitem; /* Sous-élément de menu #1 */
+ GtkWidget *submenuitem; /* Sous-élément de menu #1 */
+ GtkWidget *deepmenuitem; /* Sous-élément de menu #2 */
result = gtk_menu_item_new_with_mnemonic(_("_File"));
gtk_widget_show(result);
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c
index a847d40..a7559cd 100644
--- a/src/gui/menus/menubar.c
+++ b/src/gui/menus/menubar.c
@@ -28,6 +28,7 @@
#include "debug.h"
#include "file.h"
#include "help.h"
+#include "project.h"
#include "view.h"
#include "../editem-int.h"
@@ -40,6 +41,7 @@ struct _GMenuBar
GtkWidget *file; /* Menu "Fichier" */
GtkWidget *view; /* Menu "Affichage" */
+ GtkWidget *project; /* Menu "Projet" */
GtkWidget *debug; /* Menu "Débogage" */
GtkWidget *help; /* Menu "Aide" */
@@ -63,6 +65,9 @@ static void g_menu_bar_init(GMenuBar *);
/* Lance une actualisation du fait d'un changement de vue. */
static void update_menu_bar_for_view(GMenuBar *, GtkViewPanel *);
+/* Lance une actualisation relative à l'étendue du projet. */
+static void update_menu_bar_for_project(GMenuBar *, GStudyProject *);
+
/* Indique le type défini pour la barre de menus de la fenêtre principale. */
@@ -111,6 +116,7 @@ static void g_menu_bar_init(GMenuBar *bar)
gtk_widget_show(item->widget);
item->update_view = (update_item_view_fc)update_menu_bar_for_view;
+ item->update_project = (update_project_fc)update_menu_bar_for_project;
}
@@ -152,6 +158,11 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup)
result->view = build_menu_view(ref, accgroup, result);
gtk_container_add(GTK_CONTAINER(item->widget), result->view);
+ /* Projet */
+
+ result->project = build_menu_project(ref, accgroup, result);
+ gtk_container_add(GTK_CONTAINER(item->widget), result->project);
+
/* Débogage */
result->debug = build_menu_debug(ref, accgroup);
@@ -185,3 +196,23 @@ static void update_menu_bar_for_view(GMenuBar *bar, GtkViewPanel *view)
update_menu_view_for_view(bar->view, view, bar);
}
+
+
+/******************************************************************************
+* *
+* Paramètres : bar = barre de menus à actualiser. *
+* project = projet visé par la procédure. *
+* *
+* Description : Lance une actualisation relative à l'étendue du projet. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void update_menu_bar_for_project(GMenuBar *bar, GStudyProject *project)
+{
+ update_menu_project_for_project(bar->project, project, bar);
+
+}
diff --git a/src/gui/menus/project.c b/src/gui/menus/project.c
new file mode 100644
index 0000000..52a2fbb
--- /dev/null
+++ b/src/gui/menus/project.c
@@ -0,0 +1,227 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * project.c - gestion du menu 'Projet'
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This project is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "project.h"
+
+
+#include <i18n.h>
+
+
+#include "../editem-int.h"
+#include "../../gtkext/easygtk.h"
+
+
+
+/* Affiche la boîte d'ajout d'un binaire au projet courant. */
+static void mcb_project_add_binary_file(GtkMenuItem *, GMenuBar *);
+
+/* Retire un binaire du projet indiqué. */
+static void mcb_project_remove_binary(GtkMenuItem *, GStudyProject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* accgroup = groupe d'accélérateurs pour les menus. *
+* bar = barre de menu parente. *
+* *
+* Description : Construit le menu "Projet". *
+* *
+* Retour : Panneau de menus mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *build_menu_project(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar)
+{
+ GtkWidget *result; /* Support à retourner */
+ GtkWidget *menubar; /* Support pour éléments */
+ GtkWidget *submenuitem; /* Sous-élément de menu #1 */
+ GtkWidget *deepmenubar; /* Support pour éléments #2 */
+ GtkWidget *deepmenuitem; /* Sous-élément de menu #2 */
+
+ result = gtk_menu_item_new_with_mnemonic(_("_Project"));
+ gtk_widget_show(result);
+
+ menubar = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(result), menubar);
+
+ submenuitem = qck_create_menu_item(NULL, NULL, _("Add a binary..."), NULL, NULL);
+ gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
+ deepmenubar = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), deepmenubar);
+
+ deepmenuitem = qck_create_menu_item(NULL, NULL, _("File"),
+ G_CALLBACK(mcb_project_add_binary_file), bar);
+ gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem);
+
+ submenuitem = qck_create_menu_item(G_OBJECT(result), "menu_prj_remove_bin", _("Remove a binary"),
+ NULL, NULL);
+ gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
+ deepmenubar = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(submenuitem), deepmenubar);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : widget = menu principal à actualiser. *
+* project = projet visé par la procédure. *
+* bar = barre de menu parente. *
+* *
+* Description : Lance une actualisation relative à l'étendue du projet. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void update_menu_project_for_project(GtkWidget *widget, GStudyProject *project, GMenuBar *bar)
+{
+ GtkWidget *menuitem; /* Menu principal à compléter */
+ GtkWidget *menubar; /* Support pour éléments */
+ GList *list; /* Liste des éléments en place */
+ GList *iter; /* Boucle de parcours #1 */
+ size_t count; /* Nombre de binaires attachés */
+ GOpenidaBinary **binaries; /* Liste de ces binaires */
+ size_t i; /* Boucle de parcours #2 */
+ const char *desc; /* Description à afficher */
+ GtkWidget *submenuitem; /* Sous-menu à ajouter */
+
+ menuitem = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), "menu_prj_remove_bin"));
+ menubar = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuitem));
+
+ /* Remise à zéro */
+
+ list = gtk_container_get_children(GTK_CONTAINER(menubar));
+
+ for (iter = list; iter != NULL; iter = g_list_next(iter))
+ gtk_container_remove(GTK_CONTAINER(menubar), GTK_WIDGET(iter->data));
+
+ g_list_free(list);
+
+ /* Ajout des entrées */
+
+ binaries = g_study_project_get_binaries(project, &count);
+
+ for (i = 0; i < count; i++)
+ {
+ desc = g_openida_binary_to_string(binaries[i]);
+
+ submenuitem = qck_create_menu_item(NULL, NULL, desc,
+ G_CALLBACK(mcb_project_remove_binary), project);
+ g_object_set_data(G_OBJECT(submenuitem), "binary", binaries[i]);
+ gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
+ g_object_unref(G_OBJECT(binaries[i]));
+
+ }
+
+ if (binaries != NULL)
+ free(binaries);
+
+ gtk_widget_set_sensitive(menuitem, count > 0);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : menuitem = élément de menu sélectionné. *
+* bar = barre de menu parente. *
+* *
+* Description : Affiche la boîte d'ajout d'un binaire au projet courant. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void mcb_project_add_binary_file(GtkMenuItem *menuitem, GMenuBar *bar)
+{
+ GtkWidget *dialog; /* Boîte à afficher */
+ gchar *filename; /* Nom du fichier à intégrer */
+ GOpenidaBinary *binary; /* Représentation chargée */
+
+ dialog = gtk_file_chooser_dialog_new(_("Open a binary file"),
+ GTK_WINDOW(G_EDITOR_ITEM(bar)->ref),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+ {
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+
+ binary = g_openida_binary_new_from_file(filename);
+
+ if (binary != NULL)
+ {
+ g_signal_connect(binary, "disassembly-done",
+ G_CALLBACK(g_study_project_add_loaded_binary), get_current_project());
+ g_openida_binary_analyse(binary);
+ }
+
+ g_free(filename);
+
+ }
+
+ gtk_widget_destroy(dialog);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : menuitem = élément de menu sélectionné. *
+* project = projet d'appartenance du binaire à traiter. *
+* *
+* Description : Retire un binaire du projet indiqué. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void mcb_project_remove_binary(GtkMenuItem *menuitem, GStudyProject *project)
+{
+ GOpenidaBinary *binary; /* Binaire à retirer */
+
+ binary = G_OPENIDA_BINARY(g_object_get_data(G_OBJECT(menuitem), "binary"));
+
+ g_study_project_detach_binary(project, binary);
+ g_object_unref(G_OBJECT(binary));
+
+}
diff --git a/src/gui/menus/project.h b/src/gui/menus/project.h
new file mode 100644
index 0000000..06a1e85
--- /dev/null
+++ b/src/gui/menus/project.h
@@ -0,0 +1,45 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * project.h - prototypes pour la gestion du menu 'Projet'
+ *
+ * Copyright (C) 2012 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * OpenIDA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef _GUI_MENUS_PROJECT_H
+#define _GUI_MENUS_PROJECT_H
+
+
+#include <gtk/gtk.h>
+
+
+#include "menubar.h"
+#include "../../project.h"
+
+
+
+/* Construit le menu "Projet". */
+GtkWidget *build_menu_project(GObject *, GtkAccelGroup *, GMenuBar *);
+
+/* Lance une actualisation relative à l'étendue du projet. */
+void update_menu_project_for_project(GtkWidget *, GStudyProject *, GMenuBar *);
+
+
+
+#endif /* _GUI_MENUS_PROJECT_H */
diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c
index 19f7e9b..e0e7cc4 100644
--- a/src/gui/menus/view.c
+++ b/src/gui/menus/view.c
@@ -52,7 +52,7 @@ static void mcb_view_code(GtkCheckMenuItem *, GMenuBar *);
* accgroup = groupe d'accélérateurs pour les menus. *
* bar = barre de menu parente. *
* *
-* Description : Construit le menu "Fichier". *
+* Description : Construit le menu "Affichage". *
* *
* Retour : Panneau de menus mis en place. *
* *
diff --git a/src/gui/menus/view.h b/src/gui/menus/view.h
index 2bdc9b6..e06f519 100644
--- a/src/gui/menus/view.h
+++ b/src/gui/menus/view.h
@@ -33,7 +33,7 @@
-/* Construit le menu "Fichier". */
+/* Construit le menu "Affichage". */
GtkWidget *build_menu_view(GObject *, GtkAccelGroup *, GMenuBar *);
/* Lance une actualisation du fait d'un changement de vue. */