[file-roller: 77/123] libarchive: implemented add_dropped_files



commit 809a8c2523442d32cfac7a87eb0f14c48a04669b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Jul 29 18:14:57 2012 +0200

    libarchive: implemented add_dropped_files

 src/fr-archive-libarchive.c |   53 +++++++-
 src/fr-archive.c            |  313 +++++++++++++++++++++++++++++++++++++++--
 src/fr-archive.h            |    4 +-
 src/fr-command.c            |  325 ++++---------------------------------------
 src/fr-window.c             |   10 +-
 src/fr-window.h             |    3 +-
 6 files changed, 382 insertions(+), 326 deletions(-)
---
diff --git a/src/fr-archive-libarchive.c b/src/fr-archive-libarchive.c
index 7081a91..b35ec9b 100644
--- a/src/fr-archive-libarchive.c
+++ b/src/fr-archive-libarchive.c
@@ -1502,15 +1502,14 @@ fr_archive_libarchive_paste_clipboard (FrArchive           *archive,
 }
 
 
-/* -- fr_archive_libarchive_add_dropped_items -- */
+/* -- fr_archive_libarchive_add_dropped_files -- */
 
 
 static void
-fr_archive_libarchive_add_dropped_items (FrArchive           *archive,
-					 GList               *item_list,
+fr_archive_libarchive_add_dropped_files (FrArchive           *archive,
+					 GList               *files,
 					 const char          *base_dir,
 					 const char          *dest_dir,
-					 gboolean             update,
 					 const char          *password,
 					 gboolean             encrypt_header,
 					 FrCompression        compression,
@@ -1519,6 +1518,50 @@ fr_archive_libarchive_add_dropped_items (FrArchive           *archive,
 					 GAsyncReadyCallback  callback,
 					 gpointer             user_data)
 {
+	AddData *add_data;
+	GList   *scan;
+
+	g_return_if_fail (base_dir != NULL);
+
+	add_data = add_data_new ();
+
+	if (dest_dir[0] == '/')
+		dest_dir += 1;
+
+	for (scan = files; scan; scan = scan->next) {
+		const char *uri = (char *) scan->data;
+		char       *filepath;
+		char       *archive_pathname;
+		GFile      *file;
+
+		filepath = g_filename_from_uri (uri, NULL, NULL);
+		if (filepath == NULL)
+			continue;
+
+		archive_pathname = g_build_filename (dest_dir, _g_path_get_file_name (filepath), NULL);
+		file = g_file_new_for_uri (uri);
+		g_hash_table_insert (add_data->files_to_add, archive_pathname, add_file_new (file, archive_pathname));
+
+		g_object_unref (file);
+		g_free (filepath);
+	}
+
+	_fr_archive_libarchive_save (archive,
+				     FALSE,
+				     password,
+				     encrypt_header,
+				     compression,
+				     volume_size,
+				     cancellable,
+				     g_simple_async_result_new (G_OBJECT (archive),
+				     				callback,
+				     				user_data,
+				     				fr_archive_paste_clipboard),
+				     _add_files_begin,
+				     _add_files_end,
+				     _add_files_entry_action,
+				     add_data,
+				     (GDestroyNotify) add_data_free);
 }
 
 
@@ -1602,7 +1645,7 @@ fr_archive_libarchive_class_init (FrArchiveLibarchiveClass *klass)
 	archive_class->remove_files = fr_archive_libarchive_remove_files;
 	archive_class->rename = fr_archive_libarchive_rename;
 	archive_class->paste_clipboard = fr_archive_libarchive_paste_clipboard;
-	archive_class->add_dropped_items = fr_archive_libarchive_add_dropped_items;
+	archive_class->add_dropped_files = fr_archive_libarchive_add_dropped_files;
 	archive_class->update_open_files = fr_archive_libarchive_update_open_files;
 }
 
diff --git a/src/fr-archive.c b/src/fr-archive.c
index e097182..b0a55e9 100644
--- a/src/fr-archive.c
+++ b/src/fr-archive.c
@@ -69,6 +69,9 @@ char *action_names[] = { "NONE",
 G_DEFINE_TYPE (FrArchive, fr_archive, G_TYPE_OBJECT)
 
 
+typedef struct _DroppedItemsData DroppedItemsData;
+
+
 struct _FrArchivePrivate {
 	/* propeties */
 
@@ -91,6 +94,7 @@ struct _FrArchivePrivate {
 	gboolean       have_write_permissions;     /* true if we have the
 						    * permissions to write the
 						    * file. */
+	DroppedItemsData *dropped_items_data;
 };
 
 
@@ -221,6 +225,9 @@ fr_archive_get_property (GObject    *object,
 }
 
 
+static void dropped_items_data_free (DroppedItemsData *data);
+
+
 static void
 fr_archive_finalize (GObject *object)
 {
@@ -239,6 +246,10 @@ fr_archive_finalize (GObject *object)
 	g_mutex_clear (&archive->priv->progress_mutex);
 	g_hash_table_unref (archive->files_hash);
 	_g_ptr_array_free_full (archive->files, (GFunc) file_data_free, NULL);
+	if (archive->priv->dropped_items_data != NULL) {
+		dropped_items_data_free (archive->priv->dropped_items_data);
+		archive->priv->dropped_items_data = NULL;
+	}
 
 	/* Chain up */
 
@@ -312,7 +323,7 @@ fr_archive_class_init (FrArchiveClass *klass)
 	klass->test_integrity = NULL;
 	klass->rename = NULL;
 	klass->paste_clipboard = NULL;
-	klass->add_dropped_items = NULL;
+	klass->add_dropped_files = NULL;
 	klass->update_open_files = NULL;
 
 	/* properties */
@@ -452,6 +463,7 @@ fr_archive_init (FrArchive *self)
         self->priv->total_files = 0;
         self->priv->completed_bytes = 0;
         self->priv->total_bytes = 0;
+        self->priv->dropped_items_data = NULL;
 	g_mutex_init (&self->priv->progress_mutex);
 }
 
@@ -1580,12 +1592,283 @@ fr_archive_paste_clipboard (FrArchive           *archive,
 }
 
 
+/* -- add_dropped_files  -- */
+
+
+struct _DroppedItemsData {
+	FrArchive           *archive;
+	GList               *item_list;
+	char                *base_dir;
+	char                *dest_dir;
+	char                *password;
+	gboolean             encrypt_header;
+	FrCompression        compression;
+	guint                volume_size;
+	GCancellable        *cancellable;
+	GAsyncReadyCallback  callback;
+	gpointer             user_data;
+} ;
+
+
+static DroppedItemsData *
+dropped_items_data_new (FrArchive           *archive,
+			GList               *item_list,
+			const char          *base_dir,
+			const char          *dest_dir,
+			const char          *password,
+			gboolean             encrypt_header,
+			FrCompression        compression,
+			guint                volume_size,
+			GCancellable        *cancellable,
+			GAsyncReadyCallback  callback,
+			gpointer             user_data)
+{
+	DroppedItemsData *data;
+
+	data = g_new0 (DroppedItemsData, 1);
+	data->archive = archive;
+	data->item_list = _g_string_list_dup (item_list);
+	if (base_dir != NULL)
+		data->base_dir = g_strdup (base_dir);
+	if (dest_dir != NULL)
+		data->dest_dir = g_strdup (dest_dir);
+	if (password != NULL)
+		data->password = g_strdup (password);
+	data->encrypt_header = encrypt_header;
+	data->compression = compression;
+	data->volume_size = volume_size;
+	data->cancellable = _g_object_ref (cancellable);
+	data->callback = callback;
+	data->user_data = user_data;
+
+	return data;
+}
+
+
+static void
+dropped_items_data_free (DroppedItemsData *data)
+{
+	if (data == NULL)
+		return;
+	_g_string_list_free (data->item_list);
+	g_free (data->base_dir);
+	g_free (data->dest_dir);
+	g_free (data->password);
+	_g_object_unref (data->cancellable);
+	g_free (data);
+}
+
+
+static gboolean
+all_files_in_same_dir (GList *list)
+{
+	gboolean  same_dir = TRUE;
+	char     *first_basedir;
+	GList    *scan;
+
+	if (list == NULL)
+		return FALSE;
+
+	first_basedir = _g_path_remove_level (list->data);
+	if (first_basedir == NULL)
+		return TRUE;
+
+	for (scan = list->next; scan; scan = scan->next) {
+		char *path = scan->data;
+		char *basedir;
+
+		basedir = _g_path_remove_level (path);
+		if (basedir == NULL) {
+			same_dir = FALSE;
+			break;
+		}
+
+		if (strcmp (first_basedir, basedir) != 0) {
+			same_dir = FALSE;
+			g_free (basedir);
+			break;
+		}
+		g_free (basedir);
+	}
+	g_free (first_basedir);
+
+	return same_dir;
+}
+
+
+static void add_dropped_items (DroppedItemsData *data);
+
+
+static void
+add_dropped_items_ready_cb (GObject      *source_object,
+			    GAsyncResult *result,
+			    gpointer      user_data)
+{
+	DroppedItemsData *data = user_data;
+	FrArchive        *archive = data->archive;
+	GError           *error = NULL;
+
+	fr_archive_operation_finish (FR_ARCHIVE (source_object), result, &error);
+	if (error != NULL) {
+		GSimpleAsyncResult *result;
+
+		result = g_simple_async_result_new (G_OBJECT (data->archive),
+						    data->callback,
+						    data->user_data,
+						    fr_archive_add_dropped_items);
+		g_simple_async_result_set_from_error (result, error);
+		g_simple_async_result_complete_in_idle (result);
+
+		g_error_free (error);
+		dropped_items_data_free (archive->priv->dropped_items_data);
+		archive->priv->dropped_items_data = NULL;
+		return;
+	}
+
+	/* continue adding the items... */
+	add_dropped_items (data);
+}
+
+
+static void
+add_dropped_items (DroppedItemsData *data)
+{
+	FrArchive *archive = data->archive;
+	GList     *list = data->item_list;
+	GList     *scan;
+
+	if (list == NULL) {
+		GSimpleAsyncResult *result;
+
+		result = g_simple_async_result_new (G_OBJECT (data->archive),
+						    data->callback,
+						    data->user_data,
+						    fr_archive_add_dropped_items);
+		g_simple_async_result_complete_in_idle (result);
+
+		dropped_items_data_free (archive->priv->dropped_items_data);
+		archive->priv->dropped_items_data = NULL;
+		return;
+	}
+
+	/* if all files and directories are in the same directory call
+	 * fr_archive_add_items... */
+
+	if (all_files_in_same_dir (list)) {
+		char *first_base_dir;
+
+		data->item_list = NULL;
+
+		first_base_dir = _g_path_remove_level (list->data);
+		fr_archive_add_items (FR_ARCHIVE (archive),
+				      list,
+				      first_base_dir,
+				      data->dest_dir,
+				      FALSE,
+				      data->password,
+				      data->encrypt_header,
+				      data->compression,
+				      data->volume_size,
+				      data->cancellable,
+				      add_dropped_items_ready_cb,
+				      data);
+
+		g_free (first_base_dir);
+		_g_string_list_free (list);
+		return;
+	}
+
+	/* ...else add a directory at a time. */
+
+	for (scan = list; scan; scan = scan->next) {
+		char *path = scan->data;
+		char *base_dir;
+
+		if (! _g_uri_query_is_dir (path))
+			continue;
+
+		data->item_list = g_list_remove_link (list, scan);
+
+		base_dir = _g_path_remove_level (path);
+		fr_archive_add_directory (FR_ARCHIVE (archive),
+					  _g_path_get_file_name (path),
+					  base_dir,
+					  data->dest_dir,
+					  FALSE,
+					  data->password,
+					  data->encrypt_header,
+					  data->compression,
+					  data->volume_size,
+					  data->cancellable,
+					  add_dropped_items_ready_cb,
+					  data);
+
+		g_free (base_dir);
+		g_free (path);
+
+		return;
+	}
+
+	/* At this point all the directories have been added, only files
+	 * remaining.  If all files are in the same directory call
+	 * fr_archive_add_files. */
+
+	data->item_list = NULL;
+
+	if (all_files_in_same_dir (list)) {
+		char  *first_basedir;
+		GList *only_names_list = NULL;
+
+		first_basedir = _g_path_remove_level (list->data);
+		for (scan = list; scan; scan = scan->next) {
+			char *name;
+
+			name = g_uri_unescape_string (_g_path_get_file_name (scan->data), NULL);
+			only_names_list = g_list_prepend (only_names_list, name);
+		}
+
+		fr_archive_add_files (FR_ARCHIVE (archive),
+				      only_names_list,
+				      first_basedir,
+				      data->dest_dir,
+				      FALSE,
+				      FALSE,
+				      data->password,
+				      data->encrypt_header,
+				      data->compression,
+				      data->volume_size,
+				      data->cancellable,
+				      add_dropped_items_ready_cb,
+				      data);
+
+		_g_string_list_free (only_names_list);
+		g_free (first_basedir);
+	}
+	else
+		/* ...else call the archive specific function to add the files in the
+		 * current archive directory. */
+
+		FR_ARCHIVE_GET_CLASS (archive)->add_dropped_files (archive,
+								   list,
+								   data->base_dir,
+								   data->dest_dir,
+								   data->password,
+								   data->encrypt_header,
+								   data->compression,
+								   data->volume_size,
+								   data->cancellable,
+								   add_dropped_items_ready_cb,
+								   data);
+
+	_g_string_list_free (list);
+}
+
+
 void
 fr_archive_add_dropped_items (FrArchive           *archive,
 			      GList               *item_list,
 			      const char          *base_dir,
 			      const char          *dest_dir,
-			      gboolean             update,
 			      const char          *password,
 			      gboolean             encrypt_header,
 			      FrCompression        compression,
@@ -1631,18 +1914,20 @@ fr_archive_add_dropped_items (FrArchive           *archive,
 	}
 	g_free (archive_uri);
 
-	FR_ARCHIVE_GET_CLASS (archive)->add_dropped_items (archive,
-							   item_list,
-							   base_dir,
-							   dest_dir,
-							   update,
-							   password,
-							   encrypt_header,
-							   compression,
-							   volume_size,
-							   cancellable,
-							   callback,
-							   user_data);
+	if (archive->priv->dropped_items_data != NULL)
+		dropped_items_data_free (archive->priv->dropped_items_data);
+	archive->priv->dropped_items_data = dropped_items_data_new (archive,
+								    item_list,
+								    base_dir,
+								    dest_dir,
+								    password,
+								    encrypt_header,
+								    compression,
+								    volume_size,
+								    cancellable,
+								    callback,
+								    user_data);
+	add_dropped_items (archive->priv->dropped_items_data);
 }
 
 
diff --git a/src/fr-archive.h b/src/fr-archive.h
index 4d646ab..bae2ae5 100644
--- a/src/fr-archive.h
+++ b/src/fr-archive.h
@@ -279,11 +279,10 @@ struct _FrArchiveClass {
 					    GCancellable        *cancellable,
 					    GAsyncReadyCallback  callback,
 					    gpointer             user_data);
-	void          (*add_dropped_items) (FrArchive           *archive,
+	void          (*add_dropped_files) (FrArchive           *archive,
 				   	    GList               *item_list,
 				   	    const char          *base_dir,
 				   	    const char          *dest_dir,
-				   	    gboolean             update,
 				   	    const char          *password,
 				   	    gboolean             encrypt_header,
 				   	    FrCompression        compression,
@@ -461,7 +460,6 @@ void          fr_archive_add_dropped_items       (FrArchive           *archive,
 						  GList               *item_list,
 						  const char          *base_dir,
 						  const char          *dest_dir,
-						  gboolean             update,
 						  const char          *password,
 						  gboolean             encrypt_header,
 						  FrCompression        compression,
diff --git a/src/fr-command.c b/src/fr-command.c
index d67185c..fcce2d6 100644
--- a/src/fr-command.c
+++ b/src/fr-command.c
@@ -45,76 +45,6 @@
 #endif
 
 
-/* -- DroppedItemsData -- */
-
-
-typedef struct {
-	FrCommand           *command;
-	GList               *item_list;
-	char                *base_dir;
-	char                *dest_dir;
-	gboolean             update;
-	char                *password;
-	gboolean             encrypt_header;
-	FrCompression        compression;
-	guint                volume_size;
-	GCancellable        *cancellable;
-	GAsyncReadyCallback  callback;
-	gpointer             user_data;
-} DroppedItemsData;
-
-
-static DroppedItemsData *
-dropped_items_data_new (FrCommand           *command,
-			GList               *item_list,
-			const char          *base_dir,
-			const char          *dest_dir,
-			gboolean             update,
-			const char          *password,
-			gboolean             encrypt_header,
-			FrCompression        compression,
-			guint                volume_size,
-			GCancellable        *cancellable,
-			GAsyncReadyCallback  callback,
-			gpointer             user_data)
-{
-	DroppedItemsData *data;
-
-	data = g_new0 (DroppedItemsData, 1);
-	data->command = command;
-	data->item_list = _g_string_list_dup (item_list);
-	if (base_dir != NULL)
-		data->base_dir = g_strdup (base_dir);
-	if (dest_dir != NULL)
-		data->dest_dir = g_strdup (dest_dir);
-	data->update = update;
-	if (password != NULL)
-		data->password = g_strdup (password);
-	data->encrypt_header = encrypt_header;
-	data->compression = compression;
-	data->volume_size = volume_size;
-	data->cancellable = _g_object_ref (cancellable);
-	data->callback = callback;
-	data->user_data = user_data;
-
-	return data;
-}
-
-
-static void
-dropped_items_data_free (DroppedItemsData *data)
-{
-	if (data == NULL)
-		return;
-	_g_string_list_free (data->item_list);
-	g_free (data->base_dir);
-	g_free (data->dest_dir);
-	g_free (data->password);
-	_g_object_unref (data->cancellable);
-	g_free (data);
-}
-
-
 /* -- XferData -- */
 
 
@@ -171,13 +101,11 @@ enum {
 
 
 struct _FrCommandPrivate {
-	GFile            *local_copy;
-	gboolean          is_remote;
-	char             *temp_dir;
-	gboolean          continue_adding_dropped_items;
-	DroppedItemsData *dropped_items_data;
-	char             *temp_extraction_dir;
-	gboolean          remote_extraction;
+	GFile     *local_copy;
+	gboolean   is_remote;
+	char      *temp_dir;
+	char      *temp_extraction_dir;
+	gboolean   remote_extraction;
 };
 
 
@@ -667,10 +595,6 @@ fr_command_finalize (GObject *object)
 
 	_g_object_unref (self->process);
 	_fr_command_remove_temp_work_dir (self);
-	if (self->priv->dropped_items_data != NULL) {
-		dropped_items_data_free (self->priv->dropped_items_data);
-		self->priv->dropped_items_data = NULL;
-	}
 	g_free (self->priv->temp_extraction_dir);
 
 	if (G_OBJECT_CLASS (fr_command_parent_class)->finalize)
@@ -1341,9 +1265,6 @@ add_data_free (AddData *add_data)
 }
 
 
-static void add_dropped_items (DroppedItemsData *data);
-
-
 static void
 process_ready_for_add_files_cb (GObject      *source_object,
 				GAsyncResult *result,
@@ -1361,16 +1282,6 @@ process_ready_for_add_files_cb (GObject      *source_object,
 
 		_fr_command_remove_temp_work_dir (self);
 
-		if (self->priv->continue_adding_dropped_items) {
-			add_dropped_items (self->priv->dropped_items_data);
-			return;
-		}
-
-		if (self->priv->dropped_items_data != NULL) {
-			dropped_items_data_free (self->priv->dropped_items_data);
-			self->priv->dropped_items_data = NULL;
-		}
-
 		/* the name of the volumes are different from the
 		 * original name */
 		if (archive->multi_volume)
@@ -2979,177 +2890,38 @@ fr_command_paste_clipboard (FrArchive           *archive,
 }
 
 
-/* -- fr_command_add_dropped_items -- */
-
-
-static gboolean
-all_files_in_same_dir (GList *list)
-{
-	gboolean  same_dir = TRUE;
-	char     *first_basedir;
-	GList    *scan;
-
-	if (list == NULL)
-		return FALSE;
-
-	first_basedir = _g_path_remove_level (list->data);
-	if (first_basedir == NULL)
-		return TRUE;
-
-	for (scan = list->next; scan; scan = scan->next) {
-		char *path = scan->data;
-		char *basedir;
-
-		basedir = _g_path_remove_level (path);
-		if (basedir == NULL) {
-			same_dir = FALSE;
-			break;
-		}
-
-		if (strcmp (first_basedir, basedir) != 0) {
-			same_dir = FALSE;
-			g_free (basedir);
-			break;
-		}
-		g_free (basedir);
-	}
-	g_free (first_basedir);
-
-	return same_dir;
-}
+/* -- fr_command_add_dropped_files -- */
 
 
 static void
-add_dropped_items (DroppedItemsData *data)
+fr_command_add_dropped_files (FrArchive           *archive,
+		   	      GList               *file_list,
+		   	      const char          *base_dir,
+		   	      const char          *dest_dir,
+		   	      const char          *password,
+		   	      gboolean             encrypt_header,
+		   	      FrCompression        compression,
+		   	      guint                volume_size,
+		   	      GCancellable        *cancellable,
+		   	      GAsyncReadyCallback  callback,
+		   	      gpointer             user_data)
 {
-	FrCommand *self = data->command;
-	GList     *list = data->item_list;
+	FrCommand *self = FR_COMMAND (archive);
 	GList     *scan;
 
-	if (list == NULL) {
-		GSimpleAsyncResult *result;
-
-		result = g_simple_async_result_new (G_OBJECT (data->command),
-						    data->callback,
-						    data->user_data,
-						    fr_archive_add_dropped_items);
-		g_simple_async_result_complete_in_idle (result);
-
-		dropped_items_data_free (self->priv->dropped_items_data);
-		self->priv->dropped_items_data = NULL;
-		return;
-	}
-
-	/* if all files/dirs are in the same directory call fr_archive_add_items... */
-
-	if (all_files_in_same_dir (list)) {
-		char *first_base_dir;
-
-		first_base_dir = _g_path_remove_level (list->data);
-		fr_archive_add_items (FR_ARCHIVE (self),
-				      list,
-				      first_base_dir,
-				      data->dest_dir,
-				      data->update,
-				      data->password,
-				      data->encrypt_header,
-				      data->compression,
-				      data->volume_size,
-				      data->cancellable,
-				      data->callback,
-				      data->user_data);
-
-		g_free (first_base_dir);
-		dropped_items_data_free (self->priv->dropped_items_data);
-		self->priv->dropped_items_data = NULL;
-
-		return;
-	}
-
-	/* ...else add a directory at a time. */
-
-	for (scan = list; scan; scan = scan->next) {
-		char *path = scan->data;
-		char *base_dir;
-
-		if (! _g_uri_query_is_dir (path))
-			continue;
-
-		data->item_list = g_list_remove_link (list, scan);
-		if (data->item_list != NULL)
-			self->priv->continue_adding_dropped_items = TRUE;
-		base_dir = _g_path_remove_level (path);
-
-		fr_archive_add_directory (FR_ARCHIVE (self),
-					  _g_path_get_file_name (path),
-					  base_dir,
-					  data->dest_dir,
-					  data->update,
-					  data->password,
-					  data->encrypt_header,
-					  data->compression,
-					  data->volume_size,
-					  data->cancellable,
-					  data->callback,
-					  data->user_data);
-
-		g_free (base_dir);
-		g_free (path);
-
-		return;
-	}
-
-	/* if all files are in the same directory call fr_archive_add_files. */
-
-	if (all_files_in_same_dir (list)) {
-		char  *first_basedir;
-		GList *only_names_list = NULL;
-
-		first_basedir = _g_path_remove_level (list->data);
-
-		for (scan = list; scan; scan = scan->next) {
-			char *name;
-
-			name = g_uri_unescape_string (_g_path_get_file_name (scan->data), NULL);
-			only_names_list = g_list_prepend (only_names_list, name);
-		}
-
-		fr_archive_add_files (FR_ARCHIVE (self),
-				      only_names_list,
-				      first_basedir,
-				      data->dest_dir,
-				      data->update,
-				      FALSE,
-				      data->password,
-				      data->encrypt_header,
-				      data->compression,
-				      data->volume_size,
-				      data->cancellable,
-				      data->callback,
-				      data->user_data);
-
-		_g_string_list_free (only_names_list);
-		g_free (first_basedir);
-
-		return;
-	}
-
-	/* ...else call fr_command_add for each file.  This is needed to add
-	 * files without path info. FIXME: doesn't work with remote files. */
-
 	fr_archive_set_stoppable (FR_ARCHIVE (self), TRUE);
-	self->creating_archive = ! g_file_query_exists (self->priv->local_copy, data->cancellable);
+	self->creating_archive = ! g_file_query_exists (self->priv->local_copy, cancellable);
 	g_object_set (self,
 		      "filename", self->priv->local_copy,
-		      "password", data->password,
-		      "encrypt-header", data->encrypt_header,
-		      "compression", data->compression,
-		      "volume-size", data->volume_size,
+		      "password", password,
+		      "encrypt-header", encrypt_header,
+		      "compression", compression,
+		      "volume-size", volume_size,
 		      NULL);
 
 	fr_process_clear (self->process);
 	fr_command_uncompress (self);
-	for (scan = list; scan; scan = scan->next) {
+	for (scan = file_list; scan; scan = scan->next) {
 		char  *fullpath = scan->data;
 		char  *basedir;
 		GList *singleton;
@@ -3160,53 +2932,16 @@ add_dropped_items (DroppedItemsData *data)
 				NULL,
 				singleton,
 				basedir,
-				data->update,
+				FALSE,
 				FALSE);
 		g_list_free (singleton);
 		g_free (basedir);
 	}
 	fr_command_recompress (self);
 	fr_process_execute (self->process,
-			    data->cancellable,
-			    data->callback,
-			    data->user_data);
-
-	_g_string_list_free (data->item_list);
-	data->item_list = NULL;
-}
-
-
-static void
-fr_command_add_dropped_items (FrArchive           *archive,
-		   	      GList               *item_list,
-		   	      const char          *base_dir,
-		   	      const char          *dest_dir,
-		   	      gboolean             update,
-		   	      const char          *password,
-		   	      gboolean             encrypt_header,
-		   	      FrCompression        compression,
-		   	      guint                volume_size,
-		   	      GCancellable        *cancellable,
-		   	      GAsyncReadyCallback  callback,
-		   	      gpointer             user_data)
-{
-	FrCommand *self = FR_COMMAND (archive);
-
-	if (self->priv->dropped_items_data != NULL)
-		dropped_items_data_free (self->priv->dropped_items_data);
-	self->priv->dropped_items_data = dropped_items_data_new (self,
-								 item_list,
-								 base_dir,
-								 dest_dir,
-								 update,
-								 password,
-								 encrypt_header,
-								 compression,
-								 volume_size,
-								 cancellable,
-								 callback,
-								 user_data);
-	add_dropped_items (self->priv->dropped_items_data);
+			    cancellable,
+			    callback,
+			    user_data);
 }
 
 
@@ -3327,7 +3062,7 @@ fr_command_class_init (FrCommandClass *klass)
 	archive_class->test_integrity = fr_command_test_integrity;
 	archive_class->rename = fr_command_rename;
 	archive_class->paste_clipboard = fr_command_paste_clipboard;
-	archive_class->add_dropped_items = fr_command_add_dropped_items;
+	archive_class->add_dropped_files = fr_command_add_dropped_files;
 	archive_class->update_open_files = fr_command_update_open_files;
 
 	klass->list = NULL;
@@ -3442,8 +3177,6 @@ fr_command_init (FrCommand *self)
 	self->priv->local_copy = NULL;
 	self->priv->is_remote = FALSE;
 	self->priv->temp_dir = NULL;
-	self->priv->continue_adding_dropped_items = FALSE;
-	self->priv->dropped_items_data = NULL;
 	self->priv->temp_extraction_dir = NULL;
 	self->priv->remote_extraction = FALSE;
 
diff --git a/src/fr-window.c b/src/fr-window.c
index 4da3ec0..35b6dee 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -4142,12 +4142,12 @@ fr_window_drag_data_received  (GtkWidget          *widget,
 			gtk_widget_destroy (GTK_WIDGET (d));
 
 			if (r == 0)  /* Add */
-				fr_window_archive_add_dropped_items (window, list, FALSE);
+				fr_window_archive_add_dropped_items (window, list);
 			else if (r == 1)  /* Open */
 				fr_window_archive_open (window, list->data, GTK_WINDOW (window));
  		}
  		else
-			fr_window_archive_add_dropped_items (window, list, FALSE);
+			fr_window_archive_add_dropped_items (window, list);
 	}
 	else {
 		if (one_file && is_an_archive)
@@ -6563,8 +6563,7 @@ fr_window_archive_add_items (FrWindow      *window,
 
 void
 fr_window_archive_add_dropped_items (FrWindow *window,
-				     GList    *item_list,
-				     gboolean  update)
+				     GList    *item_list)
 {
 	_archive_operation_started (window, FR_ACTION_ADDING_FILES);
 
@@ -6572,7 +6571,6 @@ fr_window_archive_add_dropped_items (FrWindow *window,
 				      item_list,
 				      fr_window_get_current_location (window),
 				      fr_window_get_current_location (window),
-				      update,
 				      window->priv->password,
 				      window->priv->encrypt_header,
 				      window->priv->compression,
@@ -9131,7 +9129,7 @@ fr_window_exec_batch_action (FrWindow      *window,
 	case FR_BATCH_ACTION_ADD:
 		debug (DEBUG_INFO, "[BATCH] ADD\n");
 
-		fr_window_archive_add_dropped_items (window, (GList*) action->data, FALSE);
+		fr_window_archive_add_dropped_items (window, (GList*) action->data);
 		break;
 
 	case FR_BATCH_ACTION_OPEN:
diff --git a/src/fr-window.h b/src/fr-window.h
index 33c9e2e..e94572d 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -140,8 +140,7 @@ void            fr_window_archive_add_items            (FrWindow      *window,
 						        const char    *dest_dir,
 						        gboolean       update);
 void            fr_window_archive_add_dropped_items    (FrWindow      *window,
-						        GList         *item_list,
-						        gboolean       update);
+						        GList         *item_list);
 void            fr_window_archive_remove               (FrWindow      *window,
 						        GList         *file_list);
 void            fr_window_archive_extract              (FrWindow      *window,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]