From 0a190905f31d7c395e1b26efe3abe443687429e5 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 11 Mar 2019 20:47:05 +0100 Subject: Defined new config parameters for the edge colors. --- src/core/params.c | 12 ++ src/core/params.h | 4 + src/glibext/configuration.c | 74 +++++++++++ src/glibext/configuration.h | 2 + src/gtkext/graph/edge.c | 41 +++++- src/gui/dialogs/Makefile.am | 4 + src/gui/dialogs/gresource.xml | 2 + src/gui/dialogs/preferences.c | 270 ++++++++++++++++++++++++++++++++++++++-- src/gui/dialogs/preferences.ui | 145 ++------------------- src/gui/dialogs/prefs_fgraph.c | 196 +++++++++++++++++++++++++++++ src/gui/dialogs/prefs_fgraph.h | 46 +++++++ src/gui/dialogs/prefs_fgraph.ui | 150 ++++++++++++++++++++++ src/gui/dialogs/prefs_labels.c | 102 +++++++++++++++ src/gui/dialogs/prefs_labels.h | 46 +++++++ src/gui/dialogs/prefs_labels.ui | 150 ++++++++++++++++++++++ src/gui/panels/regedit.c | 11 ++ 16 files changed, 1105 insertions(+), 150 deletions(-) create mode 100644 src/gui/dialogs/prefs_fgraph.c create mode 100644 src/gui/dialogs/prefs_fgraph.h create mode 100644 src/gui/dialogs/prefs_fgraph.ui create mode 100644 src/gui/dialogs/prefs_labels.c create mode 100644 src/gui/dialogs/prefs_labels.h create mode 100644 src/gui/dialogs/prefs_labels.ui diff --git a/src/core/params.c b/src/core/params.c index 8d9a035..9cb540e 100644 --- a/src/core/params.c +++ b/src/core/params.c @@ -204,6 +204,18 @@ bool load_main_config_parameters(void) param = g_generic_config_create_param(config, MPK_TOOLTIP_MAX_STRINGS, CPT_INTEGER, 5); if (param == NULL) return false; + param = g_generic_config_create_param(config, MPK_LINK_DEFAULT, CPT_COLOR, ((GdkRGBA []) {{ 0, 0, 0, 1.0 }})); + if (param == NULL) return false; + + param = g_generic_config_create_param(config, MPK_LINK_BRANCH_TRUE, CPT_COLOR, ((GdkRGBA []) {{ 0, 0.6, 0, 1.0 }})); + if (param == NULL) return false; + + param = g_generic_config_create_param(config, MPK_LINK_BRANCH_FALSE, CPT_COLOR, ((GdkRGBA []) {{ 0.8, 0, 0, 1.0 }})); + if (param == NULL) return false; + + param = g_generic_config_create_param(config, MPK_LINK_LOOP, CPT_COLOR, ((GdkRGBA []) {{ 0, 0, 0.8, 1.0 }})); + if (param == NULL) return false; + param = g_generic_config_create_param(config, MPK_KEYBINDINGS_EDIT, CPT_STRING, "F2"); if (param == NULL) return false; diff --git a/src/core/params.h b/src/core/params.h index 21fffd7..85f4084 100644 --- a/src/core/params.h +++ b/src/core/params.h @@ -62,6 +62,10 @@ #define MPK_SELECTION_LINE "gui.editor.views.selection_line" #define MPK_TOOLTIP_MAX_CALLS "gui.editor.views.tooltip_max_calls" #define MPK_TOOLTIP_MAX_STRINGS "gui.editor.views.tooltip_max_strings" +#define MPK_LINK_DEFAULT "gui.editor.graph.link.default" +#define MPK_LINK_BRANCH_TRUE "gui.editor.graph.link.branch_true" +#define MPK_LINK_BRANCH_FALSE "gui.editor.graph.link.branch_false" +#define MPK_LINK_LOOP "gui.editor.graph.link.loop" #define MPK_KEYBINDINGS_EDIT "gui.key_bindings.global.edit" #define MPK_TMPDIR "misc.tmpdir" #define MPK_AUTO_SAVE "project.autosave" diff --git a/src/glibext/configuration.c b/src/glibext/configuration.c index 03575b0..09d2d37 100644 --- a/src/glibext/configuration.c +++ b/src/glibext/configuration.c @@ -52,6 +52,7 @@ typedef union _param_value int integer; /* Valeur entière */ unsigned long ulong; /* Valeur entière positive */ char *string; /* Chaîne de caractères */ + GdkRGBA color; /* Couleur avec transparence */ } param_value; @@ -343,6 +344,10 @@ GCfgParam *g_config_param_new(const char *path, ConfigParamType type, ...) result->def.string = strdup(result->def.string); break; + case CPT_COLOR: + result->def.color = *va_arg(ap, GdkRGBA *); + break; + default: g_object_unref(G_OBJECT(result)); result = NULL; @@ -412,6 +417,8 @@ static bool g_config_param_read(GCfgParam *param, xmlXPathContextPtr context) char *access; /* Chemin d'accès XML */ char *value; /* Valeur en chaîne de carac. */ unsigned long ulval; /* Valeur transformée */ + GdkRGBA color; /* Couleur transformée */ + char *end; /* Position terminale */ access = strdup(param->path); access = strrpl(access, ".", "/"); @@ -443,6 +450,20 @@ static bool g_config_param_read(GCfgParam *param, xmlXPathContextPtr context) g_config_param_set_value(param, value); break; + case CPT_COLOR: + color.red = strtod(value, &end); + if (*end != ';') goto gcpr_bad_value; + else end++; + color.green = strtod(end, &end); + if (*end != ';') goto gcpr_bad_value; + else end++; + color.blue = strtod(end, &end); + if (*end != ';') goto gcpr_bad_value; + else end++; + color.alpha = strtod(end, &end); + g_config_param_set_value(param, &color); + break; + default: assert(false); break; @@ -457,6 +478,12 @@ static bool g_config_param_read(GCfgParam *param, xmlXPathContextPtr context) return true; + gcpr_bad_value: + + free(value); + + return false; + } @@ -481,6 +508,7 @@ static bool g_config_param_write(GCfgParam *param, xmlDocPtr xdoc, xmlXPathConte char *access; /* Chemin d'accès XML */ char int_val[sizeof(XSTR(INT_MIN)) + 1];/* Valeur en chaîne de carac. */ char ul_val[sizeof(XSTR(ULONG_MAX)) + 1];/* Valeur en chaîne de carac. */ + char *color; /* Valeurs d'une couleur */ state = g_config_param_get_state(param); @@ -524,6 +552,19 @@ static bool g_config_param_write(GCfgParam *param, xmlDocPtr xdoc, xmlXPathConte param->cur.string != NULL ? param->cur.string : ""); break; + case CPT_COLOR: + + asprintf(&color, "%f;%f;%f;%f", + param->cur.color.red, + param->cur.color.green, + param->cur.color.blue, + param->cur.color.alpha); + + result = add_content_to_node(xdoc, context, access, color); + + free(color); + break; + default: assert(false); break; @@ -650,6 +691,14 @@ ConfigParamState g_config_param_get_state(GCfgParam *param) param->cached_state = CPS_CHANGED; break; + case CPT_COLOR: + param->cached_state = (param->def.color.red == param->cur.color.red + && param->def.color.blue == param->cur.color.blue + && param->def.color.green == param->cur.color.green + && param->def.color.alpha == param->cur.color.alpha + ? CPS_DEFAULT : CPS_CHANGED); + break; + default: break; @@ -700,6 +749,13 @@ void g_config_param_make_empty(GCfgParam *param) } break; + case CPT_COLOR: + param->cur.color.red = 0; + param->cur.color.blue = 0; + param->cur.color.green = 0; + param->cur.color.alpha = 0; + break; + default: break; @@ -758,6 +814,10 @@ void g_config_param_reset(GCfgParam *param) param->cur.string = NULL; break; + case CPT_COLOR: + param->cur.color = param->def.color; + break; + default: assert(false); break; @@ -798,6 +858,7 @@ void g_config_param_set_value(GCfgParam *param, ...) int old_integer; /* Valeur entière */ unsigned long old_ulong; /* Valeur entière positive */ char *old_string; /* Chaîne de caractères */ + GdkRGBA old_color; /* Couleur avec transparence */ bool modified; /* Détermine une modification */ va_start(ap, param); @@ -840,6 +901,15 @@ void g_config_param_set_value(GCfgParam *param, ...) break; + case CPT_COLOR: + old_color = param->cur.color; + param->cur.color = *va_arg(ap, GdkRGBA *); + modified = (old_color.red != param->cur.color.red + || old_color.blue != param->cur.color.blue + || old_color.green != param->cur.color.green + || old_color.alpha != param->cur.color.alpha); + break; + default: assert(false); modified = false; @@ -900,6 +970,10 @@ void g_config_param_get_value(GCfgParam *param, ...) *(va_arg(ap, char **)) = param->cur.string; break; + case CPT_COLOR: + *(va_arg(ap, GdkRGBA *)) = param->cur.color; + break; + default: assert(false); break; diff --git a/src/glibext/configuration.h b/src/glibext/configuration.h index 7da2452..0f352ea 100644 --- a/src/glibext/configuration.h +++ b/src/glibext/configuration.h @@ -27,6 +27,7 @@ #include #include +#include @@ -40,6 +41,7 @@ typedef enum _ConfigParamType CPT_INTEGER, /* Valeur entière */ CPT_ULONG, /* Valeur entière positive */ CPT_STRING, /* Chaîne de caractère */ + CPT_COLOR, /* Couleur avec transparence */ CPT_COUNT diff --git a/src/gtkext/graph/edge.c b/src/gtkext/graph/edge.c index 93f020b..b74c049 100644 --- a/src/gtkext/graph/edge.c +++ b/src/gtkext/graph/edge.c @@ -30,6 +30,9 @@ #include +#include "../../core/params.h" + + /* Lien graphique entre deux noeuds graphiques (instance) */ struct _GGraphEdge @@ -470,32 +473,62 @@ bool g_graph_edge_detect_at(const GGraphEdge *edge, gint x, gint y) void g_graph_edge_draw(const GGraphEdge *edge, cairo_t *cairo, bool arrow, bool selected) { + GGenConfig *config; /* Configuration globale */ + GdkRGBA color; /* Couleur de lien définie */ +#ifndef NDEBUG + bool status; /* Validité d'une couleur */ +#endif size_t i; /* Boucle de parcours */ if (selected) cairo_set_source_rgb(cairo, 1.0, 1.0, 1.0); else + { + config = get_main_configuration(); + switch (edge->color) { default: case EGC_DEFAULT: - cairo_set_source_rgb(cairo, 0, 0, 0); +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_DEFAULT, &color); +#else + g_generic_config_get_value(config, MPK_LINK_DEFAULT, &color); +#endif break; case EGC_GREEN: - cairo_set_source_rgb(cairo, 0, 0.6, 0); +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_BRANCH_TRUE, &color); +#else + g_generic_config_get_value(config, MPK_LINK_BRANCH_TRUE, &color); +#endif break; case EGC_RED: - cairo_set_source_rgb(cairo, 0.8, 0, 0); +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_BRANCH_FALSE, &color); +#else + g_generic_config_get_value(config, MPK_LINK_BRANCH_FALSE, &color); +#endif break; case EGC_BLUE: - cairo_set_source_rgb(cairo, 0, 0, 0.8); +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_LOOP, &color); +#else + g_generic_config_get_value(config, MPK_LINK_LOOP, &color); +#endif break; case EGC_DASHED_GRAY: cairo_set_source_rgb(cairo, 0.4, 0.4, 0.4); break; } + assert(status); + + cairo_set_source_rgba(cairo, color.red, color.green, color.blue, color.alpha); + + } + switch (edge->color) { default: diff --git a/src/gui/dialogs/Makefile.am b/src/gui/dialogs/Makefile.am index 755ddbd..869fa7a 100644 --- a/src/gui/dialogs/Makefile.am +++ b/src/gui/dialogs/Makefile.am @@ -7,6 +7,8 @@ UI_FILES = \ bookmark.ui \ identity.ui \ preferences.ui \ + prefs_fgraph.ui \ + prefs_labels.ui \ storage.ui libguidialogs_la_SOURCES = \ @@ -18,6 +20,8 @@ libguidialogs_la_SOURCES = \ identity.h identity.c \ plugins.h plugins.c \ preferences.h preferences.c \ + prefs_fgraph.h prefs_fgraph.c \ + prefs_labels.h prefs_labels.c \ resources.h resources.c \ storage.h storage.c diff --git a/src/gui/dialogs/gresource.xml b/src/gui/dialogs/gresource.xml index b6e3c32..ff606ba 100644 --- a/src/gui/dialogs/gresource.xml +++ b/src/gui/dialogs/gresource.xml @@ -4,6 +4,8 @@ bookmark.ui identity.ui preferences.ui + prefs_fgraph.ui + prefs_labels.ui storage.ui diff --git a/src/gui/dialogs/preferences.c b/src/gui/dialogs/preferences.c index dcb4cc7..8fd1961 100644 --- a/src/gui/dialogs/preferences.c +++ b/src/gui/dialogs/preferences.c @@ -27,6 +27,92 @@ #include +#include "prefs_fgraph.h" +#include "prefs_labels.h" +#include "../../core/params.h" + + + +/* Constructeur de panneau de paramétrage */ +typedef GtkWidget * (* prefs_panel_creation_cb) (GtkBuilder **); + +/* Chargement de la configuration */ +typedef void (* prefs_config_update_cb) (GtkBuilder *, GGenConfig *); + +/* Description d'un noeud de préférences */ +typedef struct _pref_node_desc_t +{ + prefs_panel_creation_cb create; /* Procédure de création */ + prefs_config_update_cb load; /* Procédure de chargement */ + prefs_config_update_cb store; /* Procédure d'enregistrement */ + + const char *name; /* Désignation interne */ + const char *title; /* Désignation humaine */ + + GtkBuilder *builder; /* Constructeur GTK */ + GtkWidget *panel; /* Panneau GTK */ + + struct _pref_node_desc_t *children; /* Sous-arborescence */ + +} pref_node_desc_t; + + +#define PREF_NODE_NULL_ENTRY { .title = NULL } + + +/* Liste des paramétrages à afficher */ +static pref_node_desc_t _prefs_nodes[] = { + + { + .create = NULL, + + .title = "Analysis", + + .children = (pref_node_desc_t []){ + + { + .create = create_labels_preferences, + .load = load_labels_configuration, + .store = store_labels_configuration, + + .name = "labels", + .title = "Colored labels", + + }, + + PREF_NODE_NULL_ENTRY + + } + + }, + + { + .create = NULL, + + .title = "Editor", + + .children = (pref_node_desc_t []){ + + { + .create = create_fgraph_preferences, + .load = load_fgraph_configuration, + .store = store_fgraph_configuration, + + .name = "fgraph", + .title = "Function graph", + + }, + + PREF_NODE_NULL_ENTRY + + } + + }, + + PREF_NODE_NULL_ENTRY + +}; + /* Eléments de la liste de sections */ typedef enum _PrefListItem @@ -37,6 +123,71 @@ typedef enum _PrefListItem } PrefListItem; +/* Ajoute un panneau de paramétrage à la boîte de dialogue. */ +static void add_preferences_node(GtkTreeStore *, GtkTreeIter *, GGenConfig *, GtkStack *, pref_node_desc_t *); + +/* Affiche le panneau correspondant au noeud sélectionné. */ +static void on_prefs_selection_changed(GtkTreeSelection *, GtkBuilder *); + +/* Lance la sauvegarde d'éléments de paramétrage. */ +static void store_preferences_node(GGenConfig *, pref_node_desc_t *); + +/* Sauvegarde l'ensemble des paramètres de configuration. */ +static void on_prefs_apply_button_clicked(GtkButton *, GtkBuilder *); + + + +/****************************************************************************** +* * +* Paramètres : store = arborescence des sections à compléter. * +* parent = point d'insertion du parent. * +* config = configuration globale à charger. * +* stack = pile de composants GTK à constituer. * +* node = noeud de description courant à traiter. * +* * +* Description : Ajoute un panneau de paramétrage à la boîte de dialogue. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void add_preferences_node(GtkTreeStore *store, GtkTreeIter *parent, GGenConfig *config, GtkStack *stack, pref_node_desc_t *node) +{ + GtkTreeIter iter; /* Point d'insertion */ + pref_node_desc_t *child; /* Sous-élément à traiter */ + + if (node->create == NULL) + { + node->builder = NULL; + node->panel = NULL; + } + else + { + node->panel = node->create(&node->builder); + + node->load(node->builder, config); + + gtk_widget_show(node->panel); + + gtk_stack_add_named(stack, node->panel, node->name); + + } + + gtk_tree_store_append(store, &iter, parent); + + gtk_tree_store_set(store, &iter, + PLI_TITLE, _(node->title), + PLI_PANEL, node->panel, + -1); + + if (node->children != NULL) + for (child = node->children; child->title != NULL; child++) + add_preferences_node(store, &iter, config, stack, child); + +} + /****************************************************************************** * * @@ -55,8 +206,11 @@ GtkWidget *create_preferences_dialog(GtkWindow *parent, GtkBuilder **outb) { GtkWidget *result; /* Fenêtre à renvoyer */ GtkBuilder *builder; /* Constructeur utilisé */ + GGenConfig *config; /* Configuration globale */ + GtkStack *stack; /* Pile à mettre à jour */ GtkTreeStore *store; /* Arborescence des sections */ - GtkTreeIter iter; /* Point d'insertion */ + pref_node_desc_t *iter; /* Boucle de parcours */ + GtkTreeView *treeview; /* Arborescence principale */ builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/preferences.ui"); *outb = builder; @@ -67,27 +221,123 @@ GtkWidget *create_preferences_dialog(GtkWindow *parent, GtkBuilder **outb) /* Intégration des différentes sections */ + config = get_main_configuration(); + + stack = GTK_STACK(gtk_builder_get_object(builder, "stack")); + store = GTK_TREE_STORE(gtk_builder_get_object(builder, "pref_list")); - gtk_tree_store_append(store, &iter, NULL); + for (iter = _prefs_nodes; iter->title != NULL; iter++) + add_preferences_node(store, NULL, config, stack, iter); - gtk_tree_store_set(store, &iter, - PLI_TITLE, _("Colored labels"), - PLI_PANEL, gtk_builder_get_object(builder, "colored_labels_panel"), - -1); + treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); - /* Mise à jour de l'interface */ + gtk_tree_view_expand_all(treeview); /* Connexion des signaux */ - /* gtk_builder_add_callback_symbols(builder, - "update_preferences", G_CALLBACK(update_preferences), + "on_prefs_selection_changed", G_CALLBACK(on_prefs_selection_changed), + "on_prefs_apply_button_clicked", G_CALLBACK(on_prefs_apply_button_clicked), NULL); - */ gtk_builder_connect_signals(builder, builder); return result; } + + +/****************************************************************************** +* * +* Paramètres : selection = sélection courante de l'arborescence des options.* +* builder = constructeur GTK avec toutes les références. * +* * +* Description : Affiche le panneau correspondant au noeud sélectionné. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void on_prefs_selection_changed(GtkTreeSelection *selection, GtkBuilder *builder) +{ + GtkTreeModel *model; /* Gestionnaire de données */ + GtkTreeIter iter; /* Position courante */ + GtkWidget *panel; /* Panneau à mettre en avant */ + GtkStack *stack; /* Pile à mettre à jour */ + + if (gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gtk_tree_model_get(model, &iter, PLI_PANEL, &panel, -1); + + stack = GTK_STACK(gtk_builder_get_object(builder, "stack")); + + if (panel == NULL) + gtk_stack_set_visible_child_name(stack, "empty"); + + else + { + gtk_stack_set_visible_child(stack, panel); + + g_object_unref(G_OBJECT(panel)); + + } + + } + +} + + +/****************************************************************************** +* * +* Paramètres : config = configuration globale à actualiser. * +* node = noeud de description courant à traiter. * +* * +* Description : Lance la sauvegarde d'éléments de paramétrage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void store_preferences_node(GGenConfig *config, pref_node_desc_t *node) +{ + pref_node_desc_t *child; /* Sous-élément à traiter */ + + if (node->create != NULL) + node->store(node->builder, config); + + if (node->children != NULL) + for (child = node->children; child->title != NULL; child++) + store_preferences_node(config, child); + +} + + +/****************************************************************************** +* * +* Paramètres : button = bouton GTK à l'origine de l'opération. * +* builder = constructeur GTK avec toutes les références. * +* * +* Description : Sauvegarde l'ensemble des paramètres de configuration. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void on_prefs_apply_button_clicked(GtkButton *button, GtkBuilder *builder) +{ + GGenConfig *config; /* Configuration globale */ + pref_node_desc_t *iter; /* Boucle de parcours */ + + config = get_main_configuration(); + + for (iter = _prefs_nodes; iter->title != NULL; iter++) + store_preferences_node(config, iter); + +} diff --git a/src/gui/dialogs/preferences.ui b/src/gui/dialogs/preferences.ui index 2760399..251ef46 100644 --- a/src/gui/dialogs/preferences.ui +++ b/src/gui/dialogs/preferences.ui @@ -2,23 +2,6 @@ - - - - - - - - global colored labels - - - colored labels for symbols - - - colored labels for basic blocks - - - @@ -68,6 +51,7 @@ True True True + True @@ -97,13 +81,15 @@ 8 in - + True True pref_list False - + + + @@ -125,136 +111,23 @@ - + True False 8 8 8 - + True False vertical - 8 - - True - False - 8 - - - True - False - Specify: - - - False - True - 0 - - - - - True - False - colored_label_types - - - - 0 - - - - - True - True - 1 - - - - - False - True - 0 - - - - - True - False - 8 - - - True - True - in - - - True - True - - - - - - - - True - True - 0 - - - - - True - False - vertical - icons - False - 4 - - - True - False - True - list-add - - - False - True - - - - - True - False - True - list-remove - - - False - True - - - - - False - True - 1 - - - - - True - True - 1 - + - page0 - page0 + empty diff --git a/src/gui/dialogs/prefs_fgraph.c b/src/gui/dialogs/prefs_fgraph.c new file mode 100644 index 0000000..919647e --- /dev/null +++ b/src/gui/dialogs/prefs_fgraph.c @@ -0,0 +1,196 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs_fgraph.c - options relatives aux graphiques de fonction + * + * Copyright (C) 2019 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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 Chrysalide. If not, see . + */ + + +#include "prefs_fgraph.h" + + +#include + + +#include "../../core/params.h" + + + +/****************************************************************************** +* * +* Paramètres : builder = constructeur à détruire après usage. [OUT] * +* * +* Description : Met en place un panneau de paramétrage pour graphiques. * +* * +* Retour : Adresse du composant GTK prêt à emploi. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *create_fgraph_preferences(GtkBuilder **builder) +{ + GtkWidget *result; /* Fenêtre à renvoyer */ + + *builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/prefs_fgraph.ui"); + + result = GTK_WIDGET(gtk_builder_get_object(*builder, "panel")); + + g_object_ref(G_OBJECT(result)); + + gtk_widget_unparent(result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : builder = constructeur contenant les références du dialogue. * +* config = configuration globale à consulter. * +* * +* Description : Charge la configuration des paramétrages pour graphiques. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void load_fgraph_configuration(GtkBuilder *builder, GGenConfig *config) +{ + GdkRGBA color; /* Couleur de lien définie */ +#ifndef NDEBUG + bool status; /* Validité d'une couleur */ +#endif + GtkColorChooser *chooser; /* Bouton de sélection */ + +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_DEFAULT, &color); + assert(status); +#else + g_generic_config_get_value(config, MPK_LINK_DEFAULT, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "def_button")); + + gtk_color_chooser_set_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_BRANCH_TRUE, &color); + assert(status); +#else + g_generic_config_get_value(config, MPK_LINK_BRANCH_TRUE, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "true_button")); + + gtk_color_chooser_set_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_BRANCH_FALSE, &color); + assert(status); +#else + g_generic_config_get_value(config, MPK_LINK_BRANCH_FALSE, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "false_button")); + + gtk_color_chooser_set_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_get_value(config, MPK_LINK_LOOP, &color); + assert(status); +#else + g_generic_config_get_value(config, MPK_LINK_LOOP, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "loop_button")); + + gtk_color_chooser_set_rgba(chooser, &color); + +} + + +/****************************************************************************** +* * +* Paramètres : builder = constructeur contenant les références du dialogue. * +* config = configuration globale à consulter. * +* * +* Description : Sauvegarde la configuration des paramétrages pour graphiques.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void store_fgraph_configuration(GtkBuilder *builder, GGenConfig *config) +{ + GtkColorChooser *chooser; /* Bouton de sélection */ + GdkRGBA color; /* Couleur de lien définie */ +#ifndef NDEBUG + bool status; /* Validité d'une couleur */ +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "def_button")); + + gtk_color_chooser_get_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_set_value(config, MPK_LINK_DEFAULT, &color); + assert(status); +#else + g_generic_config_set_value(config, MPK_LINK_DEFAULT, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "true_button")); + + gtk_color_chooser_get_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_set_value(config, MPK_LINK_BRANCH_TRUE, &color); + assert(status); +#else + g_generic_config_set_value(config, MPK_LINK_BRANCH_TRUE, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "false_button")); + + gtk_color_chooser_get_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_set_value(config, MPK_LINK_BRANCH_FALSE, &color); + assert(status); +#else + g_generic_config_set_value(config, MPK_LINK_BRANCH_FALSE, &color); +#endif + + chooser = GTK_COLOR_CHOOSER(gtk_builder_get_object(builder, "loop_button")); + + gtk_color_chooser_get_rgba(chooser, &color); + +#ifndef NDEBUG + status = g_generic_config_set_value(config, MPK_LINK_LOOP, &color); + assert(status); +#else + g_generic_config_set_value(config, MPK_LINK_LOOP, &color); +#endif + +} diff --git a/src/gui/dialogs/prefs_fgraph.h b/src/gui/dialogs/prefs_fgraph.h new file mode 100644 index 0000000..7d3b153 --- /dev/null +++ b/src/gui/dialogs/prefs_fgraph.h @@ -0,0 +1,46 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs_fgraph.h - prototypes pour les options relatives aux graphiques de fonction + * + * Copyright (C) 2019 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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 Chrysalide. If not, see . + */ + + +#ifndef _GUI_DIALOGS_PREFS_FGRAPH_H +#define _GUI_DIALOGS_PREFS_FGRAPH_H + + +#include + + +#include "../../glibext/configuration.h" + + + +/* Met en place un panneau de paramétrage pour graphiques. */ +GtkWidget *create_fgraph_preferences(GtkBuilder **); + +/* Charge la configuration des paramétrages pour graphiques. */ +void load_fgraph_configuration(GtkBuilder *, GGenConfig *); + +/* Sauvegarde la configuration des paramétrages pour graphiques. */ +void store_fgraph_configuration(GtkBuilder *, GGenConfig *); + + + +#endif /* _GUI_DIALOGS_PREFS_FGRAPH_H */ diff --git a/src/gui/dialogs/prefs_fgraph.ui b/src/gui/dialogs/prefs_fgraph.ui new file mode 100644 index 0000000..6f981cd --- /dev/null +++ b/src/gui/dialogs/prefs_fgraph.ui @@ -0,0 +1,150 @@ + + + + + + False + + + True + False + vertical + + + True + False + 0 + none + + + True + False + 12 + + + True + False + 8 + + + True + False + Default link: + 1 + + + 0 + 0 + + + + + True + True + True + + + 1 + 0 + + + + + True + False + Conditional branching (true): + 1 + + + 0 + 1 + + + + + True + False + Conditional branching (false): + 1 + + + 0 + 2 + + + + + True + False + Loop link: + 1 + + + 0 + 3 + + + + + True + True + True + + + 1 + 1 + + + + + True + True + True + + + 1 + 2 + + + + + True + True + True + + + 1 + 3 + + + + + + + + + True + False + Colors + + + + + False + True + 0 + + + + + + + + + + + + + + + diff --git a/src/gui/dialogs/prefs_labels.c b/src/gui/dialogs/prefs_labels.c new file mode 100644 index 0000000..51d012c --- /dev/null +++ b/src/gui/dialogs/prefs_labels.c @@ -0,0 +1,102 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs_labels.c - paramètres des étiquettes colorées + * + * Copyright (C) 2019 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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 Chrysalide. If not, see . + */ + + +#include "prefs_labels.h" + + + +/****************************************************************************** +* * +* Paramètres : builder = constructeur à détruire après usage. [OUT] * +* * +* Description : Met en place un panneau de paramétrage d'étiquettes colorées.* +* * +* Retour : Adresse du composant GTK prêt à emploi. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *create_labels_preferences(GtkBuilder **builder) +{ + GtkWidget *result; /* Fenêtre à renvoyer */ + + *builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/prefs_labels.ui"); + + result = GTK_WIDGET(gtk_builder_get_object(*builder, "panel")); + + g_object_ref(G_OBJECT(result)); + + gtk_widget_unparent(result); + + /* Connexion des signaux */ + + /* + gtk_builder_add_callback_symbols(builder, + "update_preferences", G_CALLBACK(update_preferences), + NULL); + */ + + gtk_builder_connect_signals(*builder, *builder); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : builder = constructeur contenant les références du dialogue. * +* config = configuration globale à consulter. * +* * +* Description : Charge la configuration des paramétrages pour étiquettes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void load_labels_configuration(GtkBuilder *builder, GGenConfig *config) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : builder = constructeur contenant les références du dialogue. * +* config = configuration globale à consulter. * +* * +* Description : Sauvegarde la configuration des paramétrages pour étiquettes.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void store_labels_configuration(GtkBuilder *builder, GGenConfig *config) +{ + +} diff --git a/src/gui/dialogs/prefs_labels.h b/src/gui/dialogs/prefs_labels.h new file mode 100644 index 0000000..91ab1ab --- /dev/null +++ b/src/gui/dialogs/prefs_labels.h @@ -0,0 +1,46 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs_labels.h - prototypes pour les paramètres des étiquettes colorées + * + * Copyright (C) 2019 Cyrille Bagard + * + * This file is part of Chrysalide. + * + * Chrysalide 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. + * + * Chrysalide 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 Chrysalide. If not, see . + */ + + +#ifndef _GUI_DIALOGS_PREFS_LABELS_H +#define _GUI_DIALOGS_PREFS_LABELS_H + + +#include + + +#include "../../glibext/configuration.h" + + + +/* Met en place un panneau de paramétrage d'étiquettes colorées. */ +GtkWidget *create_labels_preferences(GtkBuilder **); + +/* Charge la configuration des paramétrages pour étiquettes. */ +void load_labels_configuration(GtkBuilder *, GGenConfig *); + +/* Sauvegarde la configuration des paramétrages pour étiquettes. */ +void store_labels_configuration(GtkBuilder *, GGenConfig *); + + + +#endif /* _GUI_DIALOGS_PREFS_LABELS_H */ diff --git a/src/gui/dialogs/prefs_labels.ui b/src/gui/dialogs/prefs_labels.ui new file mode 100644 index 0000000..9bdbec6 --- /dev/null +++ b/src/gui/dialogs/prefs_labels.ui @@ -0,0 +1,150 @@ + + + + + + False + + + True + False + vertical + 8 + + + True + False + 8 + + + True + False + Specify: + + + False + True + 0 + + + + + True + False + colored_label_types + + + + 0 + + + + + True + True + 1 + + + + + False + True + 0 + + + + + True + False + 8 + + + True + True + in + + + True + True + + + + + + + + True + True + 0 + + + + + True + False + vertical + icons + False + 4 + + + True + False + True + list-add + + + False + True + + + + + True + False + True + list-remove + + + False + True + + + + + False + True + 1 + + + + + True + True + 1 + + + + + + + + + + + + + + + + global colored labels + + + colored labels for symbols + + + colored labels for basic blocks + + + + diff --git a/src/gui/panels/regedit.c b/src/gui/panels/regedit.c index 8ecc99b..db98f28 100644 --- a/src/gui/panels/regedit.c +++ b/src/gui/panels/regedit.c @@ -400,6 +400,10 @@ static void reload_config_into_treeview(GRegeditPanel *panel, GGenConfig *config type_desc = _("String"); break; + case CPT_COLOR: + type_desc = _("Color"); + break; + default: type_desc = _(""); break; @@ -536,6 +540,10 @@ static void update_config_param_value(GtkListStore *store, GtkTreeIter *iter) desc = (string != NULL ? string : ""); break; + case CPT_COLOR: + desc = ""; + break; + default: assert(false); desc = "???"; @@ -723,6 +731,9 @@ static void on_param_value_edited(GtkCellRendererText *renderer, gchar *path, gc g_config_param_set_value(param, new); break; + case CPT_COLOR: + break; + default: assert(false); goto opve_bad_value; -- cgit v0.11.2-87-g4458