summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-03-09 18:04:49 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-03-09 18:04:49 (GMT)
commitdc8a2b19dbb32bfe49b1ff6640cc609238b392ca (patch)
tree2103c99baeb3b792bc82fc3db28bd16ecf72b70e /src/gui
parentf8f804cf7ff9a62404b843cf303c762101572784 (diff)
Stored and loaded panels attributes using the global configuration.
Diffstat (limited to 'src/gui')
-rwxr-xr-xsrc/gui/core/Makefile.am1
-rw-r--r--src/gui/core/core.c97
-rw-r--r--src/gui/core/core.h47
-rw-r--r--src/gui/core/panels.c27
-rw-r--r--src/gui/core/panels.h3
-rw-r--r--src/gui/editor.c5
-rw-r--r--src/gui/panels/bookmarks.c3
-rw-r--r--src/gui/panels/glance.c4
-rw-r--r--src/gui/panels/history.c4
-rw-r--r--src/gui/panels/log.c3
-rw-r--r--src/gui/panels/panel-int.h3
-rw-r--r--src/gui/panels/panel.c147
-rw-r--r--src/gui/panels/panel.h9
-rw-r--r--src/gui/panels/regedit.c3
-rw-r--r--src/gui/panels/strings.c4
-rw-r--r--src/gui/panels/symbols.c3
16 files changed, 334 insertions, 29 deletions
diff --git a/src/gui/core/Makefile.am b/src/gui/core/Makefile.am
index 948bd24..2000f58 100755
--- a/src/gui/core/Makefile.am
+++ b/src/gui/core/Makefile.am
@@ -2,6 +2,7 @@
noinst_LTLIBRARIES = libguicore.la
libguicore_la_SOURCES = \
+ core.h core.c \
panels.h panels.c
libguicore_la_LDFLAGS = $(LIBGTK_LIBS) $(LIBXML_LIBS)
diff --git a/src/gui/core/core.c b/src/gui/core/core.c
new file mode 100644
index 0000000..16e5cc8
--- /dev/null
+++ b/src/gui/core/core.c
@@ -0,0 +1,97 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * core.c - chargement et le déchargement du tronc commun pour l'éditeur graphique
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "core.h"
+
+
+#include "panels.h"
+
+
+#include "../../core/params.h"
+
+
+
+/******************************************************************************
+* *
+* Paramètres : ref = espace de référencement global. *
+* *
+* Description : Charge les éléments graphiques de l'éditeur. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool load_all_gui_components(GObject *ref)
+{
+ bool result; /* Bilan à retourner */
+
+ result = true;
+
+ load_main_panels(ref);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : config = configuration globale à utiliser. *
+* *
+* Description : Finalise le chargement des éléments graphiques de l'éditeur. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool complete_loading_of_all_gui_components(GGenConfig *config)
+{
+ bool result; /* Bilan à faire remonter */
+
+ result = browse_all_item_panels((handle_panel_item_fc)gtk_panel_item_apply_configuration, config);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Décharge les éléments graphiques de l'éditeur. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void unload_all_gui_components(void)
+{
+
+}
diff --git a/src/gui/core/core.h b/src/gui/core/core.h
new file mode 100644
index 0000000..f5ab761
--- /dev/null
+++ b/src/gui/core/core.h
@@ -0,0 +1,47 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * core.h - prototypes pour le chargement et le déchargement du tronc commun pour l'éditeur graphique
+ *
+ * Copyright (C) 2016 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#ifndef _GUI_CORE_CORE_H
+#define _GUI_CORE_CORE_H
+
+
+#include <glib-object.h>
+#include <stdbool.h>
+
+
+#include "../../glibext/configuration.h"
+
+
+
+/* Charge les éléments graphiques de l'éditeur. */
+bool load_all_gui_components(GObject *);
+
+/* Finalise le chargement des éléments graphiques de l'éditeur. */
+bool complete_loading_of_all_gui_components(GGenConfig *);
+
+/* Décharge les éléments graphiques de l'éditeur. */
+void unload_all_gui_components(void);
+
+
+
+#endif /* _GUI_CORE_CORE_H */
diff --git a/src/gui/core/panels.c b/src/gui/core/panels.c
index 6b77e92..d8565f4 100644
--- a/src/gui/core/panels.c
+++ b/src/gui/core/panels.c
@@ -33,6 +33,7 @@
#include "../panels/regedit.h"
#include "../panels/strings.h"
#include "../panels/symbols.h"
+#include "../../core/params.h"
#include "../../gtkext/gtkdockable.h"
@@ -56,36 +57,40 @@ static GPanelItem *_panels_list = NULL;
void load_main_panels(GObject *ref)
{
+ GGenConfig *config; /* Configuration globale */
GPanelItem *item; /* Panneau de base à charger */
+ config = get_main_configuration();
+
item = g_log_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
item = g_regedit_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
item = g_symbols_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
item = g_history_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
item = g_strings_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
item = g_glance_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
item = g_bookmarks_panel_new();
- register_panel_item(item, ref);
+ register_panel_item(item, ref, config);
}
/******************************************************************************
* *
-* Paramètres : item = composant à présenter à l'affichage. *
-* ref = espace de référencement global. *
+* Paramètres : item = composant à présenter à l'affichage. *
+* ref = espace de référencement global. *
+* config = configuration à compléter. *
* *
* Description : Enregistre un panneau comme partie intégrante de l'éditeur. *
* *
@@ -95,7 +100,7 @@ void load_main_panels(GObject *ref)
* *
******************************************************************************/
-void register_panel_item(GPanelItem *item, GObject *ref)
+void register_panel_item(GPanelItem *item, GObject *ref, GGenConfig *config)
{
GEditorItem *parent; /* Autre version de l'élément */
@@ -116,7 +121,7 @@ void register_panel_item(GPanelItem *item, GObject *ref)
gtk_dockable_setup_dnd(GTK_DOCKABLE(item));
- g_panel_item_dock(item);
+ gtk_panel_item_setup_configuration(item, config);
}
diff --git a/src/gui/core/panels.h b/src/gui/core/panels.h
index 1a8f9d8..07ce133 100644
--- a/src/gui/core/panels.h
+++ b/src/gui/core/panels.h
@@ -30,6 +30,7 @@
#include "../panels/panel.h"
+#include "../../glibext/configuration.h"
@@ -37,7 +38,7 @@
void load_main_panels(GObject *);
/* Enregistre un panneau comme partie intégrante de l'éditeur. */
-void register_panel_item(GPanelItem *, GObject *);
+void register_panel_item(GPanelItem *, GObject *, GGenConfig *);
/* Réalise un traitement sur un panneau de l'éditeur. */
typedef bool (* handle_panel_item_fc) (GPanelItem *, void *);
diff --git a/src/gui/editor.c b/src/gui/editor.c
index bcbdfe1..fdf253f 100644
--- a/src/gui/editor.c
+++ b/src/gui/editor.c
@@ -34,6 +34,7 @@
#include "status.h"
#include "menus/menubar.h"
+#include "core/core.h"
#include "panels/panel.h"
#include "tb/portions.h"
#include "tb/source.h"
@@ -305,7 +306,7 @@ GtkWidget *create_editor(void)
//_support = init_panels2(G_CALLBACK(on_dock_item_switch), ref);
gtk_box_pack_start(GTK_BOX(vbox1), _support, TRUE, TRUE, 0);
- load_main_panels(ref);
+ /* ... = */load_all_gui_components(ref);
} while(0);
@@ -324,7 +325,7 @@ GtkWidget *create_editor(void)
/* Autre */
- prepare_drag_and_drop_window();
+ /* ... = */prepare_drag_and_drop_window();
diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c
index 87789b6..222176a 100644
--- a/src/gui/panels/bookmarks.c
+++ b/src/gui/panels/bookmarks.c
@@ -255,7 +255,8 @@ static void g_bookmarks_panel_init(GBookmarksPanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Bookmarks");
- pitem->path = "SE";
+ pitem->dock_at_startup = false;
+ pitem->path = strdup("SE");
/* Représentation graphique */
diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c
index 1dab8b4..c473116 100644
--- a/src/gui/panels/glance.c
+++ b/src/gui/panels/glance.c
@@ -25,6 +25,7 @@
#include "glance.h"
+#include <string.h>
#include <gtk/gtk.h>
@@ -186,7 +187,8 @@ static void g_glance_panel_init(GGlancePanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Glance");
- pitem->path = "es";
+ pitem->dock_at_startup = true;
+ pitem->path = strdup("es");
/* Support de dessin */
diff --git a/src/gui/panels/history.c b/src/gui/panels/history.c
index 526a775..15574be 100644
--- a/src/gui/panels/history.c
+++ b/src/gui/panels/history.c
@@ -25,6 +25,7 @@
#include "history.h"
+#include <string.h>
#include <cairo-gobject.h>
@@ -176,7 +177,8 @@ static void g_history_panel_init(GHistoryPanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Change history");
- pitem->path = "eN";
+ pitem->dock_at_startup = true;
+ pitem->path = strdup("eN");
/* Représentation graphique */
diff --git a/src/gui/panels/log.c b/src/gui/panels/log.c
index 1b8c6bc..da35c8f 100644
--- a/src/gui/panels/log.c
+++ b/src/gui/panels/log.c
@@ -168,7 +168,8 @@ static void g_log_panel_init(GLogPanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Misc information");
- pitem->path = "S";
+ pitem->dock_at_startup = true;
+ pitem->path = strdup("S");
/* Représentation graphique */
diff --git a/src/gui/panels/panel-int.h b/src/gui/panels/panel-int.h
index 5e906f0..7e44275 100644
--- a/src/gui/panels/panel-int.h
+++ b/src/gui/panels/panel-int.h
@@ -48,7 +48,8 @@ struct _GPanelItem
const char *lname; /* Description longue */
- const char *path; /* Chemin vers la place idéale */
+ bool dock_at_startup; /* Recommandation au démarrage */
+ char *path; /* Chemin vers la place idéale */
bool docked; /* Panneau inscrusté ? */
diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c
index 00a4eea..71fa155 100644
--- a/src/gui/panels/panel.c
+++ b/src/gui/panels/panel.c
@@ -26,9 +26,11 @@
#include <assert.h>
+#include <stdio.h>
#include "panel-int.h"
+#include "../../common/extstr.h"
#include "../../gtkext/gtkdockable-int.h"
@@ -51,6 +53,9 @@ static const char *gtk_panel_item_get_desc(const GPanelItem *);
/* Fournit le composant graphique intégrable dans un ensemble. */
static GtkWidget *gtk_panel_item_get_widget(GPanelItem *);
+/* Construit la chaîne d'accès à un élément de configuration. */
+static char *gtk_panel_item_build_configuration_key(const GPanelItem *, const char *);
+
/* Indique le type défini pour un élément destiné à un panneau. */
@@ -140,10 +145,11 @@ static void g_panel_item_dockable_interface_init(GtkDockableInterface *iface)
/******************************************************************************
* *
* Paramètres : personality = nature du panneau à mettre en place. *
-* name = nom associé à l'élément. *
-* lname = description longue du panneau. *
-* widget = composant à présenter à l'affichage. *
-* path = chemin vers la place idéale pour le futur panneau. *
+* name = nom associé à l'élément. *
+* lname = description longue du panneau. *
+* widget = composant à présenter à l'affichage. *
+* startup = chargement au démarrage ? *
+* path = chemin vers la place idéale pour le futur panneau. *
* *
* Description : Crée un élément de panneau réactif. *
* *
@@ -153,7 +159,7 @@ static void g_panel_item_dockable_interface_init(GtkDockableInterface *iface)
* *
******************************************************************************/
-GPanelItem *g_panel_item_new(PanelItemPersonality personality, const char *name, const char *lname, GtkWidget *widget, const char *path)
+GPanelItem *g_panel_item_new(PanelItemPersonality personality, const char *name, const char *lname, GtkWidget *widget, bool startup, const char *path)
{
GPanelItem *result; /* Structure à retourner */
GEditorItem *parent; /* Autre version de l'élément */
@@ -170,7 +176,8 @@ GPanelItem *g_panel_item_new(PanelItemPersonality personality, const char *name,
result->lname = lname;
- result->path = path;
+ result->dock_at_startup = startup;
+ result->path = strdup(path);
return result;
@@ -236,6 +243,134 @@ static GtkWidget *gtk_panel_item_get_widget(GPanelItem *item)
/******************************************************************************
* *
+* Paramètres : item = instance GTK à consulter. *
+* attrib = élément de configuration à inclure dans le résultat.*
+* *
+* Description : Construit la chaîne d'accès à un élément de configuration. *
+* *
+* Retour : Chaîne de caractères à libérer après usage. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static char *gtk_panel_item_build_configuration_key(const GPanelItem *item, const char *attrib)
+{
+ char *result; /* Construction à renvoyer */
+ const char *name; /* Nom court du panneau */
+
+ name = g_editor_item_get_name(G_EDITOR_ITEM(item));
+
+ asprintf(&result, "gui.panels.%s.%s", name, attrib);
+
+ result = strrpl(result, " ", "_");
+
+ result = strlower(result);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : item = instance GTK à consulter. *
+* config = configuration à compléter. *
+* *
+* Description : Met en place les bases de la configuration du panneau. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool gtk_panel_item_setup_configuration(const GPanelItem *item, GGenConfig *config)
+{
+ bool result; /* Bilan à retourner */
+ char *key; /* Clef d'accès à un paramètre */
+ GCfgParam *param; /* Paramètre chargé */
+
+ result = true;
+
+ key = gtk_panel_item_build_configuration_key(item, "dock_at_startup");
+
+ param = g_generic_config_create_param(config, key, CPT_BOOLEAN, item->dock_at_startup);
+
+ if (param == NULL)
+ {
+ result = false;
+ goto gpisc_exit;
+ }
+
+ free(key);
+
+ key = gtk_panel_item_build_configuration_key(item, "path");
+
+ param = g_generic_config_create_param(config, key, CPT_STRING, item->path);
+ if (param == NULL)
+ result = false;
+
+ gpisc_exit:
+
+ free(key);
+
+ return result;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : item = instance GTK à consulter. *
+* config = configuration à charger. *
+* *
+* Description : Charge un panneau sur les bases de la configuration fournie. *
+* *
+* Retour : true, par conformité avec browse_all_item_panels(). *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool gtk_panel_item_apply_configuration(GPanelItem *item, GGenConfig *config)
+{
+ char *key; /* Clef d'accès à un paramètre */
+ const char *new_path; /* Nouveau chemin de placement */
+ bool status; /* Statut de l'encapsulation */
+
+ key = gtk_panel_item_build_configuration_key(item, "path");
+
+ if (g_generic_config_get_value(config, key, &new_path))
+ {
+ free(item->path);
+
+ item->path = strdup(new_path);
+
+ }
+
+ free(key);
+
+ key = gtk_panel_item_build_configuration_key(item, "dock_at_startup");
+
+ if (g_generic_config_get_value(config, key, &status))
+ {
+ item->dock_at_startup = status;
+
+ if (item->dock_at_startup)
+ g_signal_emit_by_name(item, "dock-request");
+
+ }
+
+ free(key);
+
+ return true;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : item = instance GTK à consulter. *
* *
* Description : Fournit une indication sur la personnalité du panneau. *
diff --git a/src/gui/panels/panel.h b/src/gui/panels/panel.h
index bb46c5a..cbe9030 100644
--- a/src/gui/panels/panel.h
+++ b/src/gui/panels/panel.h
@@ -30,6 +30,7 @@
#include "../editem.h"
+#include "../../glibext/configuration.h"
@@ -66,7 +67,13 @@ typedef enum _PanelItemPersonality
GType g_panel_item_get_type(void);
/* Crée un élément de panneau réactif. */
-GPanelItem *g_panel_item_new(PanelItemPersonality, const char *, const char *, GtkWidget *, const char *);
+GPanelItem *g_panel_item_new(PanelItemPersonality, const char *, const char *, GtkWidget *, bool, const char *);
+
+/* Met en place les bases de la configuration du panneau. */
+bool gtk_panel_item_setup_configuration(const GPanelItem *, GGenConfig *);
+
+/* Charge un panneau sur les bases de la configuration fournie. */
+bool gtk_panel_item_apply_configuration(GPanelItem *, GGenConfig *);
/* Fournit une indication sur la personnalité du panneau. */
PanelItemPersonality gtk_panel_item_get_personality(const GPanelItem *);
diff --git a/src/gui/panels/regedit.c b/src/gui/panels/regedit.c
index a62f824..5e224ec 100644
--- a/src/gui/panels/regedit.c
+++ b/src/gui/panels/regedit.c
@@ -225,7 +225,8 @@ static void g_regedit_panel_init(GRegeditPanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Configuration parameters");
- pitem->path = "N";
+ pitem->dock_at_startup = true;
+ pitem->path = strdup("N");
/* Représentation graphique */
diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c
index 0c39b4b..ae436cf 100644
--- a/src/gui/panels/strings.c
+++ b/src/gui/panels/strings.c
@@ -25,6 +25,7 @@
#include "strings.h"
+#include <string.h>
#include <inttypes.h>
@@ -233,7 +234,8 @@ static void g_strings_panel_init(GStringsPanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Strings");
- pitem->path = "SE";
+ pitem->dock_at_startup = false;
+ pitem->path = strdup("N");
/* Représentation graphique */
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index 1b7453b..422c9b4 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -259,7 +259,8 @@ static void g_symbols_panel_init(GSymbolsPanel *panel)
pitem->personality = PIP_SINGLETON;
pitem->lname = _("Binary symbols");
- pitem->path = "eN";
+ pitem->dock_at_startup = true;
+ pitem->path = strdup("eN");
/* Représentation graphique */