From 4bbd6a0ff90a6ff1b352662784c494d4ece2fdb6 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Tue, 25 Aug 2026 09:01:35 +0530 Subject: [PATCH 1/6] Increase width of bandwidth and frequency indicators Avoid indicator positions shifting when displaying different values. --- src/Indicator/Widgets/IndicatorWidgetBandwidth.vala | 4 ++++ src/Indicator/Widgets/IndicatorWidgetFrequency.vala | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala index e58b3a2fe..ca7ea7d28 100644 --- a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala +++ b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala @@ -8,6 +8,10 @@ public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget { base (icon_name); } + construct { + label.width_chars = 8; + } + public override void update_label (Value value) { uint64 bandwidth = value.get_uint64 (); diff --git a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala index a9b91f135..2be473e5f 100644 --- a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala +++ b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala @@ -8,6 +8,10 @@ public class Monitor.IndicatorWidgetFrequency : Monitor.IndicatorWidget { base (icon_name); } + construct { + label.width_chars = 8; + } + public override void update_label (Value value) { double frequency = value.get_double (); From 3b6d5320f818e7b98ac5dff713dc5e0ece7aecbd Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Mon, 14 Sep 2026 11:58:50 +0530 Subject: [PATCH 2/6] Revert "Increase width of bandwidth and frequency indicators" This reverts commit 4bbd6a0ff90a6ff1b352662784c494d4ece2fdb6. --- src/Indicator/Widgets/IndicatorWidgetBandwidth.vala | 4 ---- src/Indicator/Widgets/IndicatorWidgetFrequency.vala | 4 ---- 2 files changed, 8 deletions(-) diff --git a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala index ca7ea7d28..e58b3a2fe 100644 --- a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala +++ b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala @@ -8,10 +8,6 @@ public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget { base (icon_name); } - construct { - label.width_chars = 8; - } - public override void update_label (Value value) { uint64 bandwidth = value.get_uint64 (); diff --git a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala index 2be473e5f..a9b91f135 100644 --- a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala +++ b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala @@ -8,10 +8,6 @@ public class Monitor.IndicatorWidgetFrequency : Monitor.IndicatorWidget { base (icon_name); } - construct { - label.width_chars = 8; - } - public override void update_label (Value value) { double frequency = value.get_double (); From 5d600eca71207b9ce49681d60534ba610822716e Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Mon, 14 Sep 2026 12:11:50 +0530 Subject: [PATCH 3/6] Use tabular markup, width_chars and xalign left --- src/Indicator/Widgets/IndicatorWidgetBandwidth.vala | 8 +++++++- src/Indicator/Widgets/IndicatorWidgetFrequency.vala | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala index e58b3a2fe..f5db42843 100644 --- a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala +++ b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala @@ -8,9 +8,15 @@ public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget { base (icon_name); } + construct { + label.use_markup = true; + label.width_chars = 8; + label.xalign = 0; + } + public override void update_label (Value value) { uint64 bandwidth = value.get_uint64 (); - label.label = format_size (bandwidth); + label.label = GLib.Markup.printf_escaped ("%s", format_size (bandwidth)); } } diff --git a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala index a9b91f135..6badeb348 100644 --- a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala +++ b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala @@ -8,9 +8,13 @@ public class Monitor.IndicatorWidgetFrequency : Monitor.IndicatorWidget { base (icon_name); } + construct { + label.use_markup = true; + } + public override void update_label (Value value) { double frequency = value.get_double (); - label.label = ("%.2f %s").printf (frequency, _("GHz")); + label.label = ("%.2f %s").printf (frequency, _("GHz")); } } From 005b984416da418759e71095c64bdca494bda345 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Wed, 16 Sep 2026 21:49:29 +0530 Subject: [PATCH 4/6] Add seconday indicator label to minimise indicator shifting about --- src/Indicator/Widgets/IndicatorWidget.vala | 10 ++++++ .../Widgets/IndicatorWidgetBandwidth.vala | 20 +++++++---- .../Widgets/IndicatorWidgetFrequency.vala | 15 ++++++--- src/Utils.vala | 33 +++++++++++++------ src/Views/SystemView/SystemCPUView.vala | 5 ++- src/Views/SystemView/SystemNetworkView.vala | 8 +++-- 6 files changed, 66 insertions(+), 25 deletions(-) diff --git a/src/Indicator/Widgets/IndicatorWidget.vala b/src/Indicator/Widgets/IndicatorWidget.vala index 80301e90c..9ae6aa590 100644 --- a/src/Indicator/Widgets/IndicatorWidget.vala +++ b/src/Indicator/Widgets/IndicatorWidget.vala @@ -8,6 +8,7 @@ public class Monitor.IndicatorWidget : Gtk.Box { public string icon_name { get; construct; } protected Gtk.Label label; + protected Gtk.Label secondary_label; public IndicatorWidget (string icon_name) { Object ( @@ -28,6 +29,15 @@ public class Monitor.IndicatorWidget : Gtk.Box { width_chars = 4, }; + secondary_label = new Gtk.Label (Utils.NOT_AVAILABLE) { + margin_start = 2, + margin_end = 2, + margin_top = 2, + margin_bottom = 2, + width_chars = 4, + visible = false, + }; + append (icon); append (label); } diff --git a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala index f86c634e9..211d731a4 100644 --- a/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala +++ b/src/Indicator/Widgets/IndicatorWidgetBandwidth.vala @@ -9,17 +9,23 @@ public class Monitor.IndicatorWidgetBandwidth : Monitor.IndicatorWidget { } construct { - label.use_markup = true; - label.width_chars = 8; - label.xalign = 0; + label.xalign = 0.5f; + label.margin_end = 0; + label.width_chars = 3; + label.max_width_chars = 3; + secondary_label.xalign = 1; + secondary_label.visible = true; + append (secondary_label); } public override void update_label (Value value) { uint64 bandwidth = value.get_uint64 (); - label.label = GLib.Markup.printf_escaped ( - "%s", - Utils.Strings.format_network_speed (bandwidth) - ); + string speed_value; + string speed_unit; + Utils.Strings.format_network_speed (bandwidth, out speed_value, out speed_unit); + + label.label = speed_value; + secondary_label.label = speed_unit; } } diff --git a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala index 50911b3ca..efacf9ef4 100644 --- a/src/Indicator/Widgets/IndicatorWidgetFrequency.vala +++ b/src/Indicator/Widgets/IndicatorWidgetFrequency.vala @@ -9,15 +9,20 @@ public class Monitor.IndicatorWidgetFrequency : Monitor.IndicatorWidget { } construct { - label.use_markup = true; + secondary_label.width_chars = 3; + secondary_label.margin_start = 0; + secondary_label.visible = true; + append (secondary_label); } public override void update_label (Value value) { double frequency = value.get_double (); - label.label = GLib.Markup.printf_escaped ( - "%s", - Utils.Strings.format_frequency (frequency) - ); + string frequency_value; + string frequency_unit; + Utils.Strings.format_frequency (frequency, out frequency_value, out frequency_unit); + + label.label = frequency_value; + secondary_label.label = frequency_unit; } } diff --git a/src/Utils.vala b/src/Utils.vala index e1bb59859..c3e5575ce 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -6,6 +6,7 @@ namespace Monitor.Utils { const int BITS_IN_BYTES = 8; const int MHZ_IN_GHZ = 1000; + const int IEC_UNIT_BASE = 1024; const string NOT_AVAILABLE = (_("N/A")); const string NO_DATA = "\u2014"; @@ -52,27 +53,39 @@ public class Monitor.Utils.Strings { return pretty; } - public static string format_frequency (double mhz) { + public static void format_frequency (double mhz, out string frequency_value, out string frequency_unit) { 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); + frequency_value = _("%.2f").printf (frequency); + frequency_unit = _("Ghz"); + return; } ///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); + frequency_value = _("%.0f").printf (frequency); + frequency_unit = _("Mhz"); } - 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_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) - ); + public static void format_network_speed (uint64 speed_in_bytes_per_second, out string speed_value, out string speed_unit) { + ///TRANSLATORS: These are the network speed unit such as "Mbps" for "megabits per second". + string[] UNITS = {_("bps"), _("Kbps"), _("Mbps"), _("Gbps"), _("Tbps")}; + + var speed_in_bits_per_second = speed_in_bytes_per_second * BITS_IN_BYTES; + + int unit_index = 0; + while ((speed_in_bits_per_second / IEC_UNIT_BASE) > 0 && (unit_index < UNITS.length)) { + unit_index++; + speed_in_bits_per_second /= IEC_UNIT_BASE; + } + + ///TRANSLATORS: This is the numeric value of network speed. + speed_value = _("%llu").printf (speed_in_bits_per_second); + + speed_unit = UNITS[unit_index]; } } diff --git a/src/Views/SystemView/SystemCPUView.vala b/src/Views/SystemView/SystemCPUView.vala index a17ff781d..266fd004d 100644 --- a/src/Views/SystemView/SystemCPUView.vala +++ b/src/Views/SystemView/SystemCPUView.vala @@ -116,7 +116,10 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { } main_metric_value = ("%d%%").printf (cpu.percentage); - cpu_frequency_label.text = Utils.Strings.format_frequency (cpu.frequency); + string frequency_value; + string frequency_unit; + Utils.Strings.format_frequency (cpu.frequency, out frequency_value, out frequency_unit); + cpu_frequency_label.text = "%s %s".printf (frequency_value, frequency_unit); } private Gtk.Grid grid_core_labels () { diff --git a/src/Views/SystemView/SystemNetworkView.vala b/src/Views/SystemView/SystemNetworkView.vala index dd5d1fb7d..a762c84a7 100644 --- a/src/Views/SystemView/SystemNetworkView.vala +++ b/src/Views/SystemView/SystemNetworkView.vala @@ -60,8 +60,12 @@ 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 = Utils.Strings.format_network_speed ((uint64) down_bytes); - network_upload_label.text = Utils.Strings.format_network_speed ((uint64) up_bytes); + string speed_value; + string speed_unit; + Utils.Strings.format_frequency ((uint64) down_bytes, out speed_value, out speed_unit); + network_download_label.text = "%s %s".printf (speed_value, speed_unit); + Utils.Strings.format_frequency ((uint64) up_bytes, out speed_value, out speed_unit); + network_upload_label.text = "%s %s".printf (speed_value, speed_unit); network_chart.update (0, up_bytes); network_chart.update (1, down_bytes); } From a221fcb779d870dbf8e53bd448830d564498a1b9 Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Wed, 16 Sep 2026 21:55:06 +0530 Subject: [PATCH 5/6] Fix lint for non const var naming convention --- src/Utils.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Utils.vala b/src/Utils.vala index c3e5575ce..9dfc19ee7 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -72,12 +72,12 @@ public class Monitor.Utils.Strings { public static void format_network_speed (uint64 speed_in_bytes_per_second, out string speed_value, out string speed_unit) { ///TRANSLATORS: These are the network speed unit such as "Mbps" for "megabits per second". - string[] UNITS = {_("bps"), _("Kbps"), _("Mbps"), _("Gbps"), _("Tbps")}; + string[] units = {_("bps"), _("Kbps"), _("Mbps"), _("Gbps"), _("Tbps")}; var speed_in_bits_per_second = speed_in_bytes_per_second * BITS_IN_BYTES; int unit_index = 0; - while ((speed_in_bits_per_second / IEC_UNIT_BASE) > 0 && (unit_index < UNITS.length)) { + while ((speed_in_bits_per_second / IEC_UNIT_BASE) > 0 && (unit_index < units.length)) { unit_index++; speed_in_bits_per_second /= IEC_UNIT_BASE; } @@ -85,7 +85,7 @@ public class Monitor.Utils.Strings { ///TRANSLATORS: This is the numeric value of network speed. speed_value = _("%llu").printf (speed_in_bits_per_second); - speed_unit = UNITS[unit_index]; + speed_unit = units[unit_index]; } } From 4dc40a87dd7df9c835f6936055136e2ed857702d Mon Sep 17 00:00:00 2001 From: Vishal Rao Date: Wed, 16 Sep 2026 22:01:59 +0530 Subject: [PATCH 6/6] Fix string translation issues --- src/Views/SystemView/SystemCPUView.vala | 4 +++- src/Views/SystemView/SystemNetworkView.vala | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Views/SystemView/SystemCPUView.vala b/src/Views/SystemView/SystemCPUView.vala index 266fd004d..403da5653 100644 --- a/src/Views/SystemView/SystemCPUView.vala +++ b/src/Views/SystemView/SystemCPUView.vala @@ -119,7 +119,9 @@ public class Monitor.SystemCPUView : Monitor.WidgetResource { string frequency_value; string frequency_unit; Utils.Strings.format_frequency (cpu.frequency, out frequency_value, out frequency_unit); - cpu_frequency_label.text = "%s %s".printf (frequency_value, frequency_unit); + ///TRANSLATORS: The first param is the cpu frequency speed value (as a string) and + ///the second param is the cpu frequency speed unit such as "Ghz" for "gigahertz" or "Mhz" for "megahertz". + cpu_frequency_label.text = _("%s %s").printf (frequency_value, frequency_unit); } private Gtk.Grid grid_core_labels () { diff --git a/src/Views/SystemView/SystemNetworkView.vala b/src/Views/SystemView/SystemNetworkView.vala index a762c84a7..0f6ceeee0 100644 --- a/src/Views/SystemView/SystemNetworkView.vala +++ b/src/Views/SystemView/SystemNetworkView.vala @@ -63,9 +63,13 @@ public class Monitor.SystemNetworkView : Gtk.Grid { string speed_value; string speed_unit; Utils.Strings.format_frequency ((uint64) down_bytes, out speed_value, out speed_unit); - network_download_label.text = "%s %s".printf (speed_value, speed_unit); + ///TRANSLATORS: The first param is the numeric value (as string) of network speed. + ///The second param is the network speed unit such as "Mbps" for "megabits per second". + network_download_label.text = _("%s %s").printf (speed_value, speed_unit); Utils.Strings.format_frequency ((uint64) up_bytes, out speed_value, out speed_unit); - network_upload_label.text = "%s %s".printf (speed_value, speed_unit); + ///TRANSLATORS: The first param is the numeric value (as string) of network speed. + ///The second param is the network speed unit such as "Mbps" for "megabits per second". + network_upload_label.text = _("%s %s").printf (speed_value, speed_unit); network_chart.update (0, up_bytes); network_chart.update (1, down_bytes); }