[file-roller] Allow to archive files with spaces and other special characters



commit 47fb26b6e2c2be1511594395428ccd86c297b877
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sun Aug 2 10:32:57 2009 +0200

    Allow to archive files with spaces and other special characters
    
    [fixed bug #590468]

 src/dlg-add-files.c |   18 +++++++++---------
 src/fr-window.c     |   26 ++++++++++++++++++--------
 src/fr-window.h     |    2 +-
 3 files changed, 28 insertions(+), 18 deletions(-)
---
diff --git a/src/dlg-add-files.c b/src/dlg-add-files.c
index f7434eb..031f652 100644
--- a/src/dlg-add-files.c
+++ b/src/dlg-add-files.c
@@ -67,7 +67,7 @@ file_sel_response_cb (GtkWidget      *widget,
 	eel_gconf_set_string (PREF_ADD_FILENAME, uri);
 	fr_window_set_add_default_dir (window, current_folder);
 	g_free (uri);
-	
+
 	if ((response == GTK_RESPONSE_CANCEL) || (response == GTK_RESPONSE_DELETE_EVENT)) {
 		gtk_widget_destroy (data->dialog);
 		g_free (current_folder);
@@ -92,7 +92,7 @@ file_sel_response_cb (GtkWidget      *widget,
 					   GTK_DIALOG_MODAL,
 					   NULL,
 					   _("Could not add the files to the archive"),
-					   _("You don't have the right permissions to read files from folder \"%s\""), 
+					   _("You don't have the right permissions to read files from folder \"%s\""),
 					   utf8_path);
 		gtk_dialog_run (GTK_DIALOG (d));
 		gtk_widget_destroy (GTK_WIDGET (d));
@@ -108,14 +108,14 @@ file_sel_response_cb (GtkWidget      *widget,
 
 	selections = gtk_file_chooser_get_uris (file_sel);
 	for (iter = selections; iter != NULL; iter = iter->next) {
-		char *path = iter->data;
-		item_list = g_list_prepend (item_list, path);
+		char *uri = iter->data;
+		item_list = g_list_prepend (item_list, g_file_new_for_uri (uri));
 	}
 
 	if (item_list != NULL)
 		fr_window_archive_add_files (window, item_list, update);
 
-	g_list_free (item_list);
+	gio_file_list_free (item_list);
 	g_slist_foreach (selections, (GFunc) g_free, NULL);
 	g_slist_free (selections);
 	g_free (current_folder);
@@ -135,7 +135,7 @@ add_files_cb (GtkWidget *widget,
 	DialogData *data;
 	GtkWidget  *main_box;
 	char       *folder;
-	
+
 	data = g_new0 (DialogData, 1);
 	data->window = callback_data;
 	data->dialog = file_sel =
@@ -167,15 +167,15 @@ add_files_cb (GtkWidget *widget,
 	/* set data */
 
 	folder = eel_gconf_get_string (PREF_ADD_CURRENT_FOLDER, "");
-	if ((folder == NULL) || (strcmp (folder, "") == 0)) 
+	if ((folder == NULL) || (strcmp (folder, "") == 0))
 		folder = g_strdup (fr_window_get_add_default_dir (data->window));
 	gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (file_sel), folder);
 	g_free (folder);
-	
+
 	/* signals */
 
 	g_signal_connect (G_OBJECT (file_sel),
-			  "destroy", 
+			  "destroy",
 			  G_CALLBACK (open_file_destroy_cb),
 			  data);
 
diff --git a/src/fr-window.c b/src/fr-window.c
index 08cc221..168bec0 100644
--- a/src/fr-window.c
+++ b/src/fr-window.c
@@ -6253,31 +6253,39 @@ fr_window_archive_rename (FrWindow   *window,
 
 void
 fr_window_archive_add_files (FrWindow *window,
-			     GList    *file_list,
+			     GList    *file_list, /* GFile list */
 			     gboolean  update)
 {
-	GList *files = NULL;
-	GList *scan;
+	GFile *base;
 	char  *base_dir;
 	int    base_len;
+	GList *files = NULL;
+	GList *scan;
+	char  *base_uri;
 
-	base_dir = remove_level_from_path (file_list->data);
-
+	base = g_file_get_parent ((GFile *) file_list->data);
+	base_dir = g_file_get_path (base);
 	base_len = 0;
 	if (strcmp (base_dir, "/") != 0)
 		base_len = strlen (base_dir);
 
 	for (scan = file_list; scan; scan = scan->next) {
-		char *path = scan->data;
-		char *rel_path;
+		GFile *file = scan->data;
+		char  *path;
+		char  *rel_path;
 
+		path = g_file_get_path (file);
 		rel_path = g_strdup (path + base_len + 1);
 		files = g_list_prepend (files, rel_path);
+
+		g_free (path);
 	}
 
+	base_uri = g_file_get_uri (base);
+
 	fr_archive_add_files (window->archive,
 			      files,
-			      base_dir,
+			      base_uri,
 			      fr_window_get_current_location (window),
 			      update,
 			      window->priv->password,
@@ -6285,8 +6293,10 @@ fr_window_archive_add_files (FrWindow *window,
 			      window->priv->compression,
 			      window->priv->volume_size);
 
+	g_free (base_uri);
 	path_list_free (files);
 	g_free (base_dir);
+	g_object_unref (base);
 }
 
 
diff --git a/src/fr-window.h b/src/fr-window.h
index 1c3b564..b136af2 100644
--- a/src/fr-window.h
+++ b/src/fr-window.h
@@ -122,7 +122,7 @@ void        fr_window_archive_reload            (FrWindow      *window);
 void        fr_window_archive_rename            (FrWindow      *window,
 						 const char    *filename);
 void        fr_window_archive_add_files         (FrWindow      *window,
-						 GList         *file_list,
+						 GList         *file_list, /* GFile list */
 						 gboolean       update);
 void        fr_window_archive_add_with_wildcard (FrWindow      *window,
 						 const char    *include_files,



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