[gnome-system-monitor] Drop the max_rate/max_size arguments for format_*. This may introduce UI regression int graph scales



commit 59a831e36f1e90d12f951cdcbbcad43b311bccd8
Author: Benoît Dejean <bdejean gmail com>
Date:   Mon Nov 6 21:15:07 2017 +0100

    Drop the max_rate/max_size arguments for format_*.
    This may introduce UI regression int graph scales.
    But that's the only way to use the generic g_format_size_full instead.

 src/load-graph.cpp |    2 +-
 src/util.cpp       |   18 ++++++++++--------
 src/util.h         |    8 ++++----
 3 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index 649fa11..336917b 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -115,7 +115,7 @@ void draw_background(LoadGraph *graph) {
         if (graph->type == LOAD_GRAPH_NET) {
             // operation orders matters so it's 0 if i == num_bars
             guint64 rate = graph->net.max - (i * graph->net.max / num_bars);
-            const std::string captionstr(procman::format_network_rate(rate, graph->net.max));
+            const std::string captionstr(procman::format_network_rate(rate));
             caption = g_strdup(captionstr.c_str());
         } else {
             // operation orders matters so it's 0 if i == num_bars
diff --git a/src/util.cpp b/src/util.cpp
index 31a215e..74d0cdc 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -145,7 +145,7 @@ procman_make_label_for_mmaps_or_ofiles(const char *format,
  **/
 
 gchar*
-procman::format_size(guint64 size, guint64 max_size, bool want_bits)
+procman::format_size(guint64 size, bool want_bits)
 {
 
     enum {
@@ -173,6 +173,8 @@ procman::format_size(guint64 size, guint64 max_size, bool want_bits)
 
     const Format (&formats)[4] = all_formats[want_bits ? 1 : 0];
 
+    guint64 max_size = size;
+
     if (want_bits) {
         size *= 8;
         max_size *= 8;
@@ -473,7 +475,7 @@ namespace procman
             g_free(str);
         }
         else {
-            g_object_set(renderer, "text", procman::format_rate(size, size, FALSE).c_str(), NULL);
+            g_object_set(renderer, "text", procman::format_rate(size, FALSE).c_str(), NULL);
         }
 
     }
@@ -660,9 +662,9 @@ namespace procman
     }
 
 
-    std::string format_rate(guint64 rate, guint64 max_rate, bool want_bits)
+    std::string format_rate(guint64 rate, bool want_bits)
     {
-        char* bytes = procman::format_size(rate, max_rate, want_bits);
+        char* bytes = procman::format_size(rate, want_bits);
         // xgettext: rate, 10MiB/s or 10Mbit/s
         std::string formatted_rate(make_string(g_strdup_printf(_("%s/s"), bytes)));
         g_free(bytes);
@@ -670,18 +672,18 @@ namespace procman
     }
 
 
-    std::string format_network(guint64 rate, guint64 max_rate)
+    std::string format_network(guint64 rate)
     {
-        char* bytes = procman::format_size(rate, max_rate, GsmApplication::get()->config.network_in_bits);
+        char* bytes = procman::format_size(rate, GsmApplication::get()->config.network_in_bits);
         std::string formatted(bytes);
         g_free(bytes);
         return formatted;
     }
 
 
-    std::string format_network_rate(guint64 rate, guint64 max_rate)
+    std::string format_network_rate(guint64 rate)
     {
-        return procman::format_rate(rate, max_rate, GsmApplication::get()->config.network_in_bits);
+        return procman::format_rate(rate, GsmApplication::get()->config.network_in_bits);
     }
 
 }
diff --git a/src/util.h b/src/util.h
index ab38cac..d76244e 100644
--- a/src/util.h
+++ b/src/util.h
@@ -119,16 +119,16 @@ namespace procman
         tree_store_update<const char>(model, iter, column, new_value);
     }
 
-    gchar* format_size(guint64 size, guint64 max = 0, bool want_bits = false);
+    gchar* format_size(guint64 size, bool want_bits = false);
 
     gchar* get_nice_level (gint nice);
 
     gchar* get_nice_level_with_priority (gint nice);
 
-    std::string format_rate(guint64 rate, guint64 max_rate = 0, bool want_bits = false);
+    std::string format_rate(guint64 rate, bool want_bits = false);
 
-    std::string format_network(guint64 rate, guint64 max_rate = 0);
-    std::string format_network_rate(guint64 rate, guint64 max_rate = 0);
+    std::string format_network(guint64 rate);
+    std::string format_network_rate(guint64 rate);
 
     class NonCopyable
     {


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