[patch] size field for multi window property dialogs
- From: Johan Dahlin <jdahlin async com br>
- To: nautilus-list gnome org
- Subject: [patch] size field for multi window property dialogs
- Date: 30 Jun 2003 23:31:32 +0200
Attached patch that adds file size to multi window property dialogs. The
patch is slightly larger than it should be, because I fixed so it fits
in a 80 column terminal in a few places.
Please put me on cc for all replies, since I'm not subscribed.
The patch is against CVS HEAD.
--
Johan Dahlin <jdahlin async com br>
Async Open Source
Index: file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.175
diff -u -r1.175 fm-properties-window.c
--- file-manager/fm-properties-window.c 11 Jun 2003 17:16:20 -0000 1.175
+++ file-manager/fm-properties-window.c 30 Jun 2003 21:18:43 -0000
@@ -291,8 +291,6 @@
static NautilusFile *
get_target_file (FMPropertiesWindow *window)
{
- g_return_val_if_fail (!is_multi_file_window (window), NULL);
-
return NAUTILUS_FILE (window->details->target_files->data);
}
@@ -1663,48 +1661,74 @@
{
NautilusRequestStatus status;
char *text, *temp;
- guint directory_count;
+ guint dir_count;
guint file_count;
- guint total_count;
- guint unreadable_directory_count;
- GnomeVFSFileSize total_size;
- char *size_string;
+ guint total_count = 0;
+ guint unreadable_dir_count;
+ GnomeVFSFileSize total_size = 0;
gboolean used_two_lines;
NautilusFile *file;
g_assert (FM_IS_PROPERTIES_WINDOW (window));
- /* For right now this will only work on single-file property
- * dialogs */
if (is_multi_file_window (window)) {
- return ;
- }
-
- file = get_target_file (window);
- g_assert (nautilus_file_is_directory (file) || nautilus_file_is_gone (file));
+ GList *l;
+ GnomeVFSFileSize file_size;
+ guint unreadable;
+
+ status = NAUTILUS_REQUEST_NOT_STARTED;
+ unreadable_dir_count = FALSE;
+
+ for (l = window->details->original_files; l; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+ status = nautilus_file_get_deep_counts (file,
+ &dir_count,
+ &file_count,
+ &unreadable,
+ &file_size);
+ if (nautilus_file_is_directory(file)) {
+ total_count += (file_count + dir_count);
+ total_size += file_size;
+ } else {
+ total_count++;
+ total_size += nautilus_file_get_size(file);
+ }
+
+ if (unreadable) {
+ unreadable_dir_count = TRUE;
+ }
+ }
+ } else {
+ file = get_target_file (window);
+ g_assert (nautilus_file_is_directory (file) ||
+ nautilus_file_is_gone (file));
+
+ status = nautilus_file_get_deep_counts (file,
+ &dir_count,
+ &file_count,
+ &unreadable_dir_count,
+ &total_size);
- status = nautilus_file_get_deep_counts (file,
- &directory_count,
- &file_count,
- &unreadable_directory_count,
- &total_size);
+ total_count = file_count + dir_count;
+ }
+
/* If we've already displayed the total once, don't do another visible
- * count-up if the deep_count happens to get invalidated. But still display
- * the new total, since it might have changed.
+ * count-up if the deep_count happens to get invalidated.
+ * But still display the new total, since it might have changed.
*/
- if (window->details->deep_count_finished && status != NAUTILUS_REQUEST_DONE) {
+ if (window->details->deep_count_finished &&
+ status != NAUTILUS_REQUEST_DONE) {
return;
}
text = NULL;
- total_count = file_count + directory_count;
used_two_lines = FALSE;
-
+
if (total_count == 0) {
switch (status) {
case NAUTILUS_REQUEST_DONE:
- if (unreadable_directory_count == 0) {
+ if (unreadable_dir_count == 0) {
text = g_strdup (_("nothing"));
} else {
text = g_strdup (_("unreadable"));
@@ -1714,29 +1738,36 @@
text = g_strdup ("...");
}
} else {
- size_string = gnome_vfs_format_file_size_for_display (total_size);
+ char *size_str;
+ size_str = gnome_vfs_format_file_size_for_display (total_size);
if (total_count == 1) {
- text = g_strdup_printf (_("1 item, with size %s"), size_string);
+ text = g_strdup_printf (_("1 item, with size %s"),
+ size_str);
} else {
- text = g_strdup_printf (_("%d items, totalling %s"), total_count, size_string);
+ text = g_strdup_printf (_("%d items, totalling %s"),
+ total_count, size_str);
}
- g_free (size_string);
+ g_free (size_str);
- if (unreadable_directory_count != 0) {
+ if (unreadable_dir_count != 0) {
temp = text;
- text = g_strconcat (temp, "\n", _("(some contents unreadable)"), NULL);
+ text = g_strconcat (temp, "\n",
+ _("(some contents unreadable)"),
+ NULL);
g_free (temp);
used_two_lines = TRUE;
}
}
- gtk_label_set_text (window->details->directory_contents_value_field, text);
+ gtk_label_set_text (window->details->directory_contents_value_field,
+ text);
g_free (text);
- /* Also set the title field here, with a trailing carriage return & space
- * if the value field has two lines. This is a hack to get the
- * "Contents:" title to line up with the first line of the 2-line value.
- * Maybe there's a better way to do this, but I couldn't think of one.
+ /* Also set the title field here, with a trailing carriage return &
+ * space if the value field has two lines. This is a hack to get the
+ * "Contents:" title to line up with the first line of the
+ * 2-line value. Maybe there's a better way to do this, but I
+ * couldn't think of one.
*/
text = g_strdup (_("Contents:"));
if (used_two_lines) {
@@ -1744,7 +1775,8 @@
text = g_strconcat (temp, "\n ", NULL);
g_free (temp);
}
- gtk_label_set_text (window->details->directory_contents_title_field, text);
+ gtk_label_set_text (window->details->directory_contents_title_field,
+ text);
g_free (text);
if (status == NAUTILUS_REQUEST_DONE) {
@@ -1784,6 +1816,7 @@
int row)
{
GtkLabel *value_field;
+ NautilusFile *file;
value_field = attach_value_label (table, row, VALUE_COLUMN, "");
@@ -1792,23 +1825,33 @@
gtk_label_set_line_wrap (value_field, TRUE);
-
- /* For right now, this will only be called for single-file
- * property dialogs */
- g_return_val_if_fail (!is_multi_file_window (window), value_field);
+ /* Fill in the initial value. */
+ directory_contents_value_field_update (window);
/* Always recompute from scratch when the window is shown. */
- nautilus_file_recompute_deep_counts (get_target_file (window));
+ if (is_multi_file_window (window)) {
+ GList *l;
+ for (l = window->details->original_files; l; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+ nautilus_file_recompute_deep_counts (file);
+
+ g_signal_connect_object (file,
+ "updated_deep_count_in_progress",
+ G_CALLBACK (schedule_directory_contents_update),
+ window, G_CONNECT_SWAPPED);
+ }
+ } else {
+ file = get_target_file (window);
+ nautilus_file_recompute_deep_counts (file);
+
+ /* Connect to signal to update value when file changes. */
+ g_signal_connect_object (file,
+ "updated_deep_count_in_progress",
+ G_CALLBACK (schedule_directory_contents_update),
+ window, G_CONNECT_SWAPPED);
- /* Fill in the initial value. */
- directory_contents_value_field_update (window);
+ }
- /* Connect to signal to update value when file changes. */
- g_signal_connect_object (get_target_file (window),
- "updated_deep_count_in_progress",
- G_CALLBACK (schedule_directory_contents_update),
- window, G_CONNECT_SWAPPED);
-
return value_field;
}
@@ -1903,7 +1946,15 @@
gboolean should_show_count;
if (is_multi_file_window (window)) {
- should_show_count = FALSE;
+ GList *l;
+ guint count = 0;
+ NautilusFile *file;
+
+ for (l = window->details->original_files; l; l = l->next) {
+ file = NAUTILUS_FILE (l->data);
+ count += nautilus_file_should_show_directory_item_count (file);
+ }
+ should_show_count = count;
} else {
should_show_count = nautilus_file_should_show_directory_item_count (get_target_file (window));
}
@@ -2211,12 +2262,8 @@
FALSE);
}
- if (is_multi_file_window (window)) {
- /* FIXME: append a total size field here */
-#if 0
- append_total_size_field (window, table);
-#endif
- } else if (nautilus_file_is_directory (get_target_file (window))) {
+ if (is_multi_file_window (window) ||
+ nautilus_file_is_directory (get_target_file (window))) {
append_directory_contents_fields (window, table);
} else {
append_title_value_pair (window, table, _("Size:"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]