diff --git a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala index a9b91f135..5aabb5def 100644 --- a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala +++ b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala @@ -11,6 +11,6 @@ public class Monitor.IndicatorWidgetFrequency : Monitor.IndicatorWidget { public override void update_label (Value value) { double frequency = value.get_double (); - label.label = ("%.2f %s").printf (frequency, _("GHz")); + label.label = Utils.Strings.format_frequency (frequency); } } diff --git a/src/Resources/CPU.vala b/src/Resources/CPU.vala index 824be8b5c..8c68f1b0a 100644 --- a/src/Resources/CPU.vala +++ b/src/Resources/CPU.vala @@ -44,8 +44,8 @@ public class Monitor.CPU : Object { private double _frequency; public double frequency { get { - // Convert kHz to GHz - return (double) (_frequency / 1000000); + // Convert kHz to MHz + return (double) (_frequency / 1000); } } public double temperature_mean { diff --git a/src/Utils.vala b/src/Utils.vala index 379fa66e6..e1bb59859 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -5,6 +5,7 @@ namespace Monitor.Utils { const int BITS_IN_BYTES = 8; + const int MHZ_IN_GHZ = 1000; const string NOT_AVAILABLE = (_("N/A")); const string NO_DATA = "\u2014"; @@ -51,12 +52,26 @@ public class Monitor.Utils.Strings { return pretty; } - public static string format_network_speed (uint64 speed) { + public static string format_frequency (double mhz) { + var frequency = mhz; + if (frequency >= MHZ_IN_GHZ) { + frequency /= MHZ_IN_GHZ; + ///TRANSLATORS: The first param is the cpu frequency speed value and + ///the second param is the cpu frequency speed unit viz. "Ghz" for gigahertz. + return _("%.2f Ghz").printf (frequency); + } + + ///TRANSLATORS: The first param is the cpu frequency speed value and + ///the second param is the cpu frequency speed unit viz. "Mhz" for megahertz. + return _("%.0f Mhz").printf (frequency); + } + + public static string format_network_speed (uint64 speed_in_bytes_per_second) { ///TRANSLATORS: The first param is the numeric value (as string) of network speed. ///The second param with the appended "/s" is the network speed unit such as "Mb/s" for megabits per second. return _("%s %s/s").printf ( - format_size (speed * Utils.BITS_IN_BYTES, BITS | IEC_UNITS | ONLY_VALUE), - format_size (speed * Utils.BITS_IN_BYTES, BITS | ONLY_UNIT) + format_size (speed_in_bytes_per_second * BITS_IN_BYTES, BITS | IEC_UNITS | ONLY_VALUE), + format_size (speed_in_bytes_per_second * BITS_IN_BYTES, BITS | ONLY_UNIT) ); } } diff --git a/src/Views/SystemView/SystemCPUView.vala b/src/Views/SystemView/SystemCPUView.vala index 75b3af965..a17ff781d 100644 --- a/src/Views/SystemView/SystemCPUView.vala +++ b/src/Views/SystemView/SystemCPUView.vala @@ -54,7 +54,7 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { height_request = -1 }; cpu_frequency_chart.set_serie_color (0, Utils.Colors.get_rgba_color (Utils.Colors.LIME_500)); - cpu_frequency_chart.config.y_axis.fixed_max = 5.0; + cpu_frequency_chart.config.y_axis.fixed_max = 7.0; var freq_info_overlay = new Gtk.Overlay () { child = cpu_frequency_chart @@ -77,7 +77,7 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { } public void update () { - cpu_frequency_chart.update (0, cpu.frequency); + cpu_frequency_chart.update (0, cpu.frequency / Utils.MHZ_IN_GHZ); cpu_temperature_chart.update (0, cpu.temperature_mean); cpu_temperature_label.text = ("%.2f %s").printf (cpu.temperature_mean, _("℃")); @@ -116,7 +116,7 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { } main_metric_value = ("%d%%").printf (cpu.percentage); - cpu_frequency_label.text = ("%.2f %s").printf (cpu.frequency, _("GHz")); + cpu_frequency_label.text = Utils.Strings.format_frequency (cpu.frequency); } private Gtk.Grid grid_core_labels () {