Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Indicator/Widgets/IndicatorWidgetFrequency.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions src/Resources/CPU.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 18 additions & 3 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Views/SystemView/SystemCPUView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, _("℃"));
Expand Down Expand Up @@ -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 () {
Expand Down
Loading