[PATCH] Move custom icons when copying metadata



The attached patch ensures that custom icons that have URIs inside a
folder they're used for (consider album covers) are changed upon copying
the folder that has the custom URI set. It heavily interferes with [1],
so we should probably decide what route to take. I'd propose to not
commit the huge metadata changes from [1] to the (to be created) stable
branch, but just to HEAD, and to commit the attached patch to the stable
branch and afterwards adapt it to the changes in HEAD introduced by [1].

[1]http://mail.gnome.org/archives/nautilus-list/2005-September/msg00160.html

-- 
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.42
diff -u -p -r1.42 nautilus-metafile.c
--- libnautilus-private/nautilus-metafile.c	19 Sep 2005 13:51:16 -0000	1.42
+++ libnautilus-private/nautilus-metafile.c	21 Sep 2005 21:27:07 -0000
@@ -662,6 +662,31 @@ call_metafile_changed_for_all_files_ment
 }
 #endif
 
+
+static void
+update_custom_icon_metadata_moved (xmlNodePtr destination_file_node,
+				   const char *source_file_uri,
+				   const char *destination_file_uri)
+{
+	xmlChar *property, *p;
+
+	if (destination_file_node != NULL) {
+		property = xmlGetProp (destination_file_node, NAUTILUS_METADATA_KEY_CUSTOM_ICON);
+		if (property != NULL && g_str_has_prefix (property, source_file_uri)) {
+			p = property;
+
+			property = g_strconcat (destination_file_uri,
+						property + strlen (source_file_uri),
+						NULL);
+			xmlSetProp (destination_file_node, NAUTILUS_METADATA_KEY_CUSTOM_ICON, property);
+
+			xmlFree (p);
+		}
+
+		xmlFree (property);
+	}
+}
+
 static void
 call_metafile_changed_for_one_file (NautilusMetafile *metafile,
 				    const CORBA_char  *file_name)
@@ -1291,6 +1316,8 @@ rename_file_metadata (NautilusMetafile *
 	g_return_if_fail (old_file_name != NULL);
 	g_return_if_fail (new_file_name != NULL);
 
+	file_node = NULL;
+
 	remove_file_metadata (metafile, new_file_name);
 
 	if (metafile->details->is_read) {
@@ -1329,6 +1356,7 @@ rename_file_metadata (NautilusMetafile *
 	old_file_uri = metafile_get_file_uri (metafile, old_file_name);
 	new_file_uri = metafile_get_file_uri (metafile, new_file_name);
 	nautilus_update_thumbnail_file_renamed (old_file_uri, new_file_uri);
+	update_custom_icon_metadata_moved (file_node, old_file_uri, new_file_uri);
 	g_free (old_file_uri);
 	g_free (new_file_uri);
 }
@@ -1422,6 +1450,8 @@ copy_file_metadata (NautilusMetafile *so
 	g_return_if_fail (NAUTILUS_IS_METAFILE (destination_metafile));
 	g_return_if_fail (destination_file_name != NULL);
 
+	node = NULL;
+
 	/* FIXME bugzilla.gnome.org 43343: This does not properly
 	 * handle the case where we don't have the source metadata yet
 	 * since it's not read in.
@@ -1463,6 +1493,7 @@ copy_file_metadata (NautilusMetafile *so
 	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);
+	update_custom_icon_metadata_moved (node, source_file_uri, destination_file_uri);
 	g_free (source_file_uri);
 	g_free (destination_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]