[PATCH] Copy thumbnails upon copy/move/link



The attached patch inter alia fixed bug 45191 [1].

[1] http://bugzilla.gnome.org/show_bug.cgi?id=45191

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-metafile.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-metafile.c,v
retrieving revision 1.41
diff -u -p -r1.41 nautilus-metafile.c
--- libnautilus-private/nautilus-metafile.c	12 Aug 2005 18:11:29 -0000	1.41
+++ libnautilus-private/nautilus-metafile.c	8 Sep 2005 08:10:07 -0000
@@ -1414,6 +1414,8 @@ copy_file_metadata (NautilusMetafile *so
 {
 	xmlNodePtr source_node, node, root;
 	GHashTable *hash, *changes;
+	char *source_file_uri;
+	char *destination_file_uri;
 
 	g_return_if_fail (NAUTILUS_IS_METAFILE (source_metafile));
 	g_return_if_fail (source_file_name != NULL);
@@ -1457,9 +1459,12 @@ copy_file_metadata (NautilusMetafile *so
 		}
 	}
 
-	/* FIXME: Do we want to copy the thumbnail here like in the
-	 * rename and remove cases?
-	 */
+	/* Copy the thumbnail for the file, if any. */
+	source_file_uri = metafile_get_file_uri (source_metafile, source_file_name);
+	destination_file_uri = metafile_get_file_uri (destination_metafile, destination_file_name);
+	nautilus_update_thumbnail_file_copied (source_file_uri, destination_file_uri);
+	g_free (source_file_uri);
+	g_free (destination_file_uri);
 }
 
 static void
Index: libnautilus-private/nautilus-thumbnails.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-thumbnails.c,v
retrieving revision 1.54
diff -u -p -r1.54 nautilus-thumbnails.c
--- libnautilus-private/nautilus-thumbnails.c	8 May 2005 16:14:51 -0000	1.54
+++ libnautilus-private/nautilus-thumbnails.c	8 Sep 2005 08:10:07 -0000
@@ -178,27 +178,28 @@ thumbnail_thread_starter_cb (gpointer da
 }
 
 void
-nautilus_update_thumbnail_file_renamed (const char *old_file_uri, const char *new_file_uri)
+nautilus_update_thumbnail_file_copied (const char *source_file_uri,
+				       const char *destination_file_uri)
 {
 	char *old_thumbnail_path;
 	GdkPixbuf *pixbuf;
 	GnomeVFSFileInfo *file_info;
 	GnomeThumbnailFactory *factory;
 	
-	old_thumbnail_path = gnome_thumbnail_path_for_uri (old_file_uri, GNOME_THUMBNAIL_SIZE_NORMAL);
+	old_thumbnail_path = gnome_thumbnail_path_for_uri (source_file_uri, GNOME_THUMBNAIL_SIZE_NORMAL);
 	if (old_thumbnail_path != NULL &&
 	    g_file_test (old_thumbnail_path, G_FILE_TEST_EXISTS)) {
 		file_info = gnome_vfs_file_info_new ();
-		if (gnome_vfs_get_file_info (new_file_uri,
+		if (gnome_vfs_get_file_info (destination_file_uri,
 					     file_info,
 					     GNOME_VFS_FILE_INFO_DEFAULT) == GNOME_VFS_OK) {
 			pixbuf = gdk_pixbuf_new_from_file (old_thumbnail_path, NULL);
 			
-			if (pixbuf && gnome_thumbnail_has_uri (pixbuf, old_file_uri)) {
+			if (pixbuf && gnome_thumbnail_has_uri (pixbuf, source_file_uri)) {
 				factory = nautilus_icon_factory_get_thumbnail_factory ();
 				gnome_thumbnail_factory_save_thumbnail (factory,
 									pixbuf,
-									new_file_uri,
+									destination_file_uri,
 									file_info->mtime);
 				g_object_unref (factory);
 			}
@@ -207,7 +208,6 @@ nautilus_update_thumbnail_file_renamed (
 				g_object_unref (pixbuf);
 			}
 			
-			unlink (old_thumbnail_path);
 		}
 		gnome_vfs_file_info_unref (file_info);
 	}
@@ -215,16 +215,24 @@ nautilus_update_thumbnail_file_renamed (
 	g_free (old_thumbnail_path);
 }
 
+void
+nautilus_update_thumbnail_file_renamed (const char *source_file_uri,
+					const char *destination_file_uri)
+{
+	nautilus_update_thumbnail_file_copied (source_file_uri, destination_file_uri);
+	nautilus_remove_thumbnail_for_file (source_file_uri);
+}
+
 void 
-nautilus_remove_thumbnail_for_file (const char *old_file_uri)
+nautilus_remove_thumbnail_for_file (const char *file_uri)
 {
-	char *old_thumbnail_path;
+	char *thumbnail_path;
 	
-	old_thumbnail_path = gnome_thumbnail_path_for_uri (old_file_uri, GNOME_THUMBNAIL_SIZE_NORMAL);
-	if (old_thumbnail_path != NULL) {
-		unlink (old_thumbnail_path);
+	thumbnail_path = gnome_thumbnail_path_for_uri (file_uri, GNOME_THUMBNAIL_SIZE_NORMAL);
+	if (thumbnail_path != NULL) {
+		unlink (thumbnail_path);
 	}
-	g_free (old_thumbnail_path);
+	g_free (thumbnail_path);
 }
 
 void
Index: libnautilus-private/nautilus-thumbnails.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-thumbnails.h,v
retrieving revision 1.11
diff -u -p -r1.11 nautilus-thumbnails.h
--- libnautilus-private/nautilus-thumbnails.h	15 Dec 2004 11:20:41 -0000	1.11
+++ libnautilus-private/nautilus-thumbnails.h	8 Sep 2005 08:10:07 -0000
@@ -32,9 +32,11 @@
 void       nautilus_create_thumbnail                (NautilusFile *file);
 void       nautilus_thumbnail_frame_image           (GdkPixbuf **pixbuf);
 GdkPixbuf *nautilus_thumbnail_load_framed_image     (const char   *path);
-void       nautilus_update_thumbnail_file_renamed   (const char   *old_file_uri,
-						     const char   *new_file_uri);
-void       nautilus_remove_thumbnail_for_file       (const char   *old_file_uri);
+void       nautilus_update_thumbnail_file_copied    (const char   *source_file_uri,
+						     const char   *destination_file_uri);
+void       nautilus_update_thumbnail_file_renamed   (const char   *source_file_uri,
+						     const char   *destination_file_uri);
+void       nautilus_remove_thumbnail_for_file       (const char   *file_uri);
 
 /* Queue handling: */
 void       nautilus_thumbnail_remove_from_queue     (const char   *file_uri);

Attachment: signature.asc
Description: This is a digitally signed message part



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