You are not logged in.

#1 2013-03-21 18:10:39

emorkay
Member
From: India
Registered: 2012-06-06
Posts: 43

[SOLVED]Nautilus base-2 file sizes

Hi,
Is there anyway to display file sizes in nautilus in base-2 units? I have no problem with the current display style but I just prefer base-2 file sizes.

Thanks,

Last edited by emorkay (2013-03-24 14:55:57)

Offline

#2 2013-03-21 23:15:17

don_crissti
Member
Registered: 2009-03-17
Posts: 35

Re: [SOLVED]Nautilus base-2 file sizes

Yes...patch it...

Offline

#3 2013-03-22 13:34:04

emorkay
Member
From: India
Registered: 2012-06-06
Posts: 43

Re: [SOLVED]Nautilus base-2 file sizes

Thanks for the reply. Do I have to build nautilus after applying the patch?

Also, it is giving the following error when patch is applied. "can't find file to patch"

I am sorry but patching files always confuses me. sad

Last edited by emorkay (2013-03-22 13:39:51)

Offline

#4 2013-03-24 14:52:31

emorkay
Member
From: India
Registered: 2012-06-06
Posts: 43

Re: [SOLVED]Nautilus base-2 file sizes

Hi,

I finally patched it and it's showing base2 file sizes. However, the file copy window is still showing base10 sizes. That's not a big problem though.

Thanks,

Last edited by emorkay (2013-03-24 14:54:49)

Offline

#5 2013-03-25 13:34:04

don_crissti
Member
Registered: 2009-03-17
Posts: 35

Re: [SOLVED]Nautilus base-2 file sizes

The diff in my link was just an example... There are several files that need patching in order to have a consistent nautilus behavior. That being said, here is the full diff for nautilus 3.6.3, this should give you base-2 file size in nautilus, file-copy::dialog and right-click::properties:

diff -ur nautilus-3.6.3/libnautilus-private/nautilus-file.c nautilus-3.6.3/libnautilus-private/nautilus-file.c
--- nautilus-3.6.3/libnautilus-private/nautilus-file.c	2012-11-12 23:52:07.000000000 +0200
+++ nautilus-3.6.3/libnautilus-private/nautilus-file.c	2013-03-24 22:08:48.854305587 +0200
@@ -5725,7 +5725,7 @@
 	if (file->details->size == -1) {
 		return NULL;
 	}
-	return g_format_size (file->details->size);
+	return g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS);
 }
 
 /**
@@ -5763,7 +5763,7 @@
 		return NULL;
 	}
 
-	return g_format_size_full (file->details->size, G_FORMAT_SIZE_LONG_FORMAT);
+	return g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS);
 }
 
 
@@ -5823,7 +5823,7 @@
 	 * directly if desired.
 	 */
 	if (report_size) {
-		return g_format_size (total_size);
+		return g_format_size_full (total_size, G_FORMAT_SIZE_IEC_UNITS);
 	}
 
 	return format_item_count_for_display (report_directory_count
@@ -6670,7 +6670,7 @@
 
 	res = NULL;
 	if (file->details->free_space != (guint64)-1) {
-		res = g_format_size (file->details->free_space);
+		res = g_format_size_full (file->details->free_space, G_FORMAT_SIZE_IEC_UNITS);
 	}
 
 	return res;
diff -ur nautilus-3.6.3/libnautilus-private/nautilus-file-operations.c nautilus-3.6.3/libnautilus-private/nautilus-file-operations.c
--- nautilus-3.6.3/libnautilus-private/nautilus-file-operations.c	2012-11-12 23:52:07.000000000 +0200
+++ nautilus-3.6.3/libnautilus-private/nautilus-file-operations.c	2013-03-24 21:46:11.644252889 +0200
@@ -848,7 +848,7 @@
 	goffset size;
 
 	size = va_arg (va, goffset);
-	return g_format_size (size);
+	return g_format_size_full (size, G_FORMAT_SIZE_IEC_UNITS);
 }
 
 static void
diff -ur nautilus-3.6.3/src/nautilus-properties-window.c nautilus-3.6.3/src/nautilus-properties-window.c
--- nautilus-3.6.3/src/nautilus-properties-window.c	2012-11-12 23:52:07.000000000 +0200
+++ nautilus-3.6.3/src/nautilus-properties-window.c	2013-03-24 21:43:34.516532766 +0200
@@ -2166,7 +2166,7 @@
 		}
 	} else {
 		char *size_str;
-		size_str = g_format_size (total_size);
+		size_str = g_format_size_full (total_size, G_FORMAT_SIZE_IEC_UNITS);
 		text = g_strdup_printf (ngettext("%'d item, with size %s",
 						 "%'d items, totalling %s",
 						 total_count),
@@ -2965,9 +2965,9 @@
 	GFile *location;
 	GFileInfo *info;
 	
-	capacity = g_format_size (window->details->volume_capacity);
-	free 	 = g_format_size (window->details->volume_free);
-	used 	 = g_format_size (window->details->volume_used);
+	capacity = g_format_size_full (window->details->volume_capacity, G_FORMAT_SIZE_IEC_UNITS);
+	free 	 = g_format_size_full (window->details->volume_free, G_FORMAT_SIZE_IEC_UNITS);
+	used 	 = g_format_size_full (window->details->volume_used, G_FORMAT_SIZE_IEC_UNITS);
 	
 	file = get_original_file (window);
 	
diff -ur nautilus-3.6.3/src/nautilus-view.c nautilus-3.6.3/src/nautilus-view.c
--- nautilus-3.6.3/src/nautilus-view.c	2012-11-12 23:52:07.000000000 +0200
+++ nautilus-3.6.3/src/nautilus-view.c	2013-03-24 21:44:27.879957569 +0200
@@ -2942,7 +2942,7 @@
 		if (non_folder_size_known) {
 			char *size_string;
 
-			size_string = g_format_size (non_folder_size);
+			size_string = g_format_size_full (non_folder_size, G_FORMAT_SIZE_IEC_UNITS);
 			/* This is marked for translation in case a localiser
 			 * needs to use something other than parentheses. The
 			 * the message in parentheses is the size of the selected items.

Offline

#6 2013-03-25 18:35:40

emorkay
Member
From: India
Registered: 2012-06-06
Posts: 43

Re: [SOLVED]Nautilus base-2 file sizes

Hi,

Thank you very much. After my last post, I kept working on getting a consistent behavior of nautilus and got it working. I was planning on posting today but you beat me to it. smile

Just a small change: Instead of using

 
@@ -5763,7 +5763,7 @@
 		return NULL;
 	}
 
-	return g_format_size_full (file->details->size, G_FORMAT_SIZE_LONG_FORMAT);
+	return g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS);
 }

I used

@@ -5763,7 +5763,7 @@
 		return NULL;
 	}
 
-	return g_format_size_full (file->details->size, G_FORMAT_SIZE_LONG_FORMAT);
+	return g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS + G_FORMAT_SIZE_LONG_FORMAT); 
 }

This displays file size in IEC units and in terms of bytes in brackets.

Last edited by emorkay (2013-03-25 18:40:22)

Offline

Board footer

Powered by FluxBB