diff options
author | ZenWalker <[email protected]> | 2017-05-02 20:15:58 +0200 |
---|---|---|
committer | raveit65 <[email protected]> | 2017-05-16 20:51:51 +0200 |
commit | fc6bad0f92a91071e06b8bed9d33f15fa7f8c2bf (patch) | |
tree | d591371fb7faf69db363a03da3dc0edaf2522a07 | |
parent | 0a78609dfbaeba6f6897c37113f5750a5fe69472 (diff) | |
download | engrampa-fc6bad0f92a91071e06b8bed9d33f15fa7f8c2bf.tar.bz2 engrampa-fc6bad0f92a91071e06b8bed9d33f15fa7f8c2bf.tar.xz |
Fix: Wrong behavior of Skip button in Replace file dialog
based in file-roller commit:
https://git.gnome.org/browse/file-roller/commit/?id=fe71357aa128d029b6ca4a9493b8a408c8aaf017
Fixes #161
-rw-r--r-- | src/fr-window.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/src/fr-window.c b/src/fr-window.c index 0dbd2a6..9ac4053 100644 --- a/src/fr-window.c +++ b/src/fr-window.c @@ -3519,6 +3519,24 @@ fr_window_get_file_list_pattern (FrWindow *window, } +static GList * +fr_window_get_file_list (FrWindow *window) +{ + GList *list; + int i; + + g_return_val_if_fail (window != NULL, NULL); + + list = NULL; + for (i = 0; i < window->archive->command->files->len; i++) { + FileData *fd = g_ptr_array_index (window->archive->command->files, i); + list = g_list_prepend (list, g_strdup (fd->original_path)); + } + + return g_list_reverse (list); +} + + int fr_window_get_n_selected_files (FrWindow *window) { @@ -6646,6 +6664,7 @@ typedef struct { FrWindow *window; ExtractData *edata; GList *current_file; + gboolean extract_all; } OverwriteData; @@ -6700,6 +6719,7 @@ overwrite_dialog_response_cb (GtkDialog *dialog, odata->edata->file_list = g_list_remove_link (odata->edata->file_list, odata->current_file); path_list_free (odata->current_file); odata->current_file = next; + odata->extract_all = FALSE; } break; @@ -6727,8 +6747,6 @@ overwrite_dialog_response_cb (GtkDialog *dialog, static void _fr_window_ask_overwrite_dialog (OverwriteData *odata) { - gboolean do_not_extract = FALSE; - while ((odata->edata->overwrite == FR_OVERWRITE_ASK) && (odata->current_file != NULL)) { const char *base_name; char *e_base_name; @@ -6799,14 +6817,32 @@ _fr_window_ask_overwrite_dialog (OverwriteData *odata) g_object_unref (file); } - if (do_not_extract) { - fr_window_stop_batch (odata->window); - g_free (odata); - return; + if (odata->edata->file_list != NULL) { + /* speed optimization: passing NULL when extracting all the + * files is faster if the command supports the + * propCanExtractAll property. */ + if (odata->extract_all) { + path_list_free (odata->edata->file_list); + odata->edata->file_list = NULL; + } + odata->edata->overwrite = FR_OVERWRITE_YES; + _fr_window_archive_extract_from_edata (odata->window, odata->edata); } + else { + GtkWidget *d; - odata->edata->overwrite = FR_OVERWRITE_YES; - _fr_window_archive_extract_from_edata (odata->window, odata->edata); + d = _gtk_message_dialog_new (GTK_WINDOW (odata->window), + 0, + GTK_STOCK_DIALOG_WARNING, + _("Extraction not performed"), + NULL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); + gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK); + fr_window_show_error_dialog (odata->window, d, GTK_WINDOW (odata->window), _("Extraction not performed")); + + fr_window_stop_batch (odata->window); + } g_free (odata); } @@ -6923,6 +6959,9 @@ fr_window_archive_extract (FrWindow *window, odata = g_new0 (OverwriteData, 1); odata->window = window; odata->edata = edata; + odata->extract_all = (edata->file_list == NULL) || (g_list_length (edata->file_list) == window->archive->command->files->len); + if (edata->file_list == NULL) + edata->file_list = fr_window_get_file_list (window); odata->current_file = odata->edata->file_list; _fr_window_ask_overwrite_dialog (odata); } |