gnome-system-monitor r2293 - trunk/src



Author: bdejean
Date: Sat Feb  2 11:51:02 2008
New Revision: 2293
URL: http://svn.gnome.org/viewvc/gnome-system-monitor?rev=2293&view=rev

Log:
New argument to format_file_size... and format_rate to force unit.
Network Y-scale: make sure all labels have the same unit.
See #418181. 


Modified:
   trunk/src/load-graph.cpp
   trunk/src/util.cpp
   trunk/src/util.h

Modified: trunk/src/load-graph.cpp
==============================================================================
--- trunk/src/load-graph.cpp	(original)
+++ trunk/src/load-graph.cpp	Sat Feb  2 11:51:02 2008
@@ -182,7 +182,7 @@
 		if (g->type == LOAD_GRAPH_NET) {
 			// operation orders matters so it's 0 if i == num_bars
 			unsigned rate = g->net.max - (i * g->net.max / num_bars);
-			const std::string caption(procman::format_rate(rate));
+			const std::string caption(procman::format_rate(rate, g->net.max));
 			cairo_text_extents (tmp_cr, caption.c_str(), &extents);
 			cairo_move_to (tmp_cr, g->indent - extents.width + 20, y);
 			cairo_show_text (tmp_cr, caption.c_str());

Modified: trunk/src/util.cpp
==============================================================================
--- trunk/src/util.cpp	(original)
+++ trunk/src/util.cpp	Sat Feb  2 11:51:02 2008
@@ -153,18 +153,21 @@
  **/
 
 gchar*
-SI_gnome_vfs_format_file_size_for_display (GnomeVFSFileSize size)
+SI_gnome_vfs_format_file_size_for_display (GnomeVFSFileSize size, GnomeVFSFileSize max_size)
 {
-	if (size < (GnomeVFSFileSize) KIBIBYTE_FACTOR) {
+	if (max_size == 0)
+		max_size = size;
+
+	if (max_size < (GnomeVFSFileSize) KIBIBYTE_FACTOR) {
 		return g_strdup_printf (dngettext(GETTEXT_PACKAGE, "%u byte", "%u bytes",(guint) size), (guint) size);
 	} else {
 		guint factor;
 		const char* format;
 
-		if (size < (GnomeVFSFileSize) MEBIBYTE_FACTOR) {
+		if (max_size < (GnomeVFSFileSize) MEBIBYTE_FACTOR) {
 		  factor = KIBIBYTE_FACTOR;
 		  format = N_("%.1f KiB");
-		} else if (size < (GnomeVFSFileSize) GIBIBYTE_FACTOR) {
+		} else if (max_size < (GnomeVFSFileSize) GIBIBYTE_FACTOR) {
 		  factor = MEBIBYTE_FACTOR;
 		  format = N_("%.1f MiB");
 		} else {
@@ -456,9 +459,9 @@
 
 
 
-  std::string format_rate(GnomeVFSFileSize rate)
+  std::string format_rate(GnomeVFSFileSize rate, GnomeVFSFileSize max_rate)
   {
-    char* bytes = SI_gnome_vfs_format_file_size_for_display(rate);
+    char* bytes = SI_gnome_vfs_format_file_size_for_display(rate, max_rate);
     // xgettext: rate, 10MiB/s
     return make_string(g_strdup_printf(_("%s/s"), bytes));
   }

Modified: trunk/src/util.h
==============================================================================
--- trunk/src/util.h	(original)
+++ trunk/src/util.h	Sat Feb  2 11:51:02 2008
@@ -35,7 +35,7 @@
 
 
 gchar*
-SI_gnome_vfs_format_file_size_for_display (GnomeVFSFileSize size);
+SI_gnome_vfs_format_file_size_for_display (GnomeVFSFileSize size, GnomeVFSFileSize max = 0);
 
 
 gboolean
@@ -141,7 +141,7 @@
 
 
 
-  std::string format_rate(GnomeVFSFileSize rate);
+  std::string format_rate(GnomeVFSFileSize rate, GnomeVFSFileSize max_rate = 0);
 }
 
 



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