[gnome-disk-utility/udisks2-port] Add password entries when creating an encrypted volume
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-disk-utility/udisks2-port] Add password entries when creating an encrypted volume
- Date: Wed, 2 Nov 2011 18:11:46 +0000 (UTC)
commit 3b7452665b05aead361f5d57024914d27eabcd28
Author: David Zeuthen <davidz redhat com>
Date: Wed Nov 2 14:11:26 2011 -0400
Add password entries when creating an encrypted volume
Signed-off-by: David Zeuthen <davidz redhat com>
data/ui/format-volume-dialog.ui | 104 ++++++++++++++++++++++++++++++++
src/palimpsest/gduformatvolumedialog.c | 84 +++++++++++++++++++++----
2 files changed, 174 insertions(+), 14 deletions(-)
---
diff --git a/data/ui/format-volume-dialog.ui b/data/ui/format-volume-dialog.ui
index ef36732..d3a7f0f 100644
--- a/data/ui/format-volume-dialog.ui
+++ b/data/ui/format-volume-dialog.ui
@@ -184,6 +184,110 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="passphrase-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">_Passphrase:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">passphrase-entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="confirm-passphrase-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">C_onfirm Passphrase:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">confirm-passphrase-entry</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="passphrase-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Enter passphrase used to protect the data</property>
+ <property name="visibility">False</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">True</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">3</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="confirm-passphrase-entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="no_show_all">True</property>
+ <property name="has_tooltip">True</property>
+ <property name="tooltip_markup" translatable="yes">Confirm passphrase entered above</property>
+ <property name="visibility">False</property>
+ <property name="invisible_char">â</property>
+ <property name="activates_default">True</property>
+ <property name="invisible_char_set">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">4</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="show-passphrase-checkbutton">
+ <property name="label" translatable="yes">_Show Passphrases</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="no_show_all">True</property>
+ <property name="tooltip_markup" translatable="yes">Check this box to see the passphrases entered above</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_underline">True</property>
+ <property name="xalign">0</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="top_attach">5</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
<placeholder/>
</child>
<child>
diff --git a/src/palimpsest/gduformatvolumedialog.c b/src/palimpsest/gduformatvolumedialog.c
index 7b652ef..b524a78 100644
--- a/src/palimpsest/gduformatvolumedialog.c
+++ b/src/palimpsest/gduformatvolumedialog.c
@@ -45,6 +45,13 @@ typedef struct
GtkWidget *name_entry;
GtkWidget *filesystem_label;
GtkWidget *filesystem_entry;
+
+ GtkWidget *passphrase_label;
+ GtkWidget *passphrase_entry;
+ GtkWidget *confirm_passphrase_label;
+ GtkWidget *confirm_passphrase_entry;
+ GtkWidget *show_passphrase_checkbutton;
+
} FormatVolumeData;
static void
@@ -66,13 +73,28 @@ format_volume_data_free (FormatVolumeData *data)
static void
format_volume_update (FormatVolumeData *data)
{
- gboolean show_filesystem = FALSE;
+ gboolean show_filesystem_widgets = FALSE;
+ gboolean show_passphrase_widgets = FALSE;
gboolean can_proceed = FALSE;
- if (gtk_combo_box_get_active (GTK_COMBO_BOX (data->type_combobox)) == 3)
+ switch (gtk_combo_box_get_active (GTK_COMBO_BOX (data->type_combobox)))
{
- /* "Custom" selected */
- show_filesystem = TRUE;
+ case 2:
+ /* Encrypted, compatible with Linux (LUKS + ext4) */
+ show_passphrase_widgets = TRUE;
+ if (strlen (gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry))) > 0)
+ {
+ if (g_strcmp0 (gtk_entry_get_text (GTK_ENTRY (data->passphrase_entry)),
+ gtk_entry_get_text (GTK_ENTRY (data->confirm_passphrase_entry))) == 0)
+ {
+ can_proceed = TRUE;
+ }
+ }
+ break;
+
+ case 3:
+ /* Custom */
+ show_filesystem_widgets = TRUE;
if (strlen (gtk_entry_get_text (GTK_ENTRY (data->filesystem_entry))) > 0)
{
/* TODO: maybe validate we know how to create this FS?
@@ -80,13 +102,14 @@ format_volume_update (FormatVolumeData *data)
*/
can_proceed = TRUE;
}
- }
- else
- {
+ break;
+
+ default:
can_proceed = TRUE;
+ break;
}
- if (show_filesystem)
+ if (show_filesystem_widgets)
{
gtk_widget_show (data->filesystem_label);
gtk_widget_show (data->filesystem_entry);
@@ -97,6 +120,23 @@ format_volume_update (FormatVolumeData *data)
gtk_widget_hide (data->filesystem_entry);
}
+ if (show_passphrase_widgets)
+ {
+ gtk_widget_show (data->passphrase_label);
+ gtk_widget_show (data->passphrase_entry);
+ gtk_widget_show (data->confirm_passphrase_label);
+ gtk_widget_show (data->confirm_passphrase_entry);
+ gtk_widget_show (data->show_passphrase_checkbutton);
+ }
+ else
+ {
+ gtk_widget_hide (data->passphrase_label);
+ gtk_widget_hide (data->passphrase_entry);
+ gtk_widget_hide (data->confirm_passphrase_label);
+ gtk_widget_hide (data->confirm_passphrase_entry);
+ gtk_widget_hide (data->show_passphrase_checkbutton);
+ }
+
gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, can_proceed);
}
@@ -120,6 +160,17 @@ format_volume_populate (FormatVolumeData *data)
/* Set 'swap' for the custom filesystem */
gtk_entry_set_text (GTK_ENTRY (data->filesystem_entry), "swap");
+
+ g_object_bind_property (data->show_passphrase_checkbutton,
+ "active",
+ data->passphrase_entry,
+ "visibility",
+ G_BINDING_SYNC_CREATE);
+ g_object_bind_property (data->show_passphrase_checkbutton,
+ "active",
+ data->confirm_passphrase_entry,
+ "visibility",
+ G_BINDING_SYNC_CREATE);
}
void
@@ -140,15 +191,20 @@ gdu_format_volume_dialog_show (GduWindow *window,
"format-volume-dialog",
&data->builder);
data->type_combobox = GTK_WIDGET (gtk_builder_get_object (data->builder, "type-combobox"));
- g_signal_connect (data->type_combobox,
- "notify::active", G_CALLBACK (format_volume_property_changed), data);
+ g_signal_connect (data->type_combobox, "notify::active", G_CALLBACK (format_volume_property_changed), data);
data->name_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "name-entry"));
- g_signal_connect (data->name_entry,
- "notify::text", G_CALLBACK (format_volume_property_changed), data);
+ g_signal_connect (data->name_entry, "notify::text", G_CALLBACK (format_volume_property_changed), data);
data->filesystem_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "filesystem-label"));
data->filesystem_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "filesystem-entry"));
- g_signal_connect (data->filesystem_entry,
- "notify::text", G_CALLBACK (format_volume_property_changed), data);
+ g_signal_connect (data->filesystem_entry, "notify::text", G_CALLBACK (format_volume_property_changed), data);
+ data->passphrase_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "passphrase-label"));
+ data->passphrase_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "passphrase-entry"));
+ g_signal_connect (data->passphrase_entry, "notify::text", G_CALLBACK (format_volume_property_changed), data);
+ data->confirm_passphrase_label = GTK_WIDGET (gtk_builder_get_object (data->builder, "confirm-passphrase-label"));
+ data->confirm_passphrase_entry = GTK_WIDGET (gtk_builder_get_object (data->builder, "confirm-passphrase-entry"));
+ g_signal_connect (data->confirm_passphrase_entry, "notify::text", G_CALLBACK (format_volume_property_changed), data);
+ data->show_passphrase_checkbutton = GTK_WIDGET (gtk_builder_get_object (data->builder, "show-passphrase-checkbutton"));
+ g_signal_connect (data->show_passphrase_checkbutton, "notify::active", G_CALLBACK (format_volume_property_changed), data);
gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window));
gtk_dialog_set_default_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]