[PATCH] Make file properties dialog always show deep count



I've attached a patch to bug 126068 [1] which ensures that the contents
of folders will always be displayed in the file properties dialog, but
unfortunately nobody found the time to review it yet.
I've added some remarks to the bug report and would get some feedback:

"- Removed properties window code which toggles the visibility of the
deep count
field
- Added "force" flag to nautilus_file_get_deep_counts
- - string getters pass FALSE
- - the property window passes TRUE
- - all nautilusfile_class->get_deep_counts implementations pass TRUE, since
their deep count getters are always beyond the check in
nautilus_file_get_deep_counts. I'm not sure whether the trash implementation
should be special-cased and only pass TRUE for local files, so that remote
locations in the trash still obey the pref."

I'm particularly interested in how to handle "trash:///". Federico, you
probably have some experience in that area. This patch might also
probably intersect with [2], at least for the properties dialog. What do
you think?

[1] http://bugzilla.gnome.org/show_bug.cgi?id=126068
[2] http://bugzilla.gnome.org/show_bug.cgi?id=46200

-- 
Christian Neumair <chris gnome-de org>
Index: src/file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.218
diff -u -p -r1.218 fm-properties-window.c
--- src/file-manager/fm-properties-window.c	12 Aug 2005 22:05:23 -0000	1.218
+++ src/file-manager/fm-properties-window.c	4 Sep 2005 14:24:21 -0000
@@ -104,9 +104,6 @@ struct FMPropertiesWindowDetails {	
 	guint update_directory_contents_timeout_id;
 	guint update_files_timeout_id;
 
-	GList *directory_contents_widgets;
-	int directory_contents_row;
-
 	GList *special_flags_widgets;
 	int first_special_flags_row;
 	int num_special_flags_rows;
@@ -1870,7 +1867,8 @@ directory_contents_value_field_update (F
 					 &directory_count,
 					 &file_count, 
 					 &file_unreadable,
-					 &file_size);
+					 &file_size,
+					 TRUE);
 			total_count += (file_count + directory_count);
 			total_size += file_size;
 			
