[gthumb] Purged last gnomevfs code from gth-browser-actions-callbacks.c



commit 6f19593cca6738d46322dda3c036d530ab8196c0
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Thu May 14 08:45:13 2009 -0400

    Purged last gnomevfs code from gth-browser-actions-callbacks.c
    
    Also, added optional error argument to file_move, file_copy for
    better error reporting.
---
 libgthumb/comments.c                |    4 +-
 libgthumb/file-utils.c              |   15 ++++---
 libgthumb/file-utils.h              |    6 ++-
 libgthumb/gfile-utils.c             |   41 +++++++++---------
 libgthumb/gfile-utils.h             |   10 +++--
 libgthumb/pixbuf-utils.c            |    2 +-
 libgthumb/thumb-cache.c             |    4 +-
 src/catalog-web-exporter.c          |    2 +-
 src/dlg-catalog.c                   |    2 +-
 src/dlg-file-utils.c                |    2 +-
 src/dlg-photo-importer.c            |    2 +-
 src/gth-browser-actions-callbacks.c |   78 +++++++++++-----------------------
 src/main.c                          |    2 +-
 src/rotation-utils.c                |    2 +-
 14 files changed, 75 insertions(+), 97 deletions(-)

diff --git a/libgthumb/comments.c b/libgthumb/comments.c
index 3f9fe94..3c2e21e 100644
--- a/libgthumb/comments.c
+++ b/libgthumb/comments.c
@@ -233,7 +233,7 @@ comment_copy (const char *src,
 	if (path_is_file (comment_dest))
 		file_unlink (comment_dest);
 
-	file_copy (comment_src, comment_dest);
+	file_copy (comment_src, comment_dest, NULL);
 
 	g_free (comment_src);
 	g_free (comment_dest);
@@ -257,7 +257,7 @@ comment_move (const char *src,
 	if (path_is_file (comment_dest))
 		file_unlink (comment_dest);
 
-	file_move (comment_src, comment_dest);
+	file_move (comment_src, comment_dest, NULL);
 
 	g_free (comment_src);
 	g_free (comment_dest);
diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 175b592..051ad35 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -572,7 +572,8 @@ file_is_hidden (const gchar *name)
 static gboolean
 xfer_file (const char *from,
 	   const char *to,
-	   gboolean    move)
+	   gboolean    move,
+	   GError    **error)
 {
 	GFile      *sfile;
 	GFile      *dfile;
@@ -581,7 +582,7 @@ xfer_file (const char *from,
 	sfile = gfile_new (from);
 	dfile = gfile_new (to);
 	
-	result = gfile_xfer (sfile, dfile, move);
+	result = gfile_xfer (sfile, dfile, move, error);
 
 	g_object_unref (sfile);
 	g_object_unref (dfile);
@@ -592,17 +593,19 @@ xfer_file (const char *from,
 
 gboolean
 file_copy (const char *from,
-	   const char *to)
+	   const char *to,
+	   GError    **error)
 {
-	return xfer_file (from, to, FALSE);
+	return xfer_file (from, to, FALSE, error);
 }
 
 
 gboolean
 file_move (const char *from,
-	   const char *to)
+	   const char *to,
+	   GError    **error)
 {
-	return xfer_file (from, to, TRUE);
+	return xfer_file (from, to, TRUE, error);
 }
 
 
diff --git a/libgthumb/file-utils.h b/libgthumb/file-utils.h
index a0dd1ce..5bf31c4 100644
--- a/libgthumb/file-utils.h
+++ b/libgthumb/file-utils.h
@@ -116,9 +116,11 @@ gboolean            file_is_image_video_or_audio  (const gchar      *name,
                                                    gboolean          fast_file_type);
 gboolean            file_is_hidden                (const char       *name);
 gboolean            file_copy                     (const char       *from,
-						   const char       *to);
+						   const char       *to,
+						   GError	   **error);
 gboolean            file_move                     (const char       *from,
-						   const char       *to);
+						   const char       *to,
+						   GError	   **error);
 void                file_unlink_with_gerror       (const char  *full_path,
                                                    GError     **gerror);
 gboolean            file_unlink                   (const char       *path);
