diff options
-rw-r--r-- | src/core/params.c | 12 | ||||
-rw-r--r-- | src/core/params.h | 4 | ||||
-rw-r--r-- | src/glibext/configuration.c | 74 | ||||
-rw-r--r-- | src/glibext/configuration.h | 2 | ||||
-rw-r--r-- | src/gtkext/graph/edge.c | 41 | ||||
-rw-r--r-- | src/gui/dialogs/Makefile.am | 4 | ||||
-rw-r--r-- | src/gui/dialogs/gresource.xml | 2 | ||||
-rw-r--r-- | src/gui/dialogs/preferences.c | 270 | ||||
-rw-r--r-- | src/gui/dialogs/preferences.ui | 145 | ||||
-rw-r--r-- | src/gui/dialogs/prefs_fgraph.c | 196 | ||||
-rw-r--r-- | src/gui/dialogs/prefs_fgraph.h | 46 | ||||
-rw-r--r-- | src/gui/dialogs/prefs_fgraph.ui | 150 | ||||
-rw-r--r-- | src/gui/dialogs/prefs_labels.c | 102 | ||||
-rw-r--r-- | src/gui/dialogs/prefs_labels.h | 46 | ||||
-rw-r--r-- | src/gui/dialogs/prefs_labels.ui | 150 | ||||
-rw-r--r-- | src/gui/panels/regedit.c | 11 |
16 files changed, 1105 insertions, 150 deletions
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, "<Shift>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 <glib-object.h> #include <stdbool.h> +#include <gdk/gdk.h> @@ -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 <string.h> +#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 @@ <file compressed="true">bookmark.ui</file> <file compressed="true">identity.ui</file> <file compressed="true">preferences.ui</file> + <file compressed="true">prefs_fgraph.ui</file> + <file compressed="true">prefs_labels.ui</file> <file compressed="true">storage.ui</file> </gresource> </gresources> 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 <i18n.h> +#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 @@ <!-- Generated with glade 3.21.0 --> <interface> <requires lib="gtk+" version="3.20"/> - <object class="GtkListStore" id="colored_label_types"> - <columns> - <!-- column-name name --> - <column type="gchararray"/> - </columns> - <data> - <row> - <col id="0" translatable="yes">global colored labels</col> - </row> - <row> - <col id="0" translatable="yes">colored labels for symbols</col> - </row> - <row> - <col id="0" translatable="yes">colored labels for basic blocks</col> - </row> - </data> - </object> <object class="GtkTreeStore" id="pref_list"> <columns> <!-- column-name title --> @@ -68,6 +51,7 @@ <property name="can_focus">True</property> <property name="receives_default">True</property> <property name="use_stock">True</property> + <signal name="clicked" handler="on_prefs_apply_button_clicked" swapped="no"/> </object> <packing> <property name="expand">True</property> @@ -97,13 +81,15 @@ <property name="margin_top">8</property> <property name="shadow_type">in</property> <child> - <object class="GtkTreeView"> + <object class="GtkTreeView" id="treeview"> <property name="visible">True</property> <property name="can_focus">True</property> <property name="model">pref_list</property> <property name="headers_visible">False</property> <child internal-child="selection"> - <object class="GtkTreeSelection"/> + <object class="GtkTreeSelection"> + <signal name="changed" handler="on_prefs_selection_changed" swapped="no"/> + </object> </child> <child> <object class="GtkTreeViewColumn"> @@ -125,136 +111,23 @@ </packing> </child> <child> - <object class="GtkStack"> + <object class="GtkStack" id="stack"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="margin_left">8</property> <property name="margin_right">8</property> <property name="margin_top">8</property> <child> - <object class="GtkBox" id="colored_labels_panel"> + <object class="GtkBox"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="orientation">vertical</property> - <property name="spacing">8</property> <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">8</property> - <child> - <object class="GtkLabel"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Specify:</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkComboBox" id="colored_labels_combo"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="model">colored_label_types</property> - <child> - <object class="GtkCellRendererText"/> - <attributes> - <attribute name="text">0</attribute> - </attributes> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkBox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="spacing">8</property> - <child> - <object class="GtkScrolledWindow"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="shadow_type">in</property> - <child> - <object class="GtkTreeView"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <child internal-child="selection"> - <object class="GtkTreeSelection"/> - </child> - </object> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkToolbar"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="orientation">vertical</property> - <property name="toolbar_style">icons</property> - <property name="show_arrow">False</property> - <property name="icon_size">4</property> - <child> - <object class="GtkToolButton" id="colored_label_add"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="use_underline">True</property> - <property name="icon_name">list-add</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - <child> - <object class="GtkToolButton" id="colored_label_remove"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="use_underline">True</property> - <property name="icon_name">list-remove</property> - </object> - <packing> - <property name="expand">False</property> - <property name="homogeneous">True</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> + <placeholder/> </child> </object> <packing> - <property name="name">page0</property> - <property name="title" translatable="yes">page0</property> + <property name="name">empty</property> </packing> </child> </object> 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 <http://www.gnu.org/licenses/>. + */ + + +#include "prefs_fgraph.h" + + +#include <assert.h> + + +#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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GUI_DIALOGS_PREFS_FGRAPH_H +#define _GUI_DIALOGS_PREFS_FGRAPH_H + + +#include <gtk/gtk.h> + + +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.21.0 --> +<interface> + <requires lib="gtk+" version="3.20"/> + <object class="GtkOffscreenWindow"> + <property name="can_focus">False</property> + <child> + <object class="GtkBox" id="panel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkFrame"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <child> + <object class="GtkGrid"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">8</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Default link:</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="def_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Conditional branching (true):</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Conditional branching (false):</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Loop link:</property> + <property name="xalign">1</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">3</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="true_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="false_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkColorButton" id="loop_button"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">3</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Colors</property> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + <child> + <placeholder/> + </child> + </object> +</interface> 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 <http://www.gnu.org/licenses/>. + */ + + +#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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GUI_DIALOGS_PREFS_LABELS_H +#define _GUI_DIALOGS_PREFS_LABELS_H + + +#include <gtk/gtk.h> + + +#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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.21.0 --> +<interface> + <requires lib="gtk+" version="3.20"/> + <object class="GtkOffscreenWindow"> + <property name="can_focus">False</property> + <child> + <object class="GtkBox" id="panel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">8</property> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">8</property> + <child> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Specify:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkComboBox" id="colored_labels_combo"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="model">colored_label_types</property> + <child> + <object class="GtkCellRendererText"/> + <attributes> + <attribute name="text">0</attribute> + </attributes> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">8</property> + <child> + <object class="GtkScrolledWindow"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkToolbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="toolbar_style">icons</property> + <property name="show_arrow">False</property> + <property name="icon_size">4</property> + <child> + <object class="GtkToolButton" id="colored_label_add"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + <property name="icon_name">list-add</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="colored_label_remove"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + <property name="icon_name">list-remove</property> + </object> + <packing> + <property name="expand">False</property> + <property name="homogeneous">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <child> + <placeholder/> + </child> + </object> + <object class="GtkListStore" id="colored_label_types"> + <columns> + <!-- column-name name --> + <column type="gchararray"/> + </columns> + <data> + <row> + <col id="0" translatable="yes">global colored labels</col> + </row> + <row> + <col id="0" translatable="yes">colored labels for symbols</col> + </row> + <row> + <col id="0" translatable="yes">colored labels for basic blocks</col> + </row> + </data> + </object> +</interface> 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 = _("<Unknown type>"); break; @@ -536,6 +540,10 @@ static void update_config_param_value(GtkListStore *store, GtkTreeIter *iter) desc = (string != NULL ? string : ""); break; + case CPT_COLOR: + desc = "<color>"; + 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; |