[gnome-system-monitor] Added SI prefix tera to network counter



commit 3ea7303181e80e188e72a4fcd98b9970fe554b3b
Author: Chris Kühl <chrisk openismus com>
Date:   Sun Apr 17 01:07:20 2011 +0200

    Added SI prefix tera to network counter
    
    https://bugzilla.gnome.org/show_bug.cgi?id=639212

 src/util.cpp |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/src/util.cpp b/src/util.cpp
index 90073fe..234e6fc 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -149,10 +149,12 @@ procman_make_label_for_mmaps_or_ofiles(const char *format,
 gchar*
 procman::format_size(guint64 size, guint64 max_size, bool want_bits)
 {
+
 	enum {
 		K_INDEX,
 		M_INDEX,
-		G_INDEX
+		G_INDEX,
+                T_INDEX
 	};
 
 	struct Format {
@@ -160,16 +162,18 @@ procman::format_size(guint64 size, guint64 max_size, bool want_bits)
 		const char* string;
 	};
 
-	const Format all_formats[2][3] = {
-		{ { 1UL << 10,	N_("%.1f KiB") },
-		  { 1UL << 20,	N_("%.1f MiB") },
-		  { 1UL << 30,	N_("%.1f GiB") } },
-		{ { 1000,	N_("%.1f kbit") },
-		  { 1000000,	N_("%.1f Mbit") },
-		  { 1000000000,	N_("%.1f Gbit") } }
+	const Format all_formats[2][4] = {
+		{ { 1UL << 10,	   N_("%.1f KiB")  },
+		  { 1UL << 20,	   N_("%.1f MiB")  },
+		  { 1UL << 30,	   N_("%.1f GiB")  },
+                  { 1UL << 40,     N_("%.1f TiB")  } },
+		{ { 1000,	   N_("%.1f kbit") },
+		  { 1000000,	   N_("%.1f Mbit") },
+		  { 1000000000,	   N_("%.1f Gbit") },
+                  { 1000000000000, N_("%.1f Tbit") } }
 	};
 
-	const Format (&formats)[3] = all_formats[want_bits ? 1 : 0];
+	const Format (&formats)[4] = all_formats[want_bits ? 1 : 0];
 
 	if (want_bits) {
 	  size *= 8;
@@ -194,9 +198,12 @@ procman::format_size(guint64 size, guint64 max_size, bool want_bits)
 		} else if (max_size < formats[G_INDEX].factor) {
 		  factor = formats[M_INDEX].factor;
 		  format = formats[M_INDEX].string;
-		} else {
+		} else if (max_size < formats[T_INDEX].factor) {
 		  factor = formats[G_INDEX].factor;
 		  format = formats[G_INDEX].string;
+		} else {
+		  factor = formats[T_INDEX].factor;
+		  format = formats[T_INDEX].string;
 		}
 
 		return g_strdup_printf(_(format), size / (double)factor);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]