[file-roller] file-roller delete file in certain circumstances
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [file-roller] file-roller delete file in certain circumstances
- Date: Sun, 15 Feb 2015 13:55:59 +0000 (UTC)
commit da287a996d21545d69dc4bb5813d411acddacae8
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Feb 15 14:51:23 2015 +0100
file-roller delete file in certain circumstances
check whether the archive file is included in the files
to add before asking for the overwrite confirmation
[bug #536834]
src/dlg-batch-add.c | 5 +++++
src/fr-new-archive-dialog.c | 36 ++++++++++++++++++++++++++++++++++++
src/fr-new-archive-dialog.h | 2 ++
3 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/src/dlg-batch-add.c b/src/dlg-batch-add.c
index dd93152..90b667c 100644
--- a/src/dlg-batch-add.c
+++ b/src/dlg-batch-add.c
@@ -26,6 +26,7 @@
#include "fr-new-archive-dialog.h"
#include "fr-window.h"
#include "glib-utils.h"
+#include "gtk-utils.h"
static void
@@ -37,6 +38,7 @@ dialog_response_cb (GtkDialog *dialog,
if (response_id == GTK_RESPONSE_OK) {
GFile *file;
+ GList *scan;
const char *mime_type;
file = fr_new_archive_dialog_get_file (FR_NEW_ARCHIVE_DIALOG (dialog), &mime_type);
@@ -90,10 +92,13 @@ dlg_batch_add_files (FrWindow *window,
parent,
filename,
NULL);
+ fr_new_archive_dialog_set_files_to_add (FR_NEW_ARCHIVE_DIALOG (dialog), file_list);
+
g_signal_connect (dialog,
"response",
G_CALLBACK (dialog_response_cb),
window);
+
gtk_window_present (GTK_WINDOW (dialog));
g_object_unref (parent);
diff --git a/src/fr-new-archive-dialog.c b/src/fr-new-archive-dialog.c
index c6767b9..9da3d1c 100644
--- a/src/fr-new-archive-dialog.c
+++ b/src/fr-new-archive-dialog.c
@@ -46,6 +46,7 @@ struct _FrNewArchiveDialogPrivate {
gboolean can_encrypt_header;
gboolean can_create_volumes;
GFile *original_file;
+ GList *files_to_add;
};
@@ -59,6 +60,7 @@ fr_new_archive_dialog_finalize (GObject *object)
self = FR_NEW_ARCHIVE_DIALOG (object);
+ _g_object_list_unref (self->priv->files_to_add);
_g_object_unref (self->priv->original_file);
g_object_unref (self->priv->settings);
g_object_unref (self->priv->builder);
@@ -117,6 +119,7 @@ fr_new_archive_dialog_init (FrNewArchiveDialog *self)
self->priv->builder = NULL;
self->priv->supported_ext = g_hash_table_new (g_str_hash, g_str_equal);
self->priv->original_file = NULL;
+ self->priv->files_to_add = NULL;
}
@@ -320,6 +323,15 @@ fr_new_archive_dialog_new (const char *title,
}
+void
+fr_new_archive_dialog_set_files_to_add (FrNewArchiveDialog *self,
+ GList *file_list /* GFile list */)
+{
+ _g_object_list_unref (self->priv->files_to_add);
+ self->priv->files_to_add = _g_object_list_ref (file_list);
+}
+
+
GFile *
fr_new_archive_dialog_get_file (FrNewArchiveDialog *self,
const char **mime_type)
@@ -456,6 +468,30 @@ fr_new_archive_dialog_get_file (FrNewArchiveDialog *self,
return NULL;
}
+ /* check whether the file is included in the files to add */
+
+ {
+ GList *scan;
+
+ for (scan = self->priv->files_to_add; scan; scan = scan->next) {
+ if (_g_file_cmp_uris (G_FILE (scan->data), file) == 0) {
+ dialog = _gtk_error_dialog_new (GTK_WINDOW (self),
+ GTK_DIALOG_MODAL,
+ NULL,
+ _("Could not create the archive"),
+ "%s",
+ _("You can't add an archive to itself."));
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (parent_info);
+ g_object_unref (file);
+
+ return NULL;
+ }
+ }
+ }
+
/* overwrite confirmation */
if (g_file_query_exists (file, NULL)) {
diff --git a/src/fr-new-archive-dialog.h b/src/fr-new-archive-dialog.h
index 4a6d3ee..0e4840f 100644
--- a/src/fr-new-archive-dialog.h
+++ b/src/fr-new-archive-dialog.h
@@ -57,6 +57,8 @@ GtkWidget * fr_new_archive_dialog_new (const char *
GFile *folder,
const char *default_name,
GFile *original_file);
+void fr_new_archive_dialog_set_files_to_add (FrNewArchiveDialog *dialog,
+ GList *file_list /* GFile list */);
GFile * fr_new_archive_dialog_get_file (FrNewArchiveDialog *dialog,
const char **mime_type);
const char * fr_new_archive_dialog_get_password (FrNewArchiveDialog *dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]