[nautilus/wip/feborges/password-protected-archives: 44/44] file-operations: Add support for password protected archives
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/feborges/password-protected-archives: 44/44] file-operations: Add support for password protected archives
- Date: Tue, 26 Jan 2021 11:19:26 +0000 (UTC)
commit ec5d3531324bfd97b51732a90b615f6093e1442b
Author: Felipe Borges <felipeborges gnome org>
Date: Tue Jan 7 09:43:22 2020 +0100
file-operations: Add support for password protected archives
See https://gitlab.gnome.org/GNOME/nautilus/-/issues/327
src/nautilus-file-operations.c | 54 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 85c42f12f..3a0ef0104 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -8388,6 +8388,57 @@ extract_job_on_completed (AutoarExtractor *extractor,
nautilus_file_changes_queue_file_added (output_file);
}
+static gchar *
+extract_job_on_request_passphrase (AutoarExtractor *extractor,
+ gpointer user_data)
+{
+ ExtractJob *extract_job = user_data;
+ g_autofree gchar *label_str = NULL;
+ GtkWidget *dialog;
+ GtkWidget *entry;
+ GtkWidget *label;
+ GtkWidget *box;
+ gchar *passphrase = NULL;
+
+ dialog = gtk_dialog_new_with_buttons (_("Password Required"),
+ extract_job->common.parent_window,
+ GTK_DIALOG_USE_HEADER_BAR,
+ _("Cancel"), GTK_RESPONSE_CANCEL,
+ _("Extract"), GTK_RESPONSE_OK,
+ NULL);
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 20);
+ gtk_container_set_border_width (GTK_CONTAINER (box), 20);
+ gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), GTK_WIDGET (box));
+
+ label_str = g_strdup_printf (_("%s is password protected."),
+ g_file_get_basename (G_FILE (extract_job->source_files->data)));
+
+ label = gtk_label_new (label_str);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_label_set_max_width_chars (GTK_LABEL (label), 60);
+ gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_container_add (GTK_CONTAINER (box), label);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_placeholder_text (GTK_ENTRY (entry), _("Enter password…"));
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+ gtk_entry_set_invisible_char (GTK_ENTRY (entry), 0x2022);
+ gtk_entry_set_input_purpose (GTK_ENTRY (entry), GTK_INPUT_PURPOSE_PASSWORD);
+ gtk_container_add (GTK_CONTAINER (box), entry);
+
+ gtk_widget_show_all (box);
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK)
+ {
+ passphrase = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
+ } else {
+ abort_job ((CommonJob *) user_data);
+ }
+
+ gtk_widget_destroy (dialog);
+
+ return g_strdup (passphrase);
+}
+
static void
extract_job_on_scanned (AutoarExtractor *extractor,
guint total_files,
@@ -8548,6 +8599,9 @@ extract_task_thread_func (GTask *task,
g_signal_connect (extractor, "completed",
G_CALLBACK (extract_job_on_completed),
extract_job);
+ g_signal_connect (extractor, "request-passphrase",
+ G_CALLBACK (extract_job_on_request_passphrase),
+ extract_job);
extract_job->archive_compressed_size = archive_compressed_sizes[i];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]