file-roller r2206 - in trunk: . src



Author: paobac
Date: Tue Apr  1 16:08:20 2008
New Revision: 2206
URL: http://svn.gnome.org/viewvc/file-roller?rev=2206&view=rev

Log:
2008-04-01  Paolo Bacchilega  <paobac svn gnome org>

	* src/fr-window.c: 
	* src/fr-archive.c: 
	* src/file-utils.h: 
	* src/file-utils.c: 
	* src/dlg-update.c: 
	* src/dlg-prop.c: 
	* src/dlg-extract.c: 
	* src/dlg-batch-add.c: 
	* src/dlg-ask-password.c: 
	* src/dlg-add-folder.c: 
	
	Continuing GIO port.


Modified:
   trunk/ChangeLog
   trunk/src/dlg-add-folder.c
   trunk/src/dlg-ask-password.c
   trunk/src/dlg-batch-add.c
   trunk/src/dlg-extract.c
   trunk/src/dlg-prop.c
   trunk/src/dlg-update.c
   trunk/src/file-utils.c
   trunk/src/file-utils.h
   trunk/src/fr-archive.c
   trunk/src/fr-window.c

Modified: trunk/src/dlg-add-folder.c
==============================================================================
--- trunk/src/dlg-add-folder.c	(original)
+++ trunk/src/dlg-add-folder.c	Tue Apr  1 16:08:20 2008
@@ -572,7 +572,6 @@
 		g_clear_error (&err);
 	}
 
-	gnome_vfs_file_info_list_free (list);
 	g_free (options_dir);
 }
 
@@ -584,7 +583,9 @@
 	GtkTreeSelection *selection;
 	GtkTreeIter       iter;
 	char             *file_path;
-
+	GFile            *file;
+	GError           *error;
+	
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (aod_data->aod_treeview));
 	if (! gtk_tree_selection_get_selected (selection, NULL, &iter))
 		return;
@@ -593,8 +594,13 @@
 			    1, &file_path,
 			    -1);
 	gtk_list_store_remove (GTK_LIST_STORE (aod_data->aod_model), &iter);
-
-	gnome_vfs_unlink (file_path);
+	
+	file = g_file_new_for_uri (file_path);
+	if (! g_file_delete (file, NULL, &error)) {
+		g_warning ("could not delete file %s: %s", file_path, error->message);
+		g_clear_error (&error);
+	}
+	g_object_unref (file);
 	g_free (file_path);
 }
 

Modified: trunk/src/dlg-ask-password.c
==============================================================================
--- trunk/src/dlg-ask-password.c	(original)
+++ trunk/src/dlg-ask-password.c	Tue Apr  1 16:08:20 2008
@@ -118,7 +118,7 @@
 	/* Set widgets data. */
 
 	if (data->pwd_type == FR_PASSWORD_TYPE_MAIN)
-		name = gnome_vfs_unescape_string_for_display (file_name_from_path (fr_window_get_archive_uri (window)));
+		name = g_filename_display_basename (fr_window_get_archive_uri (window));
 	else if (data->pwd_type == FR_PASSWORD_TYPE_PASTE_FROM)
 		name = g_filename_display_basename (fr_window_get_paste_archive_uri (window));
 	text = g_strdup_printf (_("Enter the password for the archive '%s'."), name);

Modified: trunk/src/dlg-batch-add.c
==============================================================================
--- trunk/src/dlg-batch-add.c	(original)
+++ trunk/src/dlg-batch-add.c	Tue Apr  1 16:08:20 2008
@@ -107,12 +107,13 @@
 	char       *tmp;
 	const char *archive_ext;
 	gboolean    do_not_add = FALSE;
+	GError     *error;
 
 	data->add_clicked = TRUE;
 
 	/* Collect data */
 
-	archive_name = gnome_vfs_escape_string (gtk_entry_get_text (GTK_ENTRY (data->a_add_to_entry)));
+	archive_name = g_uri_escape_string (gtk_entry_get_text (GTK_ENTRY (data->a_add_to_entry)), NULL, FALSE);
 
 	/* Check whether the user entered a valid archive name. */
 
@@ -204,7 +205,7 @@
 		do_not_add = (r != GTK_RESPONSE_YES);
 	}
 
