[Nautilus-list] Can't write emblems



Here is a patch that cuts down on the amount of can't write emblems.
You only get an emblem for files that you can't write to if you can write 
to the directory the file is in. It does make the can't write emblem much 
more useful in my opinion.

I'm not sure this patch is enough, considering the async nature of 
NautilusFile. Don't i need to somehow update this when the parents 
permissions are loaded?

/ Alex

Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.258
diff -u -p -r1.258 nautilus-file.c
--- libnautilus-private/nautilus-file.c	2001/10/04 18:32:08	1.258
+++ libnautilus-private/nautilus-file.c	2001/10/05 19:26:43
@@ -1559,6 +1559,25 @@ compare_by_directory_name (NautilusFile 
 	return compare;
 }
 
+static gboolean
+nautilus_file_needs_cant_write_emblem (NautilusFile *file)
+{
+	NautilusFile *dir_file;
+
+	if (nautilus_file_can_write (file))
+		return FALSE;
+
+	dir_file = nautilus_directory_get_corresponding_file (file->details->directory);
+
+	/* If we can't write to the directory at all, no use
+	 * putting can't write emblems on every file in it.
+	 */
+	if (!nautilus_file_can_write (dir_file))
+		return FALSE;
+
+	return TRUE;
+}
+
 static int
 get_automatic_emblems_as_integer (NautilusFile *file)
 {
@@ -1570,7 +1589,7 @@ get_automatic_emblems_as_integer (Nautil
 	integer <<= 1;
 	integer |= !nautilus_file_can_read (file);
 	integer <<= 1;
-	integer |= !nautilus_file_can_write (file);
+	integer |= nautilus_file_needs_cant_write_emblem (file);
 	integer <<= 1;
 	integer |= nautilus_file_is_in_trash (file);
 
@@ -1587,7 +1606,7 @@ prepend_automatic_emblem_names (Nautilus
 		names = g_list_prepend
 			(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_TRASH));
 	}
-	if (!nautilus_file_can_write (file)) {
+	if (nautilus_file_needs_cant_write_emblem (file)) {
 		names = g_list_prepend
 			(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE));
 	}





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