? eel-vfs-file-size.diff
Index: eel-vfs-extensions.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-vfs-extensions.c,v
retrieving revision 1.17
diff -u -r1.17 eel-vfs-extensions.c
--- eel-vfs-extensions.c	27 Mar 2003 15:25:58 -0000	1.17
+++ eel-vfs-extensions.c	23 Apr 2003 12:30:15 -0000
@@ -1680,6 +1680,38 @@
 	return ret;
 }
 
+#define KILOBYTE_FACTOR 1024.0
+#define MEGABYTE_FACTOR (1024.0 * 1024.0)
+
+gchar *
+eel_vfs_format_file_size_for_display (GnomeVFSFileSize size,
+                                      EelVfsFileSize   format)
+{
+        gdouble displayed_size;
+
+        switch (format) {
+        case EEL_VFS_FILE_SIZE_BYTE_FACTOR:
+                if (size == 1)
+                      return g_strdup (_("1 byte"));
+                else
+                      return g_strdup_printf (_("%u bytes"), (guint) size);
+                break;
+        case EEL_VFS_FILE_SIZE_KILOBYTE_FACTOR:
+                displayed_size = (gdouble) size / KILOBYTE_FACTOR;
+                return g_strdup_printf (_("%.1f K"), displayed_size);
+                break;
+        case EEL_VFS_FILE_SIZE_MEGABYTE_FACTOR:
+                displayed_size = (gdouble) size / MEGABYTE_FACTOR;
+                return g_strdup_printf (_("%.1f MB"), displayed_size);
+                break;
+        case EEL_VFS_FILE_SIZE_RELATIVE:
+                return gnome_vfs_format_file_size_for_display (size);
+        default:
+                g_assert_not_reached ();
+                return NULL;
+        }
+}
+
 void
 eel_filename_get_rename_region (const char           *filename,
 				int                  *start_offset,
Index: eel-vfs-extensions.h
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-vfs-extensions.h,v
retrieving revision 1.12
diff -u -r1.12 eel-vfs-extensions.h
--- eel-vfs-extensions.h	27 Mar 2003 15:25:58 -0000	1.12
+++ eel-vfs-extensions.h	23 Apr 2003 12:30:15 -0000
@@ -109,6 +109,15 @@
 							  int                  *start_offset,
 							  int                  *end_offset);
 
+typedef enum {
+        EEL_VFS_FILE_SIZE_BYTE_FACTOR,
+        EEL_VFS_FILE_SIZE_KILOBYTE_FACTOR,
+        EEL_VFS_FILE_SIZE_MEGABYTE_FACTOR,
+        EEL_VFS_FILE_SIZE_RELATIVE
+} EelVfsFileSize;
+
+gchar *           eel_vfs_format_file_size_for_display   (GnomeVfsFileSize      size,
+                                                          EelVfsFileSize        format);
 G_END_DECLS
 
 #endif /* EEL_VFS_EXTENSIONS_H */
