[nautilus/wip/feborges/password-protected-archives: 66/66] file-operations: Add support for password protected archives




commit 899643571ea50c4d3786ecd1b39f6a5bd355e1d5
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 | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
---
diff --git a/src/nautilus-file-operations.c b/src/nautilus-file-operations.c
index 43ed33941..6a59f7e74 100644
--- a/src/nautilus-file-operations.c
+++ b/src/nautilus-file-operations.c
@@ -8254,6 +8254,39 @@ 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)
+{
+  GtkWidget *dialog;
+  GtkWidget *entry;
+  GtkWidget *box;
+  gchar *passphrase = NULL;
+
+  dialog = gtk_dialog_new_with_buttons (_("Enter passphrase"),
+                                        NULL,
+                                        GTK_DIALOG_USE_HEADER_BAR,
+                                        _("Cancel"), GTK_RESPONSE_CANCEL,
+                                        _("Set"), GTK_RESPONSE_OK,
+                                        NULL);
+  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), GTK_WIDGET (box));
+  entry = gtk_entry_new ();
+  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,
@@ -8414,6 +8447,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]