diff --git a/libgthumb/gfile-utils.c b/libgthumb/gfile-utils.c
index 8c0b4ef..3b870f5 100644
--- a/libgthumb/gfile-utils.c
+++ b/libgthumb/gfile-utils.c
@@ -762,37 +762,34 @@ static void _empty_file_progress_cb  (goffset current_num_bytes,
 gboolean
 gfile_xfer (GFile    *sfile,
             GFile    *dfile,
-            gboolean  move)
+            gboolean  move,
+	    GError  **error)
 {
-        GError *error = NULL;
+	GError *priv_error = NULL;
 
-        if (g_file_equal (sfile, dfile)) {
-                gfile_warning ("cannot copy file: source and destination are the same",
-                               sfile,
-                               NULL);
-                return FALSE;
-        }
+        if (error == NULL)
+                error = &priv_error;
 
         if (move)
                 g_file_move (sfile, dfile,
 #if GLIB_CHECK_VERSION(2,19,0)
 			     G_FILE_COPY_TARGET_DEFAULT_PERMS |
 #endif 
-                             G_FILE_COPY_OVERWRITE,
+                             G_FILE_COPY_NONE,
                              NULL, _empty_file_progress_cb,
-                             NULL, &error);
+                             NULL, error);
         else
                 g_file_copy (sfile, dfile,
 #if GLIB_CHECK_VERSION(2,19,0)
                              G_FILE_COPY_TARGET_DEFAULT_PERMS |
 #endif 
-                             G_FILE_COPY_OVERWRITE,
+                             G_FILE_COPY_NONE,
                              NULL, _empty_file_progress_cb,
-                             NULL, &error);
+                             NULL, error);
 
-        if (error != NULL) {
-                gfile_warning ("error during file copy", sfile, error);
-                g_error_free (error);
+        if (priv_error != NULL) {
+                gfile_warning ("File move or copy failed", sfile, *error);
+                g_clear_error (&priv_error);
                 return FALSE;
         }
 
@@ -801,17 +798,19 @@ gfile_xfer (GFile    *sfile,
 
 
 gboolean
-gfile_copy (GFile *sfile,
-            GFile *dfile)
+gfile_copy (GFile   *sfile,
+            GFile   *dfile,
+	    GError **error)
 {
-        return gfile_xfer (sfile, dfile, FALSE);
+        return gfile_xfer (sfile, dfile, FALSE, error);
 }
 
 gboolean
-gfile_move (GFile *sfile,
-            GFile *dfile)
+gfile_move (GFile   *sfile,
+            GFile   *dfile,
+	    GError **error)
 {
-        return gfile_xfer (sfile, dfile, TRUE);
+        return gfile_xfer (sfile, dfile, TRUE, error);
 }
 
 
diff --git a/libgthumb/gfile-utils.h b/libgthumb/gfile-utils.h
index 4d194c9..4991998 100644
--- a/libgthumb/gfile-utils.h
+++ b/libgthumb/gfile-utils.h
@@ -91,12 +91,14 @@ gboolean      gfile_path_list_new              (GFile      *gfile,
 
 gboolean      gfile_xfer                       (GFile      *sfile,
 		                                GFile      *dfile,
-		                                gboolean    move);
+		                                gboolean    move,
+						GError    **error);
 gboolean      gfile_copy                       (GFile      *sfile,
-		                                GFile      *dfile);
+		                                GFile      *dfile,
+						GError    **error);
 gboolean      gfile_move                       (GFile      *sfile,
-		                                GFile      *dfile);
-
+		                                GFile      *dfile,
+						GError    **error);
 /* line-based read/write */
 gssize        gfile_output_stream_write_line   (GFileOutputStream *ostream,
                                 		GError           **error,
diff --git a/libgthumb/pixbuf-utils.c b/libgthumb/pixbuf-utils.c
index 5a4b553..8603c8c 100644
--- a/libgthumb/pixbuf-utils.c
+++ b/libgthumb/pixbuf-utils.c
@@ -1229,7 +1229,7 @@ _gdk_pixbuf_savev (GdkPixbuf    *pixbuf,
 				ext = get_filename_extension (original_local_file);
 				temp_backup = get_temp_file_name (temp_dir, ext);
 				g_free (ext);
-				file_copy (original_local_file, temp_backup);
+				file_copy (original_local_file, temp_backup, NULL);
 			}
 		}
 	}
