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/IndicatorWidgetBandwidth.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget {
public override void update_label (Value value) {
uint64 bandwidth = value.get_uint64 ();

label.label = format_size (bandwidth);
label.label = Utils.Strings.format_network_speed (bandwidth);
}
}
10 changes: 10 additions & 0 deletions src/Utils.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/

namespace Monitor.Utils {
const int BITS_IN_BYTES = 8;

const string NOT_AVAILABLE = (_("N/A"));
const string NO_DATA = "\u2014";

Expand Down Expand Up @@ -49,6 +51,14 @@ public class Monitor.Utils.Strings {
return pretty;
}

public static string format_network_speed (uint64 speed) {
///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)
);
}
}

public class Monitor.Utils.Colors : Object {
Expand Down
4 changes: 2 additions & 2 deletions src/Views/SystemView/SystemNetworkView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class Monitor.SystemNetworkView : Gtk.Grid {
double up_bytes = network.bytes_out;
double down_bytes = network.bytes_in;
if (up_bytes >= 0 && down_bytes >= 0) {
network_download_label.text = ("%s/s").printf (format_size ((uint64) down_bytes, IEC_UNITS));
network_upload_label.text = ("%s/s").printf (format_size ((uint64) up_bytes, IEC_UNITS));
network_download_label.text = Utils.Strings.format_network_speed ((uint64) down_bytes);
network_upload_label.text = Utils.Strings.format_network_speed ((uint64) up_bytes);
network_chart.update (0, up_bytes);
network_chart.update (1, down_bytes);
}
Expand Down
Loading