-	if (! do_not_add && ! ensure_dir_exists (archive_dir, 0755)) {
+	if (! do_not_add && ! make_tree (archive_dir, &error)) {
 		GtkWidget  *d;
 
 		d = _gtk_error_dialog_new (GTK_WINDOW (window),
@@ -212,10 +213,11 @@
 					   NULL,
 					   _("Could not create the archive"),
 					   _("Could not create the destination folder: %s."),
-					   gnome_vfs_result_to_string (gnome_vfs_result_from_errno ()));
+					   error->message);
 		gtk_dialog_run (GTK_DIALOG (d));
 		gtk_widget_destroy (GTK_WIDGET (d));
 
+		g_error_free (error);
 		g_free (archive_dir);
 		g_free (archive_name);
 		return;
@@ -453,12 +455,12 @@
 	parent = remove_level_from_path (first_filename);
 
 	if (file_list->next == NULL)
-		automatic_name = gnome_vfs_unescape_string (file_name_from_path ((char*) file_list->data), "");
+		automatic_name = g_uri_unescape_string (file_name_from_path ((char*) file_list->data), NULL);
 	else {
-		automatic_name = gnome_vfs_unescape_string (file_name_from_path (parent), "");
+		automatic_name = g_uri_unescape_string (file_name_from_path (parent), NULL);
 		if ((automatic_name == NULL) || (automatic_name[0] == '\0')) {
 			g_free (automatic_name);
-			automatic_name = gnome_vfs_unescape_string (file_name_from_path (first_filename), "");
+			automatic_name = g_uri_unescape_string (file_name_from_path (first_filename), NULL);
 		}
 	}
 

Modified: trunk/src/dlg-extract.c
==============================================================================
--- trunk/src/dlg-extract.c	(original)
+++ trunk/src/dlg-extract.c	Tue Apr  1 16:08:20 2008
@@ -93,6 +93,7 @@
 	GList      *file_list;
 	char       *password;
 	char       *base_dir = NULL;
+	GError     *error;
 
 	data->extract_clicked = TRUE;
 
@@ -132,11 +133,11 @@
 				do_not_extract = TRUE;
 		}
 
