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/debug.c128
-rw-r--r--src/gui/menus/debug.h38
-rw-r--r--src/gui/menus/help.c5
-rw-r--r--src/gui/menus/help.h2
-rw-r--r--src/gui/menus/menubar.c16
-rw-r--r--src/gui/menus/menubar.h2
7 files changed, 182 insertions, 10 deletions
diff --git a/src/gui/menus/Makefile.am b/src/gui/menus/Makefile.am
index b9e127d..36fffc2 100644
--- a/src/gui/menus/Makefile.am
+++ b/src/gui/menus/Makefile.am
@@ -2,6 +2,7 @@
noinst_LTLIBRARIES = libguimenus.la
libguimenus_la_SOURCES = \
+ debug.h debug.c \
help.h help.c \
menubar.h menubar.c
diff --git a/src/gui/menus/debug.c b/src/gui/menus/debug.c
new file mode 100644
index 0000000..366d789
--- /dev/null
+++ b/src/gui/menus/debug.c
@@ -0,0 +1,128 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * debug.c - gestion du menu 'Débogage'
+ *
+ * Copyright (C) 2011 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
+ */
+
+
+#include "debug.h"
+
+
+#include <string.h>
+
+
+#include <i18n.h>
+
+
+#include "../../project.h"
+#include "../../gtkext/easygtk.h"
+#include "../../panels/log.h"
+
+
+
+/* Réagit avec le menu "Débogage -> Démarrer/Arrêter". */
+static void mcb_debug_start_stop(GtkMenuItem *, GObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* accgroup = groupe d'accélérateurs pour les menus. *
+* *
+* Description : Construit le menu "Aide". *
+* *
+* Retour : Panneau de menus mis en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GtkWidget *build_menu_debug(GObject *ref, GtkAccelGroup *accgroup)
+{
+ GtkWidget *result; /* Support à retourner */
+ GtkWidget *menubar; /* Support pour éléments */
+ GtkWidget *submenuitem; /* Sous-élément de menu */
+
+ result = gtk_menu_item_new_with_mnemonic(_("_Debug"));
+ gtk_widget_show(result);
+
+ menubar = gtk_menu_new();
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(result), menubar);
+
+ submenuitem = qck_create_menu_item(ref, "mnu_start_stop", _("Start"), G_CALLBACK(mcb_debug_start_stop), ref);
+ add_accelerator_to_menu_item(submenuitem, "F9", accgroup);
+ gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
+ submenuitem = qck_create_menu_separator();
+ gtk_container_add(GTK_CONTAINER(menubar), submenuitem);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : menuitem = élément de menu sélectionné. *
+* ref = adresse de l'espace de référencement global. *
+* *
+* Description : Réagit avec le menu "Débogage -> Démarrer/Arrêter". *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void mcb_debug_start_stop(GtkMenuItem *menuitem, GObject *ref)
+{
+ GOpenidaBinary *binary; /* Edition courante */
+ GBinaryDebugger *debugger; /* Module prêt à emploi */
+
+ binary = (GOpenidaBinary *)g_object_get_data(ref, "current_binary");
+ debugger = get_main_debugger_for_binary(get_current_openida_project(), binary);
+
+ if (debugger == NULL)
+ {
+ log_simple_message(LMT_ERROR, _("No available debug module for this binary !"));
+ return;
+ }
+
+ if (strcmp(gtk_menu_item_get_label(menuitem), _("Start")) == 0)
+ {
+ if (!g_binary_debugger_attach(debugger))
+ {
+ log_simple_message(LMT_ERROR, _("Failed to initialize the debugger."));
+ return;
+ }
+
+ gtk_menu_item_set_label(menuitem, _("Stop"));
+
+ }
+ else
+ {
+ /* TODO */
+
+ gtk_menu_item_set_label(menuitem, _("Start"));
+
+ }
+
+}
diff --git a/src/gui/menus/debug.h b/src/gui/menus/debug.h
new file mode 100644
index 0000000..7b08f60
--- /dev/null
+++ b/src/gui/menus/debug.h
@@ -0,0 +1,38 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * debug.h - prototypes pour la gestion du menu 'Débogage'
+ *
+ * Copyright (C) 2011 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_DEBUG_H
+#define _GUI_MENUS_DEBUG_H
+
+
+#include <gtk/gtk.h>
+
+
+
+/* Construit le menu "Aide". */
+GtkWidget *build_menu_debug(GObject *, GtkAccelGroup *);
+
+
+
+#endif /* _GUI_MENUS_DEBUG_H */
diff --git a/src/gui/menus/help.c b/src/gui/menus/help.c
index b1fb545..eb17301 100644
--- a/src/gui/menus/help.c
+++ b/src/gui/menus/help.c
@@ -40,7 +40,8 @@ static void mcb_help_about(GtkMenuItem *, GObject *);
/******************************************************************************
* *
-* Paramètres : ref = espace de référencement global. *
+* Paramètres : ref = espace de référencement global. *
+* accgroup = groupe d'accélérateurs pour les menus. *
* *
* Description : Construit le menu "Aide". *
* *
@@ -50,7 +51,7 @@ static void mcb_help_about(GtkMenuItem *, GObject *);
* *
******************************************************************************/
-GtkWidget *build_menu_help(GObject *ref)
+GtkWidget *build_menu_help(GObject *ref, GtkAccelGroup *accgroup)
{
GtkWidget *result; /* Support à retourner */
GtkWidget *menubar; /* Support pour éléments */
diff --git a/src/gui/menus/help.h b/src/gui/menus/help.h
index 0c2d345..675a9e7 100644
--- a/src/gui/menus/help.h
+++ b/src/gui/menus/help.h
@@ -31,7 +31,7 @@
/* Construit le menu "Aide". */
-GtkWidget *build_menu_help(GObject *);
+GtkWidget *build_menu_help(GObject *, GtkAccelGroup *);
diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c
index af27888..4718caa 100644
--- a/src/gui/menus/menubar.c
+++ b/src/gui/menus/menubar.c
@@ -25,6 +25,7 @@
#include "menubar.h"
+#include "debug.h"
#include "help.h"
#include "../editem-int.h"
@@ -104,10 +105,8 @@ static void g_menu_bar_init(GMenuBar *bar)
/******************************************************************************
* *
-* Paramètres : ref = espace de référencement global. *
-* name = nom associé à l'élément. *
-* widget = composant à présenter à l'affichage. *
-* label = étiquette destinée au menu. *
+* Paramètres : ref = espace de référencement global. *
+* accgroup = groupe d'accélérateurs pour les menus. *
* *
* Description : Compose la barre de menus principale. *
* *
@@ -117,7 +116,7 @@ static void g_menu_bar_init(GMenuBar *bar)
* *
******************************************************************************/
-GEditorItem *g_menu_bar_new(GObject *ref)
+GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup)
{
GMenuBar *result; /* Structure à retourner */
GEditorItem *item; /* Autre version de l'élément */
@@ -132,9 +131,14 @@ GEditorItem *g_menu_bar_new(GObject *ref)
g_object_ref(ref);
item->ref = ref;
+ /* Débogage */
+
+ menuitem = build_menu_debug(ref, accgroup);
+ gtk_container_add(GTK_CONTAINER(item->widget), menuitem);
+
/* Aide */
- menuitem = build_menu_help(ref);
+ menuitem = build_menu_help(ref, accgroup);
gtk_container_add(GTK_CONTAINER(item->widget), menuitem);
return G_EDITOR_ITEM(result);
diff --git a/src/gui/menus/menubar.h b/src/gui/menus/menubar.h
index e7dcf6d..ffb4c87 100644
--- a/src/gui/menus/menubar.h
+++ b/src/gui/menus/menubar.h
@@ -49,7 +49,7 @@ typedef struct _GMenuBarClass GMenuBarClass;
GType g_menu_bar_get_type(void);
/* Compose la barre de menus principale. */
-GEditorItem *g_menu_bar_new(GObject *);
+GEditorItem *g_menu_bar_new(GObject *, GtkAccelGroup *);