@@ -2001,7 +1999,6 @@ attach_directory_contents_value_field (F
 	/* Fill in the initial value. */
 	directory_contents_value_field_update (window);
  
-	       
 	for (l = window->details->target_files; l; l = l->next) {
 		file = NAUTILUS_FILE (l->data);
 		nautilus_file_recompute_deep_counts (file);
@@ -2100,44 +2097,6 @@ update_visibility_of_table_rows (GtkTabl
 	}
 }				   
 
-static void
-update_visibility_of_item_count_fields (FMPropertiesWindow *window)
-{
-	gboolean should_show_count;
-	GList *l;
-	guint count = 0;
-	NautilusFile *file;
-               
-	for (l = window->details->target_files; l; l = l->next) {
-		file = NAUTILUS_FILE (l->data);
-		count += nautilus_file_should_show_directory_item_count (file);
-	}
-	should_show_count = count;
-
-	update_visibility_of_table_rows
-		(window->details->basic_table,
-		 should_show_count,
-		 window->details->directory_contents_row,
-		 1,
-		 window->details->directory_contents_widgets);
-}
-
-static void
-update_visibility_of_item_count_fields_wrapper (gpointer callback_data)
-{
-	update_visibility_of_item_count_fields (FM_PROPERTIES_WINDOW (callback_data));
-}  
-
-static void
-remember_directory_contents_widget (FMPropertiesWindow *window, GtkWidget *widget)
-{
-	g_assert (FM_IS_PROPERTIES_WINDOW (window));
-	g_assert (GTK_IS_WIDGET (widget));
-	
-	window->details->directory_contents_widgets = 
-		g_list_prepend (window->details->directory_contents_widgets, widget);
-}
-
 static guint
 append_directory_contents_fields (FMPropertiesWindow *window,
 				  GtkTable *table)
@@ -2154,17 +2113,6 @@ append_directory_contents_fields (FMProp
 	value_field = attach_directory_contents_value_field 
 		(window, table, last_row);
 
-	remember_directory_contents_widget (window, GTK_WIDGET (title_field));
-	remember_directory_contents_widget (window, GTK_WIDGET (value_field));
-	window->details->directory_contents_row = last_row;
-
-	update_visibility_of_item_count_fields (window);
-	eel_preferences_add_callback_while_alive 
-		(NAUTILUS_PREFERENCES_SHOW_DIRECTORY_ITEM_COUNTS,
-		 update_visibility_of_item_count_fields_wrapper,
-		 window,
-		 G_OBJECT (window));
-	
 	return last_row;
 }
 
@@ -3746,9 +3694,6 @@ real_destroy (GtkObject *object)
 	window->details->changed_files = NULL;
  
 	window->details->name_field = NULL;
-	
-	g_list_free (window->details->directory_contents_widgets);
-	window->details->directory_contents_widgets = NULL;
 
 	g_list_free (window->details->special_flags_widgets);
 	window->details->special_flags_widgets = NULL;
Index: libnautilus-private/nautilus-desktop-directory-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-directory-file.c,v
retrieving revision 1.1
diff -u -p -r1.1 nautilus-desktop-directory-file.c
--- libnautilus-private/nautilus-desktop-directory-file.c	15 May 2003 17:18:42 -0000	1.1
+++ libnautilus-private/nautilus-desktop-directory-file.c	4 Sep 2005 14:24:21 -0000
@@ -413,7 +413,8 @@ desktop_directory_file_get_deep_counts (
 						directory_count,
 						file_count,
 						unreadable_directory_count,
-						total_size);
+						total_size,
+						TRUE);
 
 	if (file_count) {
 		*file_count += g_list_length (file->details->directory->details->file_list);
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.370
diff -u -p -r1.370 nautilus-file.c
--- libnautilus-private/nautilus-file.c	22 Aug 2005 21:17:58 -0000	1.370
+++ libnautilus-private/nautilus-file.c	4 Sep 2005 14:24:24 -0000
@@ -3289,6 +3289,9 @@ nautilus_file_get_directory_item_count (
  * @unreadable_directory_count: Number of directories encountered
  * that were unreadable.
  * @total_size: Total size of all files and directories visited.
+ * @force: Whether the deep counts should even be collected if
+ * nautilus_file_should_show_directory_item_count returns FALSE
+ * for this file.
  * 
  * Returns: Status to indicate whether sizes are available.
  * 
@@ -3298,7 +3301,8 @@ nautilus_file_get_deep_counts (NautilusF
 			       guint *directory_count,
 			       guint *file_count,
 			       guint *unreadable_directory_count,
-			       GnomeVFSFileSize *total_size)
+			       GnomeVFSFileSize *total_size,
+			       gboolean force)
 {
 	if (directory_count != NULL) {
 		*directory_count = 0;
@@ -3315,7 +3319,7 @@ nautilus_file_get_deep_counts (NautilusF
 
 	g_return_val_if_fail (NAUTILUS_IS_FILE (file), NAUTILUS_REQUEST_DONE);
 
-	if (!nautilus_file_should_show_directory_item_count (file)) {
+	if (!force && !nautilus_file_should_show_directory_item_count (file)) {
 		/* Set field so an existing value isn't treated as up-to-date
 		 * when preference changes later.
 		 */
@@ -4361,7 +4365,7 @@ nautilus_file_get_deep_count_as_string_i
 	g_return_val_if_fail (nautilus_file_is_directory (file), NULL);
 
 	status = nautilus_file_get_deep_counts 
-		(file, &directory_count, &file_count, &unreadable_count, &total_size);
+		(file, &directory_count, &file_count, &unreadable_count, &total_size, FALSE);
 
 	/* Check whether any info is available. */
 	if (status == NAUTILUS_REQUEST_NOT_STARTED) {
@@ -4625,7 +4629,7 @@ nautilus_file_get_string_attribute_with_
 		return g_strdup (count_unreadable ? _("? items") : "...");
 	}
 	if (strcmp (attribute_name, "deep_size") == 0) {
-		status = nautilus_file_get_deep_counts (file, NULL, NULL, NULL, NULL);
+		status = nautilus_file_get_deep_counts (file, NULL, NULL, NULL, NULL, FALSE);
 		if (status == NAUTILUS_REQUEST_DONE) {
 			/* This means no contents at all were readable */
 			return g_strdup (_("? bytes"));
@@ -4635,7 +4639,7 @@ nautilus_file_get_string_attribute_with_
 	if (strcmp (attribute_name, "deep_file_count") == 0
 	    || strcmp (attribute_name, "deep_directory_count") == 0
 	    || strcmp (attribute_name, "deep_total_count") == 0) {
-		status = nautilus_file_get_deep_counts (file, NULL, NULL, NULL, NULL);
+		status = nautilus_file_get_deep_counts (file, NULL, NULL, NULL, NULL, FALSE);
 		if (status == NAUTILUS_REQUEST_DONE) {
 			/* This means no contents at all were readable */
 			return g_strdup (_("? items"));
Index: libnautilus-private/nautilus-file.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.h,v
retrieving revision 1.106
diff -u -p -r1.106 nautilus-file.h
--- libnautilus-private/nautilus-file.h	22 Aug 2005 21:17:58 -0000	1.106
+++ libnautilus-private/nautilus-file.h	4 Sep 2005 14:24:24 -0000
@@ -164,7 +164,8 @@ NautilusRequestStatus   nautilus_file_ge
 									 guint                          *directory_count,
 									 guint                          *file_count,
 									 guint                          *unreadable_directory_count,
-									 GnomeVFSFileSize               *total_size);
+									 GnomeVFSFileSize               *total_size,
+									 gboolean                        force);
 gboolean                nautilus_file_should_show_directory_item_count  (NautilusFile                   *file);
 GList *                 nautilus_file_get_keywords                      (NautilusFile                   *file);
 void                    nautilus_file_set_keywords                      (NautilusFile                   *file,
Index: libnautilus-private/nautilus-trash-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-trash-file.c,v
retrieving revision 1.22
diff -u -p -r1.22 nautilus-trash-file.c
--- libnautilus-private/nautilus-trash-file.c	2 Apr 2003 11:51:00 -0000	1.22
+++ libnautilus-private/nautilus-trash-file.c	4 Sep 2005 14:24:31 -0000
@@ -624,7 +624,8 @@ trash_file_get_deep_counts (NautilusFile
 			 &one_directory_count,
 			 &one_file_count,
 			 &one_unreadable_directory_count,
-			 &one_total_size);
+			 &one_total_size,
+			 TRUE);
 		
 		if (one_status < status) {
 			status = one_status;

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]