[file-roller] do not show the password dialog if not needed
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [file-roller] do not show the password dialog if not needed
- Date: Wed, 23 Dec 2009 15:22:59 +0000 (UTC)
commit d482e927591ac17d14cb4594ffd08143329c485c
Author: Paolo Bacchilega <paobac src gnome org>
Date: Wed Dec 23 16:17:23 2009 +0100
do not show the password dialog if not needed
check only the files to extract to see if the password prompt
is needed.
[bug #605244]
src/fr-window.c | 48 +++++++++++++++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 9 deletions(-)
---
diff --git a/src/fr-window.c b/src/fr-window.c
index 7d7d791..ac71ca0 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -6477,18 +6477,48 @@ extract_data_free (ExtractData *edata)
static gboolean
-archive_is_encrypted (FrWindow *window)
+archive_is_encrypted (FrWindow *window,
+ GList *file_list)
{
- int i;
+ gboolean encrypted = FALSE;
- for (i = 0; i < window->archive->command->files->len; i++) {
- FileData *fdata = g_ptr_array_index (window->archive->command->files, i);
+ if (file_list == NULL) {
+ int i;
- if (fdata->encrypted)
- return TRUE;
+ for (i = 0; ! encrypted && i < window->archive->command->files->len; i++) {
+ FileData *fdata = g_ptr_array_index (window->archive->command->files, i);
+
+ if (fdata->encrypted)
+ encrypted = TRUE;
+ }
}
+ else {
- return FALSE;
+ GHashTable *file_hash;
+ int i;
+ GList *scan;
+
+ file_hash = g_hash_table_new (g_str_hash, g_str_equal);
+ for (i = 0; i < window->archive->command->files->len; i++) {
+ FileData *fdata = g_ptr_array_index (window->archive->command->files, i);
+ g_hash_table_insert (file_hash, fdata->original_path, fdata);
+ }
+
+ for (scan = file_list; ! encrypted && scan; scan = scan->next) {
+ char *filename = scan->data;
+ FileData *fdata;
+
+ fdata = g_hash_table_lookup (file_hash, filename);
+ g_return_val_if_fail (fdata != NULL, FALSE);
+
+ if (fdata->encrypted)
+ encrypted = TRUE;
+ }
+
+ g_hash_table_destroy (file_hash);
+ }
+
+ return encrypted;
}
@@ -6512,7 +6542,7 @@ fr_window_archive_extract_here (FrWindow *window,
edata,
(GFreeFunc) extract_data_free);
- if (archive_is_encrypted (window) && (window->priv->password == NULL)) {
+ if (archive_is_encrypted (window, NULL) && (window->priv->password == NULL)) {
dlg_ask_password (window);
return;
}
@@ -6558,7 +6588,7 @@ fr_window_archive_extract (FrWindow *window,
edata,
(GFreeFunc) extract_data_free);
- if (archive_is_encrypted (window) && (window->priv->password == NULL)) {
+ if (archive_is_encrypted (window, edata->file_list) && (window->priv->password == NULL)) {
dlg_ask_password (window);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]