From 2ec55d4242083066257dabfe3cbfd74e137c4a03 Mon Sep 17 00:00:00 2001 From: stsdc Date: Sun, 19 Jul 2020 00:14:26 +0200 Subject: [PATCH] percentage label in system view is now on a chart --- src/Views/SystemView/SystemCPUView.vala | 10 ++++------ src/Views/SystemView/SystemMemoryView.vala | 7 ++++--- src/Views/SystemView/SystemView.vala | 2 -- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Views/SystemView/SystemCPUView.vala b/src/Views/SystemView/SystemCPUView.vala index b3350a38..f0d567a7 100644 --- a/src/Views/SystemView/SystemCPUView.vala +++ b/src/Views/SystemView/SystemCPUView.vala @@ -23,22 +23,19 @@ public class Monitor.SystemCPUView : Gtk.Grid { cpu_percentage_label.get_style_context ().add_class ("h2"); cpu_percentage_label.valign = Gtk.Align.START; cpu_percentage_label.halign = Gtk.Align.START; + cpu_percentage_label.margin_start = 6; cpu_chart = new SystemCPUChart (cpu.core_list.size); - attach (cpu_percentage_label, 0, 0, 1, 1); - attach (grid_core_labels (), 0, 1, 1); + attach (grid_core_labels (), 0, 0, 1); + attach (cpu_percentage_label, 1, 0, 1, 1); attach (cpu_chart, 1, 0, 1, 2); - - } public void update () { for (int i = 0; i < cpu.core_list.size; i++) { - // donno why, but gives -nan if not stored - // someone explain, plz double core_percentage = cpu.core_list[i].percentage_used; cpu_chart.update(i, core_percentage); string percentage_formatted = ("% 3d%%").printf ( (int)core_percentage); @@ -51,6 +48,7 @@ public class Monitor.SystemCPUView : Gtk.Grid { private Gtk.Grid grid_core_labels () { Gtk.Grid grid = new Gtk.Grid (); grid.column_spacing = 12; + grid.width_request = 300; int column = 0; int row = 0; for (int i = 0; i < cpu.core_list.size; i++) { diff --git a/src/Views/SystemView/SystemMemoryView.vala b/src/Views/SystemView/SystemMemoryView.vala index e63d7951..25ee3b0a 100644 --- a/src/Views/SystemView/SystemMemoryView.vala +++ b/src/Views/SystemView/SystemMemoryView.vala @@ -14,7 +14,6 @@ public class Monitor.SystemMemoryView : Gtk.Grid { margin = 12; column_spacing = 12; set_vexpand (false); - } @@ -26,6 +25,7 @@ public class Monitor.SystemMemoryView : Gtk.Grid { memory_percentage_label.get_style_context ().add_class ("h2"); memory_percentage_label.halign = Gtk.Align.START; memory_percentage_label.valign = Gtk.Align.START; + memory_percentage_label.margin_start = 6; memory_total_label = new Gtk.Label ("Total: " + Utils.NO_DATA); memory_total_label.halign = Gtk.Align.START; @@ -47,8 +47,8 @@ public class Monitor.SystemMemoryView : Gtk.Grid { memory_chart = new SystemCPUChart (1); - attach (memory_percentage_label, 0, 0, 2, 1); - attach (memory_usage_grid (), 0, 1, 1); + attach (memory_percentage_label, 1, 0, 1, 1); + attach (memory_usage_grid (), 0, 0, 1); attach (memory_chart, 1, 0, 1, 2); } @@ -56,6 +56,7 @@ public class Monitor.SystemMemoryView : Gtk.Grid { private Gtk.Grid memory_usage_grid () { Gtk.Grid grid = new Gtk.Grid (); grid.column_spacing = 12; + grid.width_request = 300; grid.attach (memory_used_label, 0, 0, 1, 1); grid.attach (memory_total_label, 1, 0, 1, 1); diff --git a/src/Views/SystemView/SystemView.vala b/src/Views/SystemView/SystemView.vala index 6d5ab6de..162d5467 100644 --- a/src/Views/SystemView/SystemView.vala +++ b/src/Views/SystemView/SystemView.vala @@ -7,8 +7,6 @@ public class Monitor.SystemView : Gtk.Box { construct { orientation = Gtk.Orientation.VERTICAL; hexpand = true; - - } public SystemView (Resources _resources) {