diff options
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r-- | src/gui/dialogs/Makefile.am | 16 | ||||
-rw-r--r-- | src/gui/dialogs/binadmin.ui | 183 | ||||
-rw-r--r-- | src/gui/dialogs/gresource.xml | 6 | ||||
-rw-r--r-- | src/gui/dialogs/storage.c | 612 | ||||
-rw-r--r-- | src/gui/dialogs/storage.h | 2 |
5 files changed, 278 insertions, 541 deletions
diff --git a/src/gui/dialogs/Makefile.am b/src/gui/dialogs/Makefile.am index a75701f..5a60f25 100644 --- a/src/gui/dialogs/Makefile.am +++ b/src/gui/dialogs/Makefile.am @@ -1,6 +1,11 @@ +BUILT_SOURCES = resources.h resources.c + noinst_LTLIBRARIES = libguidialogs.la +UI_FILES = \ + binadmin.ui + libguidialogs_la_SOURCES = \ about.h about.c \ bookmark.h bookmark.c \ @@ -8,6 +13,7 @@ libguidialogs_la_SOURCES = \ goto.h goto.c \ gotox.h gotox.c \ plugins.h plugins.c \ + resources.h resources.c \ shellcode.h shellcode.c \ storage.h storage.c @@ -19,3 +25,13 @@ AM_CPPFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) SUBDIRS = + + +resources.c: gresource.xml $(UI_FILES) + glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name gui_dialogs gresource.xml + +resources.h: gresource.xml + glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name gui_dialogs gresource.xml + + +CLEANFILES = resources.h resources.c diff --git a/src/gui/dialogs/binadmin.ui b/src/gui/dialogs/binadmin.ui new file mode 100644 index 0000000..0f68228 --- /dev/null +++ b/src/gui/dialogs/binadmin.ui @@ -0,0 +1,183 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> +<interface> + <requires lib="gtk+" version="3.12"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="lower">1</property> + <property name="upper">65535</property> + <property name="value">1337</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkDialog" id="window"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">Storage</property> + <property name="resizable">False</property> + <property name="modal">True</property> + <property name="default_width">700</property> + <property name="default_height">300</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox1"> + <property name="can_focus">False</property> + <property name="margin_left">8</property> + <property name="margin_right">8</property> + <property name="margin_top">8</property> + <property name="margin_bottom">8</property> + <property name="orientation">vertical</property> + <property name="spacing">8</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area1"> + <property name="can_focus">False</property> + <property name="margin_top">8</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button1"> + <property name="label" translatable="yes">Cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button2"> + <property name="label" translatable="yes">Apply</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + </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">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">8</property> + <child> + <object class="GtkRadioButton" id="local_storage"> + <property name="label" translatable="yes">Use the internal local server.</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkRadioButton" id="server_storage"> + <property name="label" translatable="yes">Use a remote shared server:</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="xalign">0</property> + <property name="active">True</property> + <property name="draw_indicator">True</property> + <property name="group">local_storage</property> + <signal name="toggled" handler="on_server_use_toggled" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="box2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">16</property> + <property name="spacing">8</property> + <child> + <object class="GtkLabel" id="server_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Server:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="server"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="text" translatable="yes">localhost</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="port_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Port:</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="port"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="adjustment">adjustment1</property> + <property name="value">1337</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-6">button1</action-widget> + <action-widget response="-10">button2</action-widget> + </action-widgets> + </object> +</interface> diff --git a/src/gui/dialogs/gresource.xml b/src/gui/dialogs/gresource.xml new file mode 100644 index 0000000..913b830 --- /dev/null +++ b/src/gui/dialogs/gresource.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/chrysalide/gui/dialogs"> + <file compressed="true">binadmin.ui</file> + </gresource> +</gresources> diff --git a/src/gui/dialogs/storage.c b/src/gui/dialogs/storage.c index 2e97ca2..c6376d4 100644 --- a/src/gui/dialogs/storage.c +++ b/src/gui/dialogs/storage.c @@ -24,153 +24,20 @@ #include "storage.h" -#include <i18n.h> +/* Réagit à un changement dans le choix du type de serveur. */ +static void on_server_use_toggled(GtkToggleButton *, GtkBuilder *); -#include "../../analysis/db/protocol.h" -#include "../../common/cpp.h" -#include "../../gtkext/easygtk.h" +/* Applique les paramètres d'enregistrement pour un binaire. */ +static void update_binary_storage(GtkButton *, GtkBuilder *); -/* --------------------------- CORPS PRINCIPAL DU CONTENU --------------------------- */ - - -/* Enumération des colonnes de la liste affichée */ -typedef enum StorageColumnTypes -{ - SCT_FEATURE_ID, /* Désignation interne */ - SCT_FEATURE_NAME, /* Désignation humaine */ - SCT_FEATURE_STORAGE, /* Type d'enregistrement */ - SCT_COMBO_COLUMN, /* Fonctionnement du combo */ - - SCT_COUNT - -} StorageColumnTypes; - - -/* Construit l'affichage en liste des enregistrements. */ -static GtkWidget *build_features_list(void); - -/* Sauvegarde l'état des enregistrements et clôt la fenêtre. */ -static void save_storage_params(GtkButton *, GObject *); - - - -/* ---------------------- NOM D'UTILISATEUR ASSOCIE AU BINAIRE ---------------------- */ - - -/* Charge le nom de l'utilisateur associé au binaire. */ -static void load_storage_username(GLoadedBinary *, GObject *); - -/* Sauvegarde le nom de l'utilisateur associé au binaire. */ -static void save_storage_username(GLoadedBinary *, GObject *); - - - -/* ----------------------- SERVEUR DISTANT ASSOCIE AU BINAIRE ----------------------- */ - - -/* Charge la définition du serveur distant associé au binaire. */ -static void load_storage_remote_server(GLoadedBinary *, GObject *); - -/* Sauvegarde la définition du serveur distant du binaire. */ -static void save_storage_remote_server(GLoadedBinary *, GObject *); - -/* Met à jour l'accès aux paramètres du serveur distant. */ -static void on_server_usage_toggle(GtkToggleButton *, GObject *); - - - -/* ------------------------- TRAITEMENT DES FONCTIONNALITES ------------------------- */ - - -/* Remplit la vue présentant les fonctionnalités à traiter. */ -static void fill_storage_features(GtkTreeView *, GLoadedBinary *); - -/* Sauvegarde les statuts d'enregistrement des fonctionnalités. */ -static void save_storage_features(GLoadedBinary *, GObject *); - -/* Met à jour un type d'enregistrement. */ -static void storage_combo_edited_cb(GtkCellRendererText *, const gchar *, const gchar *, GtkListStore *); - - - -/* ---------------------------------------------------------------------------------- */ -/* CORPS PRINCIPAL DU CONTENU */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Construit l'affichage en liste des enregistrements. * -* * -* Retour : Composant graphique prêt à emploi. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkWidget *build_features_list(void) -{ - GtkListStore *store; - GtkWidget *view; - GtkCellRenderer *renderer; - GtkListStore *combo_store; - GtkTreeIter iter; - - store = gtk_list_store_new(SCT_COUNT, - G_TYPE_UINT, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_UINT); - - view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - - g_object_unref(store); - - /* Intitulé des fonctionnalités */ - - renderer = gtk_cell_renderer_text_new(); - - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, - _("Features"), renderer, - "text", SCT_FEATURE_NAME, - NULL); - - /* Type d'enregistrement associé */ - - renderer = gtk_cell_renderer_combo_new(); - - combo_store = gtk_list_store_new(1, G_TYPE_STRING); - gtk_list_store_append(combo_store, &iter); - gtk_list_store_set(combo_store, &iter, 0, _("Local storage"), -1); - gtk_list_store_append(combo_store, &iter); - gtk_list_store_set(combo_store, &iter, 0, _("Remote storage"), -1); - gtk_list_store_append(combo_store, &iter); - gtk_list_store_set(combo_store, &iter, 0, _("Local storage with remote access"), -1); - - g_object_set(G_OBJECT(renderer), "model", combo_store, - "editable", TRUE, "has-entry", FALSE, NULL); - g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(storage_combo_edited_cb), store); - - gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view), -1, - _("Storage"), renderer, - "text", SCT_FEATURE_STORAGE, - "text-column", SCT_COMBO_COLUMN, - NULL); - - return view; - -} - - /****************************************************************************** * * * Paramètres : binary = binaire chargé en mémoire à traiter. * * parent = fenêtre principale de l'éditeur. * +* outb = constructeur à détruire après usage. [OUT] * * * * Description : Propose une définition des propriétés d'enregistrement. * * * @@ -180,110 +47,53 @@ static GtkWidget *build_features_list(void) * * ******************************************************************************/ -GtkWidget *create_storage_dialog(GLoadedBinary *binary, GtkWindow *parent) +GtkWidget *create_storage_dialog(GLoadedBinary *binary, GtkWindow *parent, GtkBuilder **outb) { GtkWidget *result; /* Fenêtre à renvoyer */ - GtkWidget *content; /* Zone principale de la boîte */ - GtkWidget *vbox; /* Support à construire #1 */ - GtkWidget *frame; /* Support avec encadrement */ - GtkWidget *hbox; /* Support à construire #2 */ - GtkWidget *label; /* Etiquette d'indication */ - GtkWidget *entry; /* Zone de saisie de texte */ - GtkWidget *checkbutton; /* Activation de la distance */ - GtkWidget *subvbox; /* Support à construire #3 */ - GtkWidget *scrolledwindow; /* Zone de défilement */ - GtkWidget *treeview; /* Liste des fonctionnalités */ - - result = gtk_dialog_new(); - gtk_window_set_title(GTK_WINDOW(result), _("Storage")); - gtk_widget_set_size_request(result, 400, 360); - gtk_window_set_position(GTK_WINDOW(result), GTK_WIN_POS_CENTER); - gtk_window_set_type_hint(GTK_WINDOW(result), GDK_WINDOW_TYPE_HINT_DIALOG); - - gtk_window_set_modal(GTK_WINDOW(result), TRUE); - gtk_window_set_transient_for(GTK_WINDOW(result), parent); - - g_object_ref(G_OBJECT(binary)); - g_object_set_data_full(G_OBJECT(result), "binary", binary, g_object_unref); - - content = gtk_dialog_get_content_area(GTK_DIALOG(result)); - gtk_widget_show(content); - - vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8); - gtk_widget_show(vbox); - gtk_box_pack_start(GTK_BOX(content), vbox, TRUE, TRUE, 0); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); - - /* Définition de l'identité de l'utilisateur */ + GtkBuilder *builder; /* Constructeur utilisé */ + GtkToggleButton *local_button; /* Choix du serveur local */ + GtkToggleButton *remote_button; /* Choix du serveur distant */ + const char *host; /* Serveur distant à contacter */ + unsigned short port; /* Port d'écoute du serveur */ + GObject *widget; /* Composant à mettre à jour */ - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); - gtk_widget_show(hbox); + builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/binadmin.ui"); + *outb = builder; - frame = qck_create_frame(_("<b>Identity</b>"), hbox, 0, 0, 12, 0); - gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 0); + g_object_set_data(G_OBJECT(builder), "binary", binary); - label = qck_create_label(NULL, NULL, _("Username: ")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + result = GTK_WIDGET(gtk_builder_get_object(builder, "window")); - entry = qck_create_entry(G_OBJECT(result), "username", NULL); - gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); + //gtk_window_set_transient_for(GTK_WINDOW(result), parent); - /* Définition du serveur distant */ + /* Mise à jour de l'interface */ - subvbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - gtk_widget_show(subvbox); + local_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "local_storage")); + remote_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "remote_storage")); - frame = qck_create_frame(_("<b>Server to contact</b>"), subvbox, 0, 0, 12, 0); - gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, TRUE, 0); + if (g_loaded_binary_get_local_storage(binary)) + gtk_toggle_button_set_active(local_button, TRUE); + else + gtk_toggle_button_set_active(remote_button, TRUE); - checkbutton = qck_create_check_button(G_OBJECT(result), "use_remote", - _("Use a remote server:"), - G_CALLBACK(on_server_usage_toggle), result); - gtk_widget_show(checkbutton); - gtk_box_pack_start(GTK_BOX(subvbox), checkbutton, FALSE, FALSE, 0); + g_loaded_binary_get_remote_server(binary, &host, &port); - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4); - gtk_widget_show(hbox); - gtk_box_pack_start(GTK_BOX(subvbox), hbox, TRUE, TRUE, 0); + widget = gtk_builder_get_object(builder, "server"); + gtk_entry_set_text(GTK_ENTRY(widget), host); - label = qck_create_label(G_OBJECT(result), "host", _("Host: ")); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + widget = gtk_builder_get_object(builder, "port"); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(widget), port); - entry = qck_create_entry(G_OBJECT(result), "remote_host", NULL); - gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0); + on_server_use_toggled(remote_button, builder); - label = qck_create_label(G_OBJECT(result), "port", _("Port:")); - gtk_widget_show(label); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + /* Connexion des signaux */ - entry = qck_create_entry(G_OBJECT(result), "remote_port", NULL); - gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, TRUE, 0); + gtk_builder_add_callback_symbols(builder, + "on_server_use_toggled", G_CALLBACK(on_server_use_toggled), + "update_binary_storage", G_CALLBACK(update_binary_storage), + NULL); - /* Affichage des propriétés */ - - scrolledwindow = gtk_scrolled_window_new(NULL, NULL); - gtk_widget_show(scrolledwindow); - gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow, TRUE, TRUE, 0); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolledwindow), GTK_SHADOW_IN); - - treeview = build_features_list(); - g_object_set_data(G_OBJECT(result), "treeview", treeview); - gtk_widget_show(treeview); - gtk_container_add(GTK_CONTAINER(scrolledwindow), treeview); - - /* Zone de contrôle */ - - gtk_dialog_add_button(GTK_DIALOG(result), _("_Cancel"), GTK_RESPONSE_CANCEL); - gtk_dialog_add_button(GTK_DIALOG(result), _("_Ok"), GTK_RESPONSE_OK); - - /* Chargement des données actuelles */ - - load_storage_username(binary, G_OBJECT(result)); - - load_storage_remote_server(binary, G_OBJECT(result)); - - fill_storage_features(GTK_TREE_VIEW(treeview), binary); + gtk_builder_connect_signals(builder, builder); return result; @@ -292,10 +102,10 @@ GtkWidget *create_storage_dialog(GLoadedBinary *binary, GtkWindow *parent) /****************************************************************************** * * -* Paramètres : button = bouton 'OK'. * -* ref = espace de référencement principal. * +* Paramètres : button = bouton à l'origine de la procédure. * +* builder = espace de référencement global. * * * -* Description : Sauvegarde l'état des enregistrements et clôt la fenêtre. * +* Description : Réagit à un changement dans le choix du type de serveur. * * * * Retour : - * * * @@ -303,57 +113,34 @@ GtkWidget *create_storage_dialog(GLoadedBinary *binary, GtkWindow *parent) * * ******************************************************************************/ -static void save_storage_params(GtkButton *button, GObject *ref) +static void on_server_use_toggled(GtkToggleButton *button, GtkBuilder *builder) { - GLoadedBinary *binary; /* Binaire en cours d'édition */ - - binary = G_LOADED_BINARY(g_object_get_data(ref, "binary")); - - save_storage_username(binary, ref); + gboolean active; /* Etat du choix du distant */ + GtkWidget *widget; /* Composant à modifier */ - save_storage_remote_server(binary, ref); - - save_storage_features(binary, ref); - -} + active = gtk_toggle_button_get_active(button); + widget = GTK_WIDGET(gtk_builder_get_object(builder, "server_label")); + gtk_widget_set_sensitive(widget, active); + widget = GTK_WIDGET(gtk_builder_get_object(builder, "server")); + gtk_widget_set_sensitive(widget, active); -/* ---------------------------------------------------------------------------------- */ -/* NOM D'UTILISATEUR ASSOCIE AU BINAIRE */ -/* ---------------------------------------------------------------------------------- */ + widget = GTK_WIDGET(gtk_builder_get_object(builder, "port_label")); + gtk_widget_set_sensitive(widget, active); - -/****************************************************************************** -* * -* Paramètres : binary = binaire chargé en mémoire à traiter. * -* ref = espace de référencement global. * -* * -* Description : Charge le nom de l'utilisateur associé au binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void load_storage_username(GLoadedBinary *binary, GObject *ref) -{ - GtkEntry *entry; /* Zone de saisie de texte */ - - entry = GTK_ENTRY(g_object_get_data(ref, "username")); - - gtk_entry_set_text(entry, g_loaded_binary_get_username(binary)); + widget = GTK_WIDGET(gtk_builder_get_object(builder, "port")); + gtk_widget_set_sensitive(widget, active); } /****************************************************************************** * * -* Paramètres : binary = binaire chargé en mémoire à traiter. * -* ref = espace de référencement global. * +* Paramètres : button = bouton à l'origine de la procédure. * +* builder = espace de référencement global. * * * -* Description : Sauvegarde le nom de l'utilisateur associé au binaire. * +* Description : Applique les paramètres d'enregistrement pour un binaire. * * * * Retour : - * * * @@ -361,288 +148,33 @@ static void load_storage_username(GLoadedBinary *binary, GObject *ref) * * ******************************************************************************/ -static void save_storage_username(GLoadedBinary *binary, GObject *ref) +static void update_binary_storage(GtkButton *button, GtkBuilder *builder) { - GtkEntry *entry; /* Zone de saisie de texte */ - const gchar *text; /* Texte à récupérer */ + GLoadedBinary *binary; /* Binaire à mettre à jour */ + GObject *widget; /* Composant à mettre à jour */ + const gchar *host; /* Serveur distant à contacter */ + gint port; /* Port d'écoute du serveur */ + GtkToggleButton *local_button; /* Choix du serveur local */ + gboolean active; /* Etat du choix du local */ - entry = GTK_ENTRY(g_object_get_data(ref, "username")); - text = gtk_entry_get_text(entry); - - g_loaded_binary_set_username(binary, text); - -} + binary = G_LOADED_BINARY(g_object_get_data(G_OBJECT(builder), "binary")); + /* Infos de connexions à distance */ + widget = gtk_builder_get_object(builder, "server"); + host = gtk_entry_get_text(GTK_ENTRY(widget)); -/* ---------------------------------------------------------------------------------- */ -/* SERVEUR DISTANT ASSOCIE AU BINAIRE */ -/* ---------------------------------------------------------------------------------- */ + widget = gtk_builder_get_object(builder, "port"); + port = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); + g_loaded_binary_set_remote_server(binary, host, port); -/****************************************************************************** -* * -* Paramètres : binary = binaire chargé en mémoire à traiter. * -* ref = espace de référencement global. * -* * -* Description : Charge la définition du serveur distant associé au binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void load_storage_remote_server(GLoadedBinary *binary, GObject *ref) -{ - const char *host; /* Hôte à contacter */ - unsigned short port; /* Port de connexion */ - char port_str[sizeof(XSTR(USHRT_MAX)) + 1]; /* Version chaînée */ - bool use_remote; /* Utilisation du serveur ? */ - GtkEntry *entry; /* Zone de saisie de texte */ - GtkToggleButton *checkbutton; /* Activation de la distance */ - - use_remote = g_loaded_binary_get_remote_server(binary, &host, &port); - sprintf(port_str, "%hu", port); - - entry = GTK_ENTRY(g_object_get_data(ref, "remote_host")); - - gtk_entry_set_text(entry, host); - - entry = GTK_ENTRY(g_object_get_data(ref, "remote_port")); - - gtk_entry_set_text(entry, port_str); - - checkbutton = GTK_TOGGLE_BUTTON(g_object_get_data(ref, "use_remote")); - - gtk_toggle_button_set_active(checkbutton, !use_remote); - gtk_toggle_button_set_active(checkbutton, use_remote); - -} - - -/****************************************************************************** -* * -* Paramètres : binary = binaire chargé en mémoire à traiter. * -* ref = espace de référencement global. * -* * -* Description : Sauvegarde la définition du serveur distant du binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void save_storage_remote_server(GLoadedBinary *binary, GObject *ref) -{ - GtkEntry *entry; /* Zone de saisie de texte */ - const gchar *text; /* Texte à récupérer */ - unsigned short port; /* Port de connexion */ - GtkToggleButton *checkbutton; /* Activation de la distance */ - - entry = GTK_ENTRY(g_object_get_data(ref, "remote_port")); - text = gtk_entry_get_text(entry); - port = atoi(text); - - entry = GTK_ENTRY(g_object_get_data(ref, "remote_host")); - text = gtk_entry_get_text(entry); - - checkbutton = GTK_TOGGLE_BUTTON(g_object_get_data(ref, "use_remote")); - - g_loaded_binary_set_remote_server(binary, text, port, - gtk_toggle_button_get_active(checkbutton)); - -} - - -/****************************************************************************** -* * -* Paramètres : button = oche dont le status vient de changer. * -* ref = espace de référencement global. * -* * -* Description : Met à jour l'accès aux paramètres du serveur distant. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void on_server_usage_toggle(GtkToggleButton *button, GObject *ref) -{ - gboolean state; /* Etat du bouton courant */ - GtkWidget *widget; /* Element dont l'accès change */ - - state = gtk_toggle_button_get_active(button); - - widget = GTK_WIDGET(g_object_get_data(ref, "host")); - if (widget != NULL) - gtk_widget_set_sensitive(widget, state); - - widget = GTK_WIDGET(g_object_get_data(ref, "remote_host")); - if (widget != NULL) - gtk_widget_set_sensitive(widget, state); - - widget = GTK_WIDGET(g_object_get_data(ref, "port")); - if (widget != NULL) - gtk_widget_set_sensitive(widget, state); - - widget = GTK_WIDGET(g_object_get_data(ref, "remote_port")); - if (widget != NULL) - gtk_widget_set_sensitive(widget, state); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* TRAITEMENT DES FONCTIONNALITES */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : treeview = vue à compléter. * -* binary = binaire à manipuler. * -* * -* Description : Remplit la vue présentant les fonctionnalités à traiter. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void fill_storage_features(GtkTreeView *treeview, GLoadedBinary *binary) -{ - GtkListStore *store; /* Gestionnaire de liste */ - DBFeatures i; /* Boucle de parcours */ - DBStorage storage; /* Type d'enregistrement */ - char *human_feature; /* Description humaine #1 */ - char *human_value; /* Description humaine #2 */ - GtkTreeIter iter; /* Point d'insertion */ - - store = GTK_LIST_STORE(gtk_tree_view_get_model(treeview)); - - for (i = 0; i < DBF_COUNT; i++) - { - storage = g_loaded_binary_get_storage(binary, i); - - switch (i) - { - case DBF_COMMENTS: - human_feature = _("Comments"); - break; - case DBF_DISPLAY_SWITCHERS: - human_feature = _("Segments display"); - break; - case DBF_BOOKMARKS: - human_feature = _("Bookmarks"); - break; - default: /* Pour GCC... */ - break; - } - - switch (storage) - { - case DBS_ALL_LOCAL: - human_value = _("Local storage"); - break; - case DBS_ALL_REMOTE: - human_value = _("Remote storage"); - break; - case DBS_LOCAL_AND_REMOTE: - human_value = _("Local storage with remote access"); - break; - } - - gtk_list_store_append(store, &iter); - gtk_list_store_set(store, &iter, - SCT_FEATURE_ID, i, - SCT_FEATURE_NAME, human_feature, - SCT_FEATURE_STORAGE, human_value, - -1); - - } - -} - - -/****************************************************************************** -* * -* Paramètres : binary = binaire chargé en mémoire à traiter. * -* ref = espace de référencement global. * -* * -* Description : Sauvegarde les statuts d'enregistrement des fonctionnalités. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void save_storage_features(GLoadedBinary *binary, GObject *ref) -{ - GtkTreeView *treeview; /* Liste des fonctionnalités */ - GtkTreeModel *store; /* Gestionnaire de liste */ - GtkTreeIter iter; /* Point de lecture */ - gboolean valid; /* Point courant valide ? */ - DBFeatures feature; /* Fonctionnalité traitée */ - char *human_value; /* Description humaine */ - DBStorage storage; /* Type d'enregistrement */ - - treeview = GTK_TREE_VIEW(g_object_get_data(ref, "treeview")); - store = GTK_TREE_MODEL(gtk_tree_view_get_model(treeview)); - - for (valid = gtk_tree_model_get_iter_first(store, &iter); - valid; - valid = gtk_tree_model_iter_next(store, &iter)) - { - gtk_tree_model_get(store, &iter, - SCT_FEATURE_ID, &feature, - SCT_FEATURE_STORAGE, &human_value, - -1); - - if (g_strcmp0(human_value, _("Remote storage")) == 0) - storage = DBS_ALL_REMOTE; - else if (g_strcmp0(human_value, _("Local storage with remote access")) == 0) - storage = DBS_LOCAL_AND_REMOTE; - else - storage = DBS_ALL_LOCAL; - - g_loaded_binary_set_storage(binary, feature, storage); - - } - -} - - -/****************************************************************************** -* * -* Paramètres : cell = cellule du tableau à mettre à jour. * -* path = chemin d'accès à l'élément concerné. * -* value = nouvelle valeur à prendre en compte. * -* store = gestionnaire de liste sur lequel s'appuyer. * -* * -* Description : Met à jour un type d'enregistrement. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void storage_combo_edited_cb(GtkCellRendererText *cell, const gchar *path, const gchar *value, GtkListStore *store) -{ - GtkTreePath *tpath; /* Chemin instancié */ - GtkTreeIter iter; /* Point d'accès pour la maj */ + /* Choix final du serveur */ - tpath = gtk_tree_path_new_from_string(path); + local_button = GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "local_storage")); - if (gtk_tree_model_get_iter(GTK_TREE_MODEL(store), &iter, tpath)) - gtk_list_store_set(store, &iter, SCT_FEATURE_STORAGE, value, -1); + active = gtk_toggle_button_get_active(local_button); - gtk_tree_path_free(tpath); + g_loaded_binary_set_local_storage(binary, active); } diff --git a/src/gui/dialogs/storage.h b/src/gui/dialogs/storage.h index 5cca73b..16dc2dd 100644 --- a/src/gui/dialogs/storage.h +++ b/src/gui/dialogs/storage.h @@ -33,7 +33,7 @@ /* Propose une définition des propriétés d'enregistrement. */ -GtkWidget *create_storage_dialog(GLoadedBinary *, GtkWindow *); +GtkWidget *create_storage_dialog(GLoadedBinary *, GtkWindow *, GtkBuilder **); |