summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gui/dialogs/Makefile.am1
-rw-r--r--src/gui/dialogs/bookmark.c275
-rw-r--r--src/gui/dialogs/bookmark.h4
-rw-r--r--src/gui/dialogs/bookmark.ui106
-rw-r--r--src/gui/dialogs/gresource.xml3
-rw-r--r--src/gui/dialogs/identity.ui21
-rw-r--r--src/gui/menus/edition.c12
7 files changed, 168 insertions, 254 deletions
diff --git a/src/gui/dialogs/Makefile.am b/src/gui/dialogs/Makefile.am
index 77b97ac..bfda8ad 100644
--- a/src/gui/dialogs/Makefile.am
+++ b/src/gui/dialogs/Makefile.am
@@ -5,6 +5,7 @@ noinst_LTLIBRARIES = libguidialogs.la
UI_FILES = \
binadmin.ui \
+ bookmark.ui \
identity.ui
libguidialogs_la_SOURCES = \
diff --git a/src/gui/dialogs/bookmark.c b/src/gui/dialogs/bookmark.c
index b10a601..08df391 100644
--- a/src/gui/dialogs/bookmark.c
+++ b/src/gui/dialogs/bookmark.c
@@ -24,250 +24,77 @@
#include "bookmark.h"
-#include <ctype.h>
-#include <string.h>
-
-
-#include <i18n.h>
-
-
#include "../../analysis/db/items/bookmark.h"
-#include "../../gtkext/easygtk.h"
-
-/* Filtre les adresses en hexadécimal pendant l'édition. */
-static void filter_addresses(GtkEntry *, const gchar *, gint, gint *, gpointer);
-/* Clôture l'édition d'une adresse. */
-static void validate_addresses(GtkEntry *, GtkDialog *);
+/* Clôture l'édition d'un signet. */
+static void validate_address(GtkEntry *entry, GtkDialog *);
/******************************************************************************
* *
-* Paramètres : entry = composant GTK concerné par la procédure. *
-* text = nouveau texte inséré. *
-* length = taille de ce texte. *
-* position = point d'insertion. *
-* data = adresse non utilisée ici. *
+* Paramètres : parent = fenêtre parente à surpasser. *
+* outb = constructeur à détruire après usage. [OUT] *
* *
-* Description : Filtre les adresses en hexadécimal pendant l'édition. *
+* Description : Construit la fenêtre de création de signet. *
* *
-* Retour : - *
+* Retour : Adresse de la fenêtre mise en place. *
* *
* Remarques : - *
* *
******************************************************************************/
-static void filter_addresses(GtkEntry *entry, const gchar *text, gint length, gint *position, gpointer data)
+GtkWidget *create_bookmark_dialog(GtkWindow *parent, GtkBuilder **outb)
{
- gboolean has_hex; /* Préfixe '0x' déjà présent ? */
- gchar *filtered; /* Contenu nouveau approuvé */
- gint count; /* Nouvelle taille validée */
- gint i; /* Boucle de parcours */
-
- /**
- * On cherche à empêcher l'édition avant un '0x' présent,
- * ce qui viendrait fausser le fitrage.
- */
- has_hex = g_str_has_prefix(gtk_entry_get_text(entry), "0x");
-
- filtered = g_new(gchar, length);
-
- count = 0;
-
- for (i = 0; i < length; i++)
- switch (text[i])
- {
- case '0' ... '9':
- case 'a' ... 'f':
- if (!has_hex || ((i + *position) >= 2))
- filtered[count++] = text[i];
- break;
- case 'A' ... 'F':
- if (!has_hex || ((i + *position) >= 2))
- filtered[count++] = tolower(text[i]);
- break;
- case 'x':
- case 'X':
- if ((i + *position) == 1)
- filtered[count++] = 'x';
- break;
- }
-
- if (count > 0)
- {
- g_signal_handlers_block_by_func(G_OBJECT(entry), G_CALLBACK(filter_addresses), data);
- gtk_editable_insert_text(GTK_EDITABLE(entry), filtered, count, position);
- g_signal_handlers_unblock_by_func(G_OBJECT(entry), G_CALLBACK(filter_addresses), data);
- }
-
- g_signal_stop_emission_by_name(G_OBJECT(entry), "insert_text");
-
- g_free(filtered);
+ GtkWidget *result; /* Fenêtre à renvoyer */
+ GtkBuilder *builder; /* Constructeur utilisé */
-}
+ builder = gtk_builder_new_from_resource("/org/chrysalide/gui/dialogs/bookmark.ui");
+ *outb = builder;
+ result = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
-/******************************************************************************
-* *
-* Paramètres : entry = composant GTK concerné par la procédure. *
-* dialog = boîte de dialogue à valider. *
-* *
-* Description : Clôture l'édition d'une adresse. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
+ gtk_window_set_transient_for(GTK_WINDOW(result), parent);
-static void validate_addresses(GtkEntry *entry, GtkDialog *dialog)
-{
- gtk_dialog_response(dialog, GTK_RESPONSE_OK);
+ /* Connexion des signaux */
+
+ gtk_builder_add_callback_symbols(builder,
+ "validate_address", G_CALLBACK(validate_address),
+ NULL);
+
+ gtk_builder_connect_signals(builder, result);
+
+ return result;
}
/******************************************************************************
* *
-* Paramètres : parent = fenêtre parente à surpasser. *
-* addr = localisation du point à consigner. *
+* Paramètres : entry = composant GTK concerné par la procédure. *
+* dialog = boîte de dialogue à valider. *
* *
-* Description : Construit la fenêtre de création de signet. *
+* Description : Clôture l'édition d'un signet. *
* *
-* Retour : Adresse de la fenêtre mise en place. *
+* Retour : - *
* *
* Remarques : - *
* *
******************************************************************************/
-GtkWidget *create_bookmark_dialog(GtkWindow *parent, const vmpa2t *addr)
+static void validate_address(GtkEntry *entry, GtkDialog *dialog)
{
- GtkWidget *result; /* Fenêtre à renvoyer */
- GtkWidget *dlgvbox; /* Zone principale de la boîte */
- GtkWidget *vbox; /* Support à construire #1 */
- GtkWidget *frame; /* Support avec encadrement */
- GtkWidget *sub_vbox; /* Support à construire #2 */
- GtkWidget *hbox; /* Support à construire #3 */
- GtkWidget *label; /* Message d'introduction */
- GtkWidget *entry; /* Zone de saisie principale */
- GtkWidget *radio; /* Définition de localisation */
- VMPA_BUFFER(target); /* Désignation humaine de cible*/
-
- result = gtk_dialog_new();
- gtk_window_set_title(GTK_WINDOW(result), _("Add a bookmark"));
- 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_transient_for(GTK_WINDOW(result), parent);
-
- dlgvbox = gtk_dialog_get_content_area(GTK_DIALOG(result));
- gtk_widget_show(dlgvbox);
-
- vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
- gtk_widget_show(vbox);
- gtk_box_pack_start(GTK_BOX(dlgvbox), vbox, TRUE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
-
- /* Localisation dans l'espace */
-
- sub_vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
- gtk_widget_show(sub_vbox);
-
- frame = qck_create_frame(_("<b>Localisation</b>"), sub_vbox, 8, 0, 12, 0);
- gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
-
- /* 1) Adresse */
-
- hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
- gtk_widget_show(hbox);
- gtk_box_pack_start(GTK_BOX(sub_vbox), hbox, FALSE, TRUE, 0);
-
- label = qck_create_label(NULL, NULL, _("Target:"));
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
-
- entry = qck_create_entry(G_OBJECT(result), "addr", NULL);
- //g_signal_connect(G_OBJECT(entry), "changed", G_CALLBACK(forbid_text_empty_entry), assistant);
- gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, TRUE, 0);
-
- /* 2) Type d'adresse */
-
- hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 8);
- gtk_widget_show(hbox);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0);
- gtk_container_set_border_width(GTK_CONTAINER(hbox), 8);
-
- radio = qck_create_radio_button(G_OBJECT(result), "phys", _("Value is physical offset"),
- NULL, NULL, NULL);
- gtk_box_pack_start(GTK_BOX(hbox), radio, TRUE, TRUE, 0);
-
- radio = qck_create_radio_button(G_OBJECT(result), "virt", _("Value is virtual address"),
- GTK_RADIO_BUTTON(radio), NULL, NULL);
- gtk_box_pack_start(GTK_BOX(hbox), radio, TRUE, TRUE, 0);
-
- /* Commentaire éventuel */
-
- entry = qck_create_entry(G_OBJECT(result), "comment", NULL);
-
- frame = qck_create_frame(_("<b>Optional comment</b>"), entry, 8, 0, 12, 0);
- gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 0);
-
- /* Zone de validation */
-
- gtk_dialog_add_button(GTK_DIALOG(result), _("_Cancel"), GTK_RESPONSE_CANCEL);
- gtk_dialog_add_button(GTK_DIALOG(result), _("_Ok"), GTK_RESPONSE_OK);
-
- /* Remplissage avec les valeurs fournies */
-
- entry = GTK_WIDGET(g_object_get_data(G_OBJECT(result), "addr"));
-
- if (addr != NULL && has_virt_addr(addr))
- {
- vmpa2_virt_to_string(addr, MDS_UNDEFINED, target, NULL);
- radio = GTK_WIDGET(g_object_get_data(G_OBJECT(result), "virt"));
- }
-
- else if (addr != NULL && has_phys_addr(addr))
- {
- vmpa2_virt_to_string(addr, MDS_UNDEFINED, target, NULL);
- radio = GTK_WIDGET(g_object_get_data(G_OBJECT(result), "virt"));
- }
-
- else
- radio = NULL;
-
- if (radio == NULL)
- {
- gtk_entry_set_text(GTK_ENTRY(entry), "0x");
- gtk_editable_set_position(GTK_EDITABLE(entry), -1);
- gtk_widget_grab_focus(entry);
- }
-
- else
- {
- gtk_entry_set_text(GTK_ENTRY(entry), target);
- gtk_editable_set_position(GTK_EDITABLE(entry), -1);
-
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), TRUE);
-
- }
-
- if (radio != NULL)
- {
- entry = GTK_WIDGET(g_object_get_data(G_OBJECT(result), "comment"));
- gtk_widget_grab_focus(entry);
- }
-
- return result;
+ gtk_dialog_response(dialog, GTK_RESPONSE_OK);
}
/******************************************************************************
* *
-* Paramètres : dialog = boîte de dialogue ayant reçu une validation. *
+* Paramètres : builder = espace de référencement global. *
+* addr = localisation du point à consigner. *
* *
* Description : Fournit le signet conçu via la saisie de l'utilisateur. *
* *
@@ -277,52 +104,24 @@ GtkWidget *create_bookmark_dialog(GtkWindow *parent, const vmpa2t *addr)
* *
******************************************************************************/
-GDbItem *get_item_from_bookmark_dialog(GtkWidget *dialog)
+GDbItem *get_item_from_bookmark_dialog(GtkBuilder *builder, const vmpa2t *addr)
{
GDbItem *result; /* Signet nouveau à retourner */
- GObject *ref; /* Espace de référencements */
- vmpa2t *orig; /* Copie de valeur originale */
- vmpa2t addr; /* Localisation finale utilisée*/
- GtkWidget *entry; /* Zone de saisie principale */
+ GtkEntry *entry; /* Zone de saisie principale */
const gchar *text; /* Adresse en version texte */
- GtkToggleButton *radio; /* Définition de localisation */
-
- ref = G_OBJECT(dialog);
-
- /* Si la valeur d'origine a été conservée intacte... */
-
- orig = (vmpa2t *)g_object_get_data(ref, "orig");
-
- if (orig == NULL)
- {
- entry = GTK_WIDGET(g_object_get_data(ref, "addr"));
- text = gtk_entry_get_text(GTK_ENTRY(entry));
-
- radio = GTK_TOGGLE_BUTTON(g_object_get_data(ref, "phys"));
-
- if (gtk_toggle_button_get_active(radio))
- orig = string_to_vmpa_phy(text);
- else
- orig = string_to_vmpa_virt(text);
-
-
-
- }
-
- copy_vmpa(&addr, orig);
- delete_vmpa(orig);
/* Récupération du commentaire éventuel */
- entry = GTK_WIDGET(g_object_get_data(ref, "comment"));
- text = gtk_entry_get_text(GTK_ENTRY(entry));
+ entry = GTK_ENTRY(gtk_builder_get_object(builder, "comment"));
+
+ text = gtk_entry_get_text(entry);
/* Mise en place du signet défini */
if (strlen(text) > 0)
- result = G_DB_ITEM(g_db_bookmark_new(&addr, text));
+ result = G_DB_ITEM(g_db_bookmark_new(addr, text));
else
- result = G_DB_ITEM(g_db_bookmark_new(&addr, NULL));
+ result = G_DB_ITEM(g_db_bookmark_new(addr, NULL));
return result;
diff --git a/src/gui/dialogs/bookmark.h b/src/gui/dialogs/bookmark.h
index 047f915..fb910bd 100644
--- a/src/gui/dialogs/bookmark.h
+++ b/src/gui/dialogs/bookmark.h
@@ -34,10 +34,10 @@
/* Construit la fenêtre de création de signet. */
-GtkWidget *create_bookmark_dialog(GtkWindow *, const vmpa2t *);
+GtkWidget *create_bookmark_dialog(GtkWindow *, GtkBuilder **);
/* Fournit le signet conçu via la saisie de l'utilisateur. */
-GDbItem *get_item_from_bookmark_dialog(GtkWidget *);
+GDbItem *get_item_from_bookmark_dialog(GtkBuilder *, const vmpa2t *);
diff --git a/src/gui/dialogs/bookmark.ui b/src/gui/dialogs/bookmark.ui
new file mode 100644
index 0000000..85c026b
--- /dev/null
+++ b/src/gui/dialogs/bookmark.ui
@@ -0,0 +1,106 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.21.0 -->
+<interface>
+ <requires lib="gtk+" version="3.20"/>
+ <object class="GtkDialog" id="window">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Add a bookmark</property>
+ <property name="modal">True</property>
+ <property name="window_position">center-on-parent</property>
+ <property name="default_width">350</property>
+ <property name="type_hint">dialog</property>
+ <child internal-child="vbox">
+ <object class="GtkBox">
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox">
+ <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">Ok</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="GtkFrame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">4</property>
+ <property name="margin_right">4</property>
+ <property name="margin_top">4</property>
+ <property name="margin_bottom">4</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="GtkEntry" id="comment">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="margin_top">8</property>
+ <property name="margin_bottom">8</property>
+ <signal name="activate" handler="validate_address" swapped="no"/>
+ </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">Optional comment:</property>
+ </object>
+ </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="-5">button2</action-widget>
+ </action-widgets>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+</interface>
diff --git a/src/gui/dialogs/gresource.xml b/src/gui/dialogs/gresource.xml
index d1ba8b6..4c2f30a 100644
--- a/src/gui/dialogs/gresource.xml
+++ b/src/gui/dialogs/gresource.xml
@@ -2,8 +2,7 @@
<gresources>
<gresource prefix="/org/chrysalide/gui/dialogs">
<file compressed="true">binadmin.ui</file>
- </gresource>
- <gresource prefix="/org/chrysalide/gui/dialogs">
+ <file compressed="true">bookmark.ui</file>
<file compressed="true">identity.ui</file>
</gresource>
</gresources>
diff --git a/src/gui/dialogs/identity.ui b/src/gui/dialogs/identity.ui
index f622a91..25d398f 100644
--- a/src/gui/dialogs/identity.ui
+++ b/src/gui/dialogs/identity.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.21.0 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkDialog" id="window">
@@ -7,7 +7,7 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">Identity</property>
<property name="modal">True</property>
- <property name="window_position">center</property>
+ <property name="window_position">center-on-parent</property>
<property name="default_width">515</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
@@ -87,12 +87,12 @@
<property name="width_request">500</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">0</property>
<property name="label" translatable="yes">All the following information is used to create your authentication certifcate. This certificate grants you access to database servers and identifies each analysis change.
&lt;b&gt;Warning: &lt;/b&gt; updating this information drives to new signing requests for remote servers!</property>
<property name="use_markup">True</property>
<property name="wrap">True</property>
+ <property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -104,8 +104,8 @@
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes">Common name (required):</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -142,8 +142,8 @@
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes">Organisational unit:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -174,8 +174,8 @@
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes">Organisation:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -199,8 +199,8 @@
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes">Locality:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -231,8 +231,8 @@
<object class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes">State:</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -243,8 +243,8 @@
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="xalign">1</property>
<property name="label" translatable="yes">Country (two letters):</property>
+ <property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
@@ -274,5 +274,8 @@
<action-widget response="-6">button1</action-widget>
<action-widget response="-10">button2</action-widget>
</action-widgets>
+ <child>
+ <placeholder/>
+ </child>
</object>
</interface>
diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c
index 04dd9df..1742616 100644
--- a/src/gui/menus/edition.c
+++ b/src/gui/menus/edition.c
@@ -678,6 +678,7 @@ static void mcb_edition_bookmarks_toggle(GtkMenuItem *menuitem, GMenuBar *bar)
GDbCollection *collec; /* Collection à manipuler */
GDbItem *exist; /* Sens du basculement courant */
GObject *ref; /* Espace de référencements */
+ GtkBuilder *builder; /* Constructeur utilisé */
GtkWidget *dialog; /* Boîte de dialogue à montrer */
GDbItem *bookmark; /* Nouveau signet défini */
gint ret; /* Retour de confirmation */
@@ -714,11 +715,14 @@ static void mcb_edition_bookmarks_toggle(GtkMenuItem *menuitem, GMenuBar *bar)
else
{
ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar));
- dialog = create_bookmark_dialog(GTK_WINDOW(ref), curloc);
- if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+ dialog = create_bookmark_dialog(GTK_WINDOW(ref), &builder);
+
+ ret = gtk_dialog_run(GTK_DIALOG(dialog));
+
+ if (ret == GTK_RESPONSE_OK)
{
- bookmark = get_item_from_bookmark_dialog(dialog);
+ bookmark = get_item_from_bookmark_dialog(builder, curloc);
g_db_collection_wlock(G_DB_COLLECTION(collec));
@@ -744,6 +748,8 @@ static void mcb_edition_bookmarks_toggle(GtkMenuItem *menuitem, GMenuBar *bar)
gtk_widget_destroy(dialog);
+ g_object_unref(G_OBJECT(builder));
+
}
g_object_unref(G_OBJECT(collec));