-		if (! do_not_extract && ! ensure_dir_exists (extract_to_dir, 0755)) {
+		if (! do_not_extract && ! make_tree (extract_to_dir, &error)) {
 			GtkWidget  *d;
 			char       *message;
 
-			message = g_strdup_printf (_("Could not create the destination folder: %s."), gnome_vfs_result_to_string (gnome_vfs_result_from_errno ()));
+			message = g_strdup_printf (_("Could not create the destination folder: %s."), error->message);
 
 			d = _gtk_error_dialog_new (GTK_WINDOW (window),
 						   GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -147,6 +148,7 @@
 			gtk_widget_destroy (GTK_WIDGET (d));
 
 			g_free (message);
+			g_error_free (error);
 
 			return FALSE;
 		}

Modified: trunk/src/dlg-prop.c
==============================================================================
--- trunk/src/dlg-prop.c	(original)
+++ trunk/src/dlg-prop.c	Tue Apr  1 16:08:20 2008
@@ -111,9 +111,8 @@
 	set_label (label_label, _("Path:"));
 
 	label = glade_xml_get_widget (data->gui, "p_path_label");
-	/* note: window->archive_filename is unescaped. */
 	s = remove_level_from_path (fr_window_get_archive_uri (window));
-	utf8_name = gnome_vfs_format_uri_for_display (s);
+	utf8_name = g_filename_display_name (s);
 	gtk_label_set_text (GTK_LABEL (label), utf8_name);
 	g_free (utf8_name);
 	g_free (s);
@@ -124,7 +123,7 @@
 	set_label (label_label, _("Name:"));
 
 	label = glade_xml_get_widget (data->gui, "p_name_label");
-	utf8_name = gnome_vfs_unescape_string_for_display (file_name_from_path (fr_window_get_archive_uri (window)));
+	utf8_name = g_filename_display_name (file_name_from_path (fr_window_get_archive_uri (window)));
 	gtk_label_set_text (GTK_LABEL (label), utf8_name);
 
 	title_txt = g_strdup_printf (_("%s Properties"), utf8_name);

Modified: trunk/src/dlg-update.c
==============================================================================
--- trunk/src/dlg-update.c	(original)
+++ trunk/src/dlg-update.c	Tue Apr  1 16:08:20 2008
@@ -153,8 +153,8 @@
 		
 		/* primary text */
 		
-		file_name = gnome_vfs_unescape_string_for_display (file_name_from_path (file->path));
-		archive_name = gnome_vfs_unescape_string_for_display (file_name_from_path (fr_window_get_archive_uri (data->window)));
+		file_name = g_filename_display_name (file_name_from_path (file->path));
+		archive_name = g_filename_display_name (file_name_from_path (fr_window_get_archive_uri (data->window)));
 		label = g_markup_printf_escaped (_("Update the file \"%s\" in the archive \"%s\"?"), file_name, archive_name);
 		markup = g_strdup_printf ("<big><b>%s</b></big>", label);
 		gtk_label_set_markup (GTK_LABEL (data->update_file_primary_text_label), markup);
@@ -168,7 +168,7 @@
 		
 		/* primary text */
 		
-		archive_name = gnome_vfs_unescape_string_for_display (file_name_from_path (fr_window_get_archive_uri (data->window)));
+		archive_name = g_filename_display_name (file_name_from_path (fr_window_get_archive_uri (data->window)));
 		label = g_markup_printf_escaped (_("Update the files in the archive \"%s\"?"), archive_name);
 		markup = g_strdup_printf ("<big><b>%s</b></big>", label);
 		gtk_label_set_markup (GTK_LABEL (data->update_files_primary_text_label), markup);

Modified: trunk/src/file-utils.c
==============================================================================
--- trunk/src/file-utils.c	(original)
+++ trunk/src/file-utils.c	Tue Apr  1 16:08:20 2008
@@ -1008,27 +1008,16 @@
 
 
 char *
-get_uri_from_local_path (const char *local_path)
+get_uri_from_local_path (const char *path)
 {
-	char *escaped;
-	char *uri;
-
-	escaped = g_uri_escape_string (local_path, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
-	if (escaped[0] == '/') {
-		uri = g_strconcat ("file://", escaped, NULL);
-		g_free (escaped);
-	}
-	else
-		uri = escaped;
-
-	return uri;
+	return g_filename_to_uri (path, NULL, NULL);
 }
 
 
 char *
 get_local_path_from_uri (const char *uri)
 {
-	return g_uri_unescape_string (remove_host_from_uri (uri), NULL);
+	return g_filename_from_uri (uri, NULL, NULL);
 }
 
 

Modified: trunk/src/file-utils.h
==============================================================================
--- trunk/src/file-utils.h	(original)
+++ trunk/src/file-utils.h	Tue Apr  1 16:08:20 2008
@@ -74,7 +74,6 @@
 char *              get_temp_work_dir            (void);
 gboolean            is_temp_work_dir             (const char *dir);
 gboolean            is_temp_dir                  (const char *dir);
-char *              escape_uri                   (const char *uri);
 
 /* misc functions used to parse a command output lines. */
 

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Tue Apr  1 16:08:20 2008
@@ -392,7 +392,7 @@
 	if (dir == NULL)
 		return NULL;
 
-	name = gnome_vfs_unescape_string (file_name_from_path (remote_uri), "");
+	name = g_uri_unescape_string (file_name_from_path (remote_uri), NULL);
 	result = g_build_filename (dir, name, NULL);
 	
 	g_free (dir);
@@ -567,7 +567,7 @@
 {
 	const char *mime_type;
 
-	mime_type = gnome_vfs_get_file_mime_type (filename, NULL, FALSE);
+	mime_type = get_file_mime_type (filename, FALSE);
 	if (strcmp (mime_type, UNKNOWN_TYPE) == 0)
 		return NULL;
 
@@ -923,11 +923,13 @@
 static void
 move_here (FrArchive *archive) 
 {
-	char *content_uri;
-	char *parent;
-	char *parent_parent;
-	char *new_content_uri;
-	
+	char   *content_uri;
+	char   *parent;
+	char   *parent_parent;
+	char   *new_content_uri;
+	GFile  *source, *destination, *parent_file;
+	GError *error;
+
 	content_uri = get_directory_content_if_unique (archive->priv->extraction_destination);
 	if (content_uri == NULL)
 		return;	
@@ -937,9 +939,17 @@
 	if (uricmp (parent, archive->priv->extraction_destination) == 0) {
 		char *new_uri;
 		
-		new_uri = get_new_uri_from_uri (archive->priv->extraction_destination); 
-		gnome_vfs_move (archive->priv->extraction_destination, new_uri, FALSE);
-		
+		new_uri = get_new_uri_from_uri (archive->priv->extraction_destination);
+		 
+		source = g_file_new_for_uri (archive->priv->extraction_destination);
+		destination = g_file_new_for_uri (new_uri);
+		if (! g_file_move (source, destination, 0, NULL, NULL, NULL, &error)) {
+			g_warning ("could not rename %s to %s: %s", archive->priv->extraction_destination, new_uri, error->message);
+			g_clear_error (&error);
+		}
+		g_object_unref (source);
+		g_object_unref (destination);
+				
 		g_free (archive->priv->extraction_destination);
 		archive->priv->extraction_destination = new_uri;
 
@@ -955,8 +965,19 @@
 	parent_parent = remove_level_from_path (parent);
 	new_content_uri = get_new_uri (parent_parent, file_name_from_path (content_uri));
 	
-	gnome_vfs_move (content_uri, new_content_uri, FALSE);
-	gnome_vfs_remove_directory (parent);
+	source = g_file_new_for_uri (content_uri);
+	destination = g_file_new_for_uri (new_content_uri);
+	if (! g_file_move (source, destination, 0, NULL, NULL, NULL, &error)) {
+		g_warning ("could not rename %s to %s: %s", content_uri, new_content_uri, error->message);
+		g_clear_error (&error);
+	}
+	
+	parent_file = g_file_new_for_uri (parent);
+	if (! g_file_delete (parent_file, NULL, &error)) {
+		g_warning ("could not remove directory %s: %s", parent, error->message);
+		g_clear_error (&error);
+	}
+	g_object_unref (parent_file);
 	
 	g_free (archive->priv->extraction_destination);
 	archive->priv->extraction_destination = new_content_uri;
@@ -3138,8 +3159,8 @@
 
 
 static char *
-get_extract_here_destination (const char     *uri,
-			      GnomeVFSResult *result)
+get_extract_here_destination (const char *uri,
+			      GError     *error)
 {
 	char *desired_destination;
 	char *destination = NULL;
@@ -3153,9 +3174,9 @@
 			destination = g_strdup (desired_destination);
 		else
 			destination = g_strdup_printf ("%s%%20(%d)", desired_destination, n);
-		*result = gnome_vfs_make_directory (destination, 0700);
+		g_file_make_directory (destination, NULL, error);
 		n++;
-	} while (*result == GNOME_VFS_ERROR_FILE_EXISTS);
+	} while ((*error == NULL) && (*error->code == G_IO_ERROR_EXISTS));
 	
 	g_free (desired_destination);
 	
@@ -3175,15 +3196,16 @@
 			 gboolean    junk_path,
 			 const char *password)
 {
-	GnomeVFSResult  result;
-	char           *destination;
+	char   *destination;
+	GError *error;
 	
-	destination = get_extract_here_destination (archive->uri, &result);
-	if (result != GNOME_VFS_OK) {
+	destination = get_extract_here_destination (archive->uri, &error);
+	if (error != NULL) {
 		fr_archive_action_completed (archive,
 					     FR_ACTION_EXTRACTING_FILES,
 					     FR_PROC_ERROR_GENERIC,
-					     gnome_vfs_result_to_string (result));
+					     error->message);
+		g_clear_error (&error);
 		return FALSE;
 	}
 	

Modified: trunk/src/fr-window.c
==============================================================================
--- trunk/src/fr-window.c	(original)
+++ trunk/src/fr-window.c	Tue Apr  1 16:08:20 2008
@@ -1504,7 +1504,7 @@
 			utf8_path = g_filename_display_name (tmp);
 			g_free (tmp);
 
-			s_size = gnome_vfs_format_file_size_for_display (fdata->dir_size);
+			s_size = g_format_size_for_display (fdata->dir_size);
 				
 			if (fdata->list_dir) 
 				s_time = g_strdup ("");
@@ -1533,7 +1533,7 @@
 
 			utf8_path = g_filename_display_name (fdata->path);
 
-			s_size = gnome_vfs_format_file_size_for_display (fdata->size);
+			s_size = g_format_size_for_display (fdata->size);
 			s_time = get_time_string (fdata->modified);
 			desc = file_data_get_mime_type_description (fdata);
 
@@ -1731,7 +1731,7 @@
 		GtkTreeIter  node;
 		char        *name;
 		
-		name = gnome_vfs_unescape_string_for_display (file_name_from_path (window->archive->uri));
+		name = g_filename_display_basename (window->archive->uri);
 		
 		gtk_tree_store_append (window->priv->tree_store, &node, NULL);
 		gtk_tree_store_set (window->priv->tree_store, &node,
@@ -1894,7 +1894,7 @@
 		char *title;
 		char *name;
 
-		name = gnome_vfs_unescape_string_for_display (file_name_from_path (fr_window_get_archive_uri (window)));
+		name = g_filename_display_basename (fr_window_get_archive_uri (window));
 		title = g_strdup_printf ("%s %s",
 					 name,
 					 window->archive->read_only ? _("[read only]") : "");
@@ -2273,7 +2273,7 @@
 			
 			window->priv->pd_last_archive = g_strdup (window->priv->archive_uri);
 
-			name = gnome_vfs_unescape_string_for_display (file_name_from_path (window->priv->archive_uri));
+			name = g_filename_display_basename (window->priv->archive_uri);
 			gtk_label_set_text (GTK_LABEL (window->priv->pd_archive), name);
 			g_free (name);
 		}
@@ -2387,7 +2387,7 @@
 			gtk_box_pack_start (GTK_BOX (hbox), lbl, FALSE, FALSE, 0);
 
 			window->priv->pd_last_archive = g_strdup (window->priv->archive_uri);
-			name = gnome_vfs_unescape_string_for_display (file_name_from_path (window->priv->pd_last_archive));
+			name = g_filename_display_basename (window->priv->pd_last_archive);
 			lbl = window->priv->pd_archive = gtk_label_new (name);
 			g_free (name);
 
@@ -2650,7 +2650,7 @@
 
 		case FR_ACTION_LOADING_ARCHIVE:
 			dialog_parent = window->priv->load_error_parent_window;
-			unescaped_uri = gnome_vfs_format_uri_for_display (window->priv->archive_uri);
+			unescaped_uri = g_filename_display_name (window->priv->archive_uri);
 			utf8_name = g_filename_display_basename (unescaped_uri);
 			g_free (unescaped_uri);
 			msg = g_strdup_printf (_("Could not open \"%s\""), utf8_name);
@@ -5566,7 +5566,7 @@
 		char      *utf8_name;
 		char      *message;
 
-		unescaped_uri = gnome_vfs_format_uri_for_display (uri);
+		unescaped_uri = g_filename_display_name (uri);
 		utf8_name = g_filename_display_basename (unescaped_uri);
 		g_free (unescaped_uri);
 		message = g_strdup_printf (_("Could not save the archive \"%s\""), utf8_name);
@@ -6745,7 +6745,7 @@
 		g_free (e_new_path);
 	}
 
-	new_name_uri = gnome_vfs_escape_string (rdata->new_name);
+	new_name_uri = g_filename_to_uri (rdata->new_name, NULL, NULL);
 
 	for (scan = file_list; scan; scan = scan->next) {
 		const char *current_dir_relative = rdata->current_dir + 1;
@@ -7437,7 +7437,7 @@
 	GnomeVFSResult result;
 
 	for (scan = file_list; scan; scan = scan->next) {
-		char *filename = gnome_vfs_get_uri_from_local_path (scan->data);
+		char *filename = g_filename_to_uri (scan->data, NULL, NULL);
 		uris = g_list_prepend (uris, filename);
 	}
 



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