[PATCH] Shrink properties dialog for computer/trash



There are many fields in the properties window which are not relevant
for the trash and the computer.
The attached patch takes care that these are not shown. Note that it
introduces two new strings, "%u item, with size %s" and "%u item, with
size %s".

-- 
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.217
diff -u -p -r1.217 fm-properties-window.c
--- src/file-manager/fm-properties-window.c	11 Jul 2005 10:07:53 -0000	1.217
+++ src/file-manager/fm-properties-window.c	30 Jul 2005 10:58:59 -0000
@@ -214,6 +214,8 @@ static GtkLabel *attach_ellipsizing_valu
 						   int row,
 						   int column,
 						   const char *initial_text);
+static gboolean is_trash                          (NautilusFile *file);
+static gboolean is_computer                       (NautilusFile *file);
 
 GNOME_CLASS_BOILERPLATE (FMPropertiesWindow, fm_properties_window,
 			 GtkWindow, GTK_TYPE_WINDOW);
@@ -1836,6 +1838,17 @@ append_separator (GtkTable *table)
 	return separator;				   
 }
 
+static gboolean
+should_show_file_size (FMPropertiesWindow *window) 
+{
+	if (!is_multi_file_window (window) 
+	    && is_computer (get_target_file (window))) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
 static void
 directory_contents_value_field_update (FMPropertiesWindow *window)
 {
@@ -1910,13 +1923,21 @@ directory_contents_value_field_update (F
 			text = g_strdup ("...");
 		}
 	} else {
-		char *size_str;
-		size_str = gnome_vfs_format_file_size_for_display (total_size);
-		text = g_strdup_printf (ngettext("%d item, with size %s",
-						 "%d items, totalling %s",
-						 total_count),
-					total_count, size_str);
-		g_free (size_str);
+		if (should_show_file_size (window)) {
+			char *size_str;
+
+			size_str = gnome_vfs_format_file_size_for_display (total_size);
+			text = g_strdup_printf (ngettext("%u item, with size %s",
+							 "%u items, totalling %s",
+							 total_count),
+						total_count, size_str);
+			g_free (size_str);
+		} else {
+			text = g_strdup_printf (ngettext ("%u item",
+							  "%u items",
+							  total_count),
+						total_count);
+		}
 
 		if (unreadable_directory_count != 0) {
 			temp = text;
@@ -2225,16 +2246,29 @@ create_page_with_table_in_vbox (GtkNoteb
 }		
 
 static gboolean
-is_merged_trash_directory (NautilusFile *file) 
+is_computer (NautilusFile *file)
+{
+	char *uri;
+	gboolean ret;
+
+	uri = nautilus_file_get_uri (file);
+	ret = (strcmp (uri, "computer:///") == 0);
+	g_free (uri);
+
+	return ret;
+}
+
+static gboolean
+is_trash (NautilusFile *file)
 {
-	char *file_uri;
-	gboolean result;
+	char *uri;
+	gboolean ret;
 
-	file_uri = nautilus_file_get_uri (file);
-	result = gnome_vfs_uris_match (file_uri, EEL_TRASH_URI);
-	g_free (file_uri);
+	uri = nautilus_file_get_uri (file);
+	ret = eel_uri_is_trash (uri);
+	g_free (uri);
 
-	return result;
+	return ret;
 }
 
 static gboolean
@@ -2246,7 +2280,7 @@ should_show_custom_icon_buttons (FMPrope
 	 * When bug 5642 is fixed we can remove this case.
 	 */
 	if (!is_multi_file_window (window) 
-	    && is_merged_trash_directory (get_target_file (window))) {
+	    && is_trash (get_target_file (window))) {
 		return FALSE;
 	}
 
@@ -2258,7 +2292,8 @@ should_show_file_type (FMPropertiesWindo
 {
 	/* The trash on the desktop is one-of-a-kind */
 	if (!is_multi_file_window (window) 
-	    && is_merged_trash_directory (get_target_file (window))) {
+	    && (is_trash (get_target_file (window))
+		|| is_computer (get_target_file (window)))) {
 		return FALSE;
 	}
 
@@ -2267,6 +2302,17 @@ should_show_file_type (FMPropertiesWindo
 }
 
 static gboolean
+should_show_modified_date (FMPropertiesWindow *window) 
+{
+	if (!is_multi_file_window (window)
+	    && is_computer (get_target_file (window))) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
 should_show_accessed_date (FMPropertiesWindow *window) 
 {
 	/* Accessed date for directory seems useless. If we some
@@ -2302,10 +2348,37 @@ should_show_link_target (FMPropertiesWin
 }
 
 static gboolean
+should_show_location (FMPropertiesWindow *window)
+{
+	if (!is_multi_file_window (window)
+	    && (is_trash (get_target_file (window))
+		|| is_computer (get_target_file (window)))) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
+should_show_volume (FMPropertiesWindow *window)
+{
+	if (!is_multi_file_window (window)
+	    && (is_trash (get_target_file (window))
+		|| is_computer (get_target_file (window)))) {
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static gboolean
 should_show_free_space (FMPropertiesWindow *window)
 {
 	if (file_list_all_local (window->details->target_files)
-	    && file_list_all_directories (window->details->target_files)) {
+	    && file_list_all_directories (window->details->target_files)
+	    && (is_multi_file_window (window) ||
+		(!is_trash (get_target_file (window) &&
+		 !is_computer (get_target_file (window)))))) {
 		return TRUE;
 	}
 
@@ -2319,6 +2392,7 @@ create_basic_page (FMPropertiesWindow *w
 	GtkWidget *container;
 	GtkWidget *icon_aligner;
 	GtkWidget *icon_pixmap_widget;
+	gboolean show_modified_date, show_accessed_date;
 
 	GtkWidget *hbox, *name_label;
 
@@ -2385,17 +2459,22 @@ create_basic_page (FMPropertiesWindow *w
 					 FALSE);
 	}
 
-	append_title_and_ellipsizing_value (window, table, _("Location:"), 
-					    "where",
-					    _("--"),
-					    TRUE);
-	
-	if (should_show_free_space (window)) {
+	if (should_show_location (window)) {
+		append_title_and_ellipsizing_value (window, table, _("Location:"), 
+						    "where",
+						    _("--"),
+						    TRUE);
+	}
+
+	if (should_show_volume (window)) {
 		append_title_and_ellipsizing_value (window, table, 
 						    _("Volume:"), 
 						    "volume",
 						    _("--"),
 						    FALSE);
+	}
+
+	if (should_show_free_space (window)) {
 		append_title_value_pair (window, table, _("Free space:"), 
 					 "free_space",
 					 _("--"),
@@ -2417,14 +2496,21 @@ create_basic_page (FMPropertiesWindow *w
 	}				  
 	
 	/* Blank title ensures standard row height */
-	append_title_field (table, "", NULL);
-	
-	append_title_value_pair (window, table, _("Modified:"), 
-				 "date_modified",
-				 _("--"),
-				 FALSE);
-	
-	if (should_show_accessed_date (window)) {
+	show_modified_date = should_show_modified_date (window);
+	show_accessed_date = should_show_accessed_date (window);
+
+	if (show_modified_date || show_accessed_date) {
+		append_title_field (table, "", NULL);
+	}
+
+	if (show_modified_date) {
+		append_title_value_pair (window, table, _("Modified:"), 
+					 "date_modified",
+					 _("--"),
+					 FALSE);
+	}
+
+	if (show_accessed_date) {
 		append_title_value_pair (window, table, _("Accessed:"), 
 					 "date_accessed",
 					 _("--"),
@@ -2435,7 +2521,9 @@ create_basic_page (FMPropertiesWindow *w
 		GtkWidget *button_box;
 		GtkWidget *temp_button;
 		GList *l;
-		
+
+		append_title_field (table, "", NULL);
+
 		/* add command buttons for setting and clearing custom icons */
 		button_box = gtk_hbox_new (FALSE, 0);
 		gtk_widget_show (button_box);
@@ -3213,7 +3301,7 @@ should_show_emblems (FMPropertiesWindow 
 	 * When bug 5643 is fixed we can remove this case.
 	 */
 	if (!is_multi_file_window (window) 
-	    && is_merged_trash_directory (get_target_file (window))) {
+	    && is_trash (get_target_file (window))) {
 		return FALSE;
 	}
 
@@ -3227,7 +3315,8 @@ should_show_permissions (FMPropertiesWin
 	 * really a file system object.
 	 */
 	if (!is_multi_file_window (window)
-	    && is_merged_trash_directory (get_target_file (window))) {
+	    && (is_trash (get_target_file (window)) ||
+		is_computer (get_target_file (window)))) {
 		return FALSE;
 	}
 
@@ -3340,7 +3429,8 @@ should_show_open_with (FMPropertiesWindo
 	file = get_original_file (window);
 	if (file == NULL ||
 	    NAUTILUS_IS_DESKTOP_ICON_FILE (file) ||
-	    nautilus_file_is_nautilus_link (file)) {
+	    nautilus_file_is_nautilus_link (file) ||
+	    is_trash (file)) {
 		return FALSE;
 	}
 	return TRUE;

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]