From 9776f811af66eca56116fe81f77d859fb9b6e8fe Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 3 Jan 2011 01:22:36 +0000 Subject: Moved all menus related stuff into 'src/gui/menus'. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@205 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 28 +++++++++ configure.ac | 1 + src/Makefile.am | 2 +- src/dialogs/Makefile.am | 6 +- src/editor.c | 44 +++----------- src/gui/Makefile.am | 6 +- src/gui/editem.c | 19 +++++++ src/gui/editem.h | 3 + src/gui/menus/Makefile.am | 20 +++++++ src/gui/menus/help.c | 93 ++++++++++++++++++++++++++++++ src/gui/menus/help.h | 38 +++++++++++++ src/gui/menus/menubar.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++ src/gui/menus/menubar.h | 56 ++++++++++++++++++ 13 files changed, 417 insertions(+), 41 deletions(-) create mode 100644 src/gui/menus/Makefile.am create mode 100644 src/gui/menus/help.c create mode 100644 src/gui/menus/help.h create mode 100644 src/gui/menus/menubar.c create mode 100644 src/gui/menus/menubar.h diff --git a/ChangeLog b/ChangeLog index 149a683..799389c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,31 @@ +11-01-03 Cyrille Bagard + + * configure.ac: + Add the new Makefile from the 'src/gui/menus' directory to AC_CONFIG_FILES. + + * src/dialogs/Makefile.am: + Build a real library. + + * src/editor.c: + Update code. + + * src/gui/editem.c: + * src/gui/editem.h: + Retrieve the built GTK widget. + + * src/gui/Makefile.am: + Update libgui_la_LIBADD. + + * src/gui/menus/help.c: + * src/gui/menus/help.h: + * src/gui/menus/Makefile.am: + * src/gui/menus/menubar.c: + * src/gui/menus/menubar.h: + New entries: move all menus related stuff here. + + * src/Makefile.am: + Update openida_LDADD. + 10-12-31 Cyrille Bagard * configure.ac: diff --git a/configure.ac b/configure.ac index da0e825..a60359b 100644 --- a/configure.ac +++ b/configure.ac @@ -274,6 +274,7 @@ AC_CONFIG_FILES([Makefile src/graph/Makefile src/gtkext/Makefile src/gui/Makefile + src/gui/menus/Makefile src/gui/tb/Makefile src/panels/Makefile src/plugins/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 1997396..1d796cf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -99,7 +99,7 @@ openida_LDFLAGS = $(LIBGTK_LIBS) -L/usr/X11R6/lib -ldl -lm $(LIBXML_LIBS) `pkg-c openida_LDADD = $(LIBINTL) \ - dialogs/libdialogs.a \ + dialogs/libdialogs.la \ gui/libgui.la diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am index 289e5a5..359ac95 100644 --- a/src/dialogs/Makefile.am +++ b/src/dialogs/Makefile.am @@ -1,13 +1,13 @@ -lib_LIBRARIES = libdialogs.a +noinst_LTLIBRARIES = libdialogs.la -libdialogs_a_SOURCES = \ +libdialogs_la_SOURCES = \ about.h about.c \ binparts.h binparts.c \ export.h export.c \ plugins.h plugins.c -libdialogs_a_LDFLAGS = +libdialogs_la_LDFLAGS = INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) diff --git a/src/editor.c b/src/editor.c index 7e5bb80..78d890e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -52,11 +52,10 @@ #include "gtkext/gtkviewpanel.h" #include "debug/debugger.h" -#include "dialogs/about.h" #include "dialogs/binparts.h" #include "dialogs/export.h" #include "dialogs/plugins.h" -#include "gui/editem.h" +#include "gui/menus/menubar.h" #include "gui/tb/source.h" #include "panels/panel.h" @@ -146,9 +145,6 @@ void update_debug_menu_items(GObject *, gboolean); -/* Réagit avec le menu "Aide -> A propos de...". */ -static void mcb_help_about(GtkMenuItem *, GObject *); - @@ -201,6 +197,7 @@ GtkWidget *create_editor(void) { GtkWidget *result; /* Fenêtre à renvoyer */ GObject *ref; /* Version de référence */ + GEditorItem *editem; /* Menus réactifs principaux */ GtkWidget *menuboard; /* Barre de menus principale */ GtkWidget *menuitem; /* Elément de menu */ GtkWidget *menubar; /* Support pour éléments */ @@ -272,6 +269,13 @@ GtkWidget *create_editor(void) /* Intégration des menus */ + editem = g_menu_bar_new(ref); + menuboard = g_editor_item_get_widget(editem); + gtk_box_pack_start(GTK_BOX(vbox1), menuboard, FALSE, FALSE, 0); + + + + menuboard = gtk_menu_bar_new(); gtk_widget_show(menuboard); gtk_box_pack_start(GTK_BOX(vbox1), menuboard, FALSE, FALSE, 0); @@ -451,15 +455,7 @@ GtkWidget *create_editor(void) - menuitem = gtk_menu_item_new_with_mnemonic(_("_Help")); - gtk_widget_show(menuitem); - gtk_container_add(GTK_CONTAINER(menuboard), menuitem); - - menubar = gtk_menu_new(); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menubar); - submenuitem = qck_create_menu_item(NULL, NULL, _("About"), G_CALLBACK(mcb_help_about), result); - gtk_container_add(GTK_CONTAINER(menubar), submenuitem); /* Barre d'outils */ @@ -1428,28 +1424,6 @@ void update_debug_menu_items(GObject *ref, gboolean stopped) -/****************************************************************************** -* * -* 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 "Aide -> A propos de...". * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void mcb_help_about(GtkMenuItem *menuitem, GObject *ref) -{ - GtkWidget *dialog; /* Boîte de dialogue à montrer */ - - dialog = create_about_dialog(GTK_WINDOW(ref)); - gtk_widget_show(dialog); - -} - diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 801ee73..06f1a4e 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -6,7 +6,9 @@ libgui_la_SOURCES = \ editem.h editem.c libgui_la_LIBADD = \ - tb/libguitb.la + menus/libguimenus.la \ + tb/libguitb.la \ + ../dialogs/libdialogs.la libgui_la_LDFLAGS = @@ -17,4 +19,4 @@ AM_CPPFLAGS = AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = tb +SUBDIRS = menus tb diff --git a/src/gui/editem.c b/src/gui/editem.c index 694591b..bb3ec35 100644 --- a/src/gui/editem.c +++ b/src/gui/editem.c @@ -94,6 +94,25 @@ static void g_editor_item_init(GEditorItem *item) } +/****************************************************************************** +* * +* Paramètres : item = instance à consulter. * +* * +* Description : Fournit le composant GTK associé à l'élément réactif. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *g_editor_item_get_widget(const GEditorItem *item) +{ + return item->widget; + +} + + /* ---------------------------------------------------------------------------------- */ /* MANIPULATION D'ENSEMBLES */ diff --git a/src/gui/editem.h b/src/gui/editem.h index e991630..04513d7 100644 --- a/src/gui/editem.h +++ b/src/gui/editem.h @@ -55,6 +55,9 @@ typedef struct _GEditorItemClass GEditorItemClass; /* Indique le type défini pour un élément réactif d'éditeur. */ 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 *); + /* ---------------------------- MANIPULATION D'ENSEMBLES ---------------------------- */ diff --git a/src/gui/menus/Makefile.am b/src/gui/menus/Makefile.am new file mode 100644 index 0000000..b9e127d --- /dev/null +++ b/src/gui/menus/Makefile.am @@ -0,0 +1,20 @@ + +noinst_LTLIBRARIES = libguimenus.la + +libguimenus_la_SOURCES = \ + help.h help.c \ + menubar.h menubar.c + +libguimenus_la_LDFLAGS = + +libguimenus_LIBADD = $(LIBINTL) \ + ../../dialogs/libdialogs.la + + +INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) + +AM_CPPFLAGS = + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = diff --git a/src/gui/menus/help.c b/src/gui/menus/help.c new file mode 100644 index 0000000..b1fb545 --- /dev/null +++ b/src/gui/menus/help.c @@ -0,0 +1,93 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * help.c - gestion du menu 'Aide' + * + * 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 "help.h" + + +#include + + +#include "../../dialogs/about.h" +#include "../../gtkext/easygtk.h" + + + +/* Réagit avec le menu "Aide -> A propos de...". */ +static void mcb_help_about(GtkMenuItem *, GObject *); + + + +/****************************************************************************** +* * +* Paramètres : ref = espace de référencement global. * +* * +* Description : Construit le menu "Aide". * +* * +* Retour : Panneau de menus mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *build_menu_help(GObject *ref) +{ + GtkWidget *result; /* Support à retourner */ + GtkWidget *menubar; /* Support pour éléments */ + GtkWidget *submenuitem; /* Sous-élément de menu */ + + result = gtk_menu_item_new_with_mnemonic(_("_Help")); + 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, _("About"), G_CALLBACK(mcb_help_about), ref); + 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 "Aide -> A propos de...". * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void mcb_help_about(GtkMenuItem *menuitem, GObject *ref) +{ + GtkWidget *dialog; /* Boîte de dialogue à montrer */ + + dialog = create_about_dialog(GTK_WINDOW(ref)); + gtk_widget_show(dialog); + +} diff --git a/src/gui/menus/help.h b/src/gui/menus/help.h new file mode 100644 index 0000000..0c2d345 --- /dev/null +++ b/src/gui/menus/help.h @@ -0,0 +1,38 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * help.h - prototypes pour la gestion du menu 'Aide' + * + * 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_HELP_H +#define _GUI_MENUS_HELP_H + + +#include + + + +/* Construit le menu "Aide". */ +GtkWidget *build_menu_help(GObject *); + + + +#endif /* _GUI_MENUS_HELP_H */ diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c new file mode 100644 index 0000000..af27888 --- /dev/null +++ b/src/gui/menus/menubar.c @@ -0,0 +1,142 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * menubar.c - gestion des différents menus de la fenêtre principale + * + * 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 "menubar.h" + + +#include "help.h" +#include "../editem-int.h" + + + +/* Barre de menus de la fenêtre principale (instance) */ +struct _GMenuBar +{ + GEditorItem parent; /* A laisser en premier */ + +}; + + +/* Barre de menus de la fenêtre principale (classe) */ +struct _GMenuBarClass +{ + GEditorItemClass parent; /* A laisser en premier */ + +}; + + +/* Initialise la classe de la barre de menus de l'éditeur. */ +static void g_menu_bar_class_init(GMenuBarClass *); + +/* Initialise une instance de la barre de menus pour l'éditeur. */ +static void g_menu_bar_init(GMenuBar *); + + + +/* Indique le type défini pour la barre de menus de la fenêtre principale. */ +G_DEFINE_TYPE(GMenuBar, g_menu_bar, G_TYPE_EDITOR_ITEM); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe de la barre de menus de l'éditeur. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_menu_bar_class_init(GMenuBarClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : bar = instance à initialiser. * +* * +* Description : Initialise une instance de la barre de menus pour l'éditeur. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_menu_bar_init(GMenuBar *bar) +{ + GEditorItem *item; /* Autre version de l'élément */ + + item = G_EDITOR_ITEM(bar); + + item->name = "menus"; + + item->widget = gtk_menu_bar_new(); + gtk_widget_show(item->widget); + +} + + +/****************************************************************************** +* * +* 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. * +* * +* Description : Compose la barre de menus principale. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GEditorItem *g_menu_bar_new(GObject *ref) +{ + GMenuBar *result; /* Structure à retourner */ + GEditorItem *item; /* Autre version de l'élément */ + GtkWidget *menuitem; /* Elément de menu */ + + result = g_object_new(G_TYPE_MENU_BAR, NULL); + + /* Initialisation générique */ + + item = G_EDITOR_ITEM(result); + + g_object_ref(ref); + item->ref = ref; + + /* Aide */ + + menuitem = build_menu_help(ref); + 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 new file mode 100644 index 0000000..e7dcf6d --- /dev/null +++ b/src/gui/menus/menubar.h @@ -0,0 +1,56 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * menubar.h - prototypes pour la gestion des différents menus de la fenêtre principale + * + * 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_MENUBAR_H +#define _GUI_MENUS_MENUBAR_H + + +#include "../editem.h" + + + +#define G_TYPE_MENU_BAR g_menu_bar_get_type() +#define G_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_menu_bar_get_type(), GMenuBar)) +#define G_IS_MENU_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_menu_bar_get_type())) +#define G_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_MENU_BAR, GMenuBarClass)) +#define G_IS_MENU_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_MENU_BAR)) +#define G_MENU_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_MENU_BAR, GMenuBarClass)) + + +/* Barre de menus de la fenêtre principale (instance) */ +typedef struct _GMenuBar GMenuBar; + +/* Barre de menus de la fenêtre principale (classe) */ +typedef struct _GMenuBarClass GMenuBarClass; + + +/* Indique le type défini pour la barre de menus de la fenêtre principale. */ +GType g_menu_bar_get_type(void); + +/* Compose la barre de menus principale. */ +GEditorItem *g_menu_bar_new(GObject *); + + + +#endif /* _GUI_MENUS_MENUBAR_H */ -- cgit v0.11.2-87-g4458