diff --git a/libgthumb/thumb-cache.c b/libgthumb/thumb-cache.c
index b3a351b..a35e012 100644
--- a/libgthumb/thumb-cache.c
+++ b/libgthumb/thumb-cache.c
@@ -104,7 +104,7 @@ cache_copy (const char *src,
 
 		if (path_is_file (cache_dest))
 			file_unlink (cache_dest);
-		if (file_copy (cache_src, cache_dest))
+		if (file_copy (cache_src, cache_dest, NULL))
 			set_file_mtime (cache_dest, dest_mtime);
 
 		g_free (cache_dest);
@@ -127,7 +127,7 @@ cache_move (const char *src,
 
 		if (path_is_file (cache_dest))
 			file_unlink (cache_dest);
-		if (file_move (cache_src, cache_dest))
+		if (file_move (cache_src, cache_dest, NULL))
 			set_file_mtime (cache_dest, dest_mtime);
 
 		g_free (cache_dest);
diff --git a/src/catalog-web-exporter.c b/src/catalog-web-exporter.c
index 089ca00..22c001a 100644
--- a/src/catalog-web-exporter.c
+++ b/src/catalog-web-exporter.c
@@ -2707,7 +2707,7 @@ export__copy_image (CatalogWebExporter *ce)
 			        idata, 
 			        ce->target_tmp_dir);
 		
-	copy_done = gfile_copy (sfile, dfile);
+	copy_done = gfile_copy (sfile, dfile, NULL);
 
 	if (copy_done) {
 		if (gfile_image_is_jpeg (dfile)) {
diff --git a/src/dlg-catalog.c b/src/dlg-catalog.c
index 42aea2a..7984c0f 100644
--- a/src/dlg-catalog.c
+++ b/src/dlg-catalog.c
@@ -417,7 +417,7 @@ move_to_catalog_dir__ok_cb (GtkWidget  *widget,
 				file_name_from_path (data->data.catalog_path),
 				NULL);
 
-	file_move (data->data.catalog_path, new_path);
+	file_move (data->data.catalog_path, new_path, NULL);
 
 	g_free (new_path);
 	g_free (new_dir);
diff --git a/src/dlg-file-utils.c b/src/dlg-file-utils.c
index 16b7ad6..ff2b840 100644
--- a/src/dlg-file-utils.c
+++ b/src/dlg-file-utils.c
@@ -1022,7 +1022,7 @@ dlg_file_rename_series (GthWindow *window,
 			continue;
 		}
 
-		result = file_move (old_full_path, new_full_path);
+		result = file_move (old_full_path, new_full_path, NULL);
 		if (result) {
 			cache_move (old_full_path, new_full_path);
 			comment_move (old_full_path, new_full_path);
diff --git a/src/dlg-photo-importer.c b/src/dlg-photo-importer.c
index b62d8d5..40259ee 100644
--- a/src/dlg-photo-importer.c
+++ b/src/dlg-photo-importer.c
@@ -1351,7 +1351,7 @@ save_image (DialogData *data,
 			/* Create the subfolder if necessary, and move the 
 			   temporary file to it */
 			if (ensure_dir_exists (dest_folder) ) {
-				if (!file_move (initial_dest_path, final_dest_path)) {
+				if (!file_move (initial_dest_path, final_dest_path, NULL)) {
 					error_found = TRUE;
 				}
 			} else {
diff --git a/src/gth-browser-actions-callbacks.c b/src/gth-browser-actions-callbacks.c
index 97fc499..59bb7dc 100644
--- a/src/gth-browser-actions-callbacks.c
+++ b/src/gth-browser-actions-callbacks.c
@@ -24,8 +24,6 @@
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <libgnomevfs/gnome-vfs-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
 
 #include "catalog.h"
 #include "comments.h"
@@ -254,7 +252,7 @@ duplicate_file (GtkWindow  *window,
 	g_free (dir);
 	g_free (old_name_no_ext);
 
-	if (file_copy (old_path, new_path)) {
+	if (file_copy (old_path, new_path, NULL)) {
 		cache_copy (old_path, new_path);
 		comment_copy (old_path, new_path);
 	} 
@@ -500,7 +498,7 @@ catalog_rename (GthBrowser *browser,
 		_gtk_error_dialog_run (GTK_WINDOW (browser),
 				       _("The name \"%s\" is already used. " "Please use a different name."), new_fd->utf8_name);
 	} 
-	else if (file_move (old_fd->path,new_fd->path)) {
+	else if (file_move (old_fd->path,new_fd->path, NULL)) {
 		all_windows_notify_catalog_rename (old_fd->path,new_fd->path);
 	} 
 	else {
@@ -973,21 +971,11 @@ folder_rename (GtkWindow  *window,
 				       new_fd->utf8_name);
 	} 
 	else {
-		char           *old_folder_comment;
 		gboolean        result;
 
-		old_folder_comment = comments_get_comment_filename (old_path, TRUE);
-
-		result = file_move (old_fd->path, new_fd->utf8_path);
+		result = file_move (old_fd->path, new_fd->utf8_path, NULL);
 		if (result) {
-			char *new_folder_comment;
-
-			/* Comment cache. */
-
-			new_folder_comment = comments_get_comment_filename (new_fd->utf8_path, TRUE);
-			file_move (old_folder_comment, new_folder_comment);
-			g_free (new_folder_comment);
-
+			comment_move (old_path, new_path);
 			all_windows_notify_directory_rename (old_fd->path, new_fd->path);
 		} 
 		else {
@@ -995,8 +983,6 @@ folder_rename (GtkWindow  *window,
 					       _("Could not rename the folder \"%s\""),
 					       old_fd->utf8_name);
 		}
-
-		g_free (old_folder_comment);
 	}
 
 	all_windows_add_monitor ();
@@ -1196,9 +1182,10 @@ folder_copy__response_cb (GObject *object,
 	char         *dest_dir;
 	char         *new_path;
 	const char   *dir_name;
-	gboolean      same_fs;
 	gboolean      move;
 	const char   *message;
+	FileData     *old_fd;
+	FileData     *new_fd;
 
 	if (response_id != GTK_RESPONSE_OK) {
 		gtk_widget_destroy (file_sel);
@@ -1223,45 +1210,30 @@ folder_copy__response_cb (GObject *object,
 	dir_name = file_name_from_path (old_path);
 	new_path = build_uri (dest_dir, dir_name, NULL);
 
-	if (gnome_vfs_check_same_fs (old_path, dest_dir, &same_fs) != GNOME_VFS_OK)
-		same_fs = FALSE;
+	old_fd = file_data_new (old_path);
+	new_fd = file_data_new (new_path);
 
 	message = move ? _("Could not move the folder \"%s\": %s") : _("Could not copy the folder \"%s\": %s");
 
-	if (same_uri (old_path, new_path)) {
-		char *utf8_path;
-
-		utf8_path = get_utf8_display_name_from_uri (old_path);
-
+	if (same_uri (old_fd->utf8_path, new_fd->utf8_path)) {
 		_gtk_error_dialog_run (GTK_WINDOW (window),
 				       message,
-				       utf8_path,
+				       old_fd->utf8_name,
 				       _("source and destination are the same"));
-		g_free (utf8_path);
 	} 
-	else if (path_in_path (old_path, new_path)) {
-		char *utf8_path;
-
-		utf8_path = get_utf8_display_name_from_uri (old_path);
-
+	else if (path_in_path (old_fd->utf8_path, new_fd->utf8_path)) {
 		_gtk_error_dialog_run (GTK_WINDOW (window),
 				       message,
-				       utf8_path,
+				       old_fd->utf8_name,
 				       _("source contains destination"));
-		g_free (utf8_path);
 	} 
 	else if (path_is_dir (new_path)) {
-		char *utf8_name;
-
-		utf8_name = get_utf8_display_name_from_uri (dir_name);
-
 		_gtk_error_dialog_run (GTK_WINDOW (window),
 				       message,
-				       utf8_name,
+				       new_fd->utf8_name,
 				       _("a folder with that name is already present."));
-		g_free (utf8_name);
 	} 
-	else if (! (move && same_fs)) {
+	else if (!move) {
 		g_object_set_data_full (G_OBJECT (file_sel),
 					"new_path",
 					g_strdup (new_path),
@@ -1277,22 +1249,22 @@ folder_copy__response_cb (GObject *object,
 		file_sel = NULL;
 	} 
 	else {
-		char           *old_folder_comment = NULL;
-		gboolean        result;
+		char   *old_folder_comment = NULL;
+		GError *error = NULL;
 
 		/* Comment cache. */
 
 		old_folder_comment = comments_get_comment_filename (old_path, TRUE);
 
-		result = file_move (old_path, new_path);
-		if (result) {
+		file_move (old_fd->utf8_path, new_fd->utf8_path, &error);
+		if (!error) {
 			char *new_folder_comment;
 
 			/* moving folders on the same file system can be
 			 * implemeted with rename, which is faster. */
 
 			new_folder_comment = comments_get_comment_filename (new_path, TRUE);
-			file_move (old_folder_comment, new_folder_comment);
+			file_move (old_folder_comment, new_folder_comment, NULL);
 			g_free (new_folder_comment);
 
 			all_windows_notify_directory_rename (old_path, new_path);
@@ -1301,14 +1273,11 @@ folder_copy__response_cb (GObject *object,
 				gth_browser_go_to_directory (GTH_BROWSER (window), new_path);
 		} 
 		else {
-			char *utf8_path;
-
-			utf8_path = get_utf8_display_name_from_uri (old_path);
 			_gtk_error_dialog_run (GTK_WINDOW (window),
 					       message,
-					       utf8_path,
-					       gnome_vfs_result_to_string (result));
-			g_free (utf8_path);
+					       old_fd->utf8_name,
+					       error->message);
+			g_error_free (error);
 		}
 
 		g_free (old_folder_comment);
@@ -1316,6 +1285,9 @@ folder_copy__response_cb (GObject *object,
 
 	g_free (dest_dir);
 	g_free (new_path);
+	file_data_unref (old_fd);
+	file_data_unref (new_fd);
+
 	if (file_sel != NULL)
 		gtk_widget_destroy (file_sel);
 }
diff --git a/src/main.c b/src/main.c
index 5210013..b7a1568 100644
--- a/src/main.c
+++ b/src/main.c
@@ -189,7 +189,7 @@ convert_old_comment (char     *real_file,
 	comment_dir = remove_level_from_path (comment_file);
 	ensure_dir_exists (comment_dir);
 
-	file_copy (rc_file, comment_file);
+	file_copy (rc_file, comment_file, NULL);
 
 	g_free (comment_dir);
 	g_free (comment_file);
diff --git a/src/rotation-utils.c b/src/rotation-utils.c
index 9c50246..cce9679 100644
--- a/src/rotation-utils.c
+++ b/src/rotation-utils.c
@@ -203,7 +203,7 @@ apply_transformation_jpeg (FileData       *file,
 		goto apply_transformation_jpeg__free_and_close;
 	}
 
-	if (! file_move (tmp_output_file, file->local_path)) {
+	if (! file_move (tmp_output_file, file->local_path, NULL)) {
 		if (error != NULL)
 			*error = g_error_new (GTHUMB_ERROR, 0, "%s", _("Could not move temporary file to local destination. Check folder permissions."));
 		result = FALSE;



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