Skip to content

Commit

Permalink
percentage label in system view is now on a chart
Browse files Browse the repository at this point in the history
  • Loading branch information
stsdc committed Jul 18, 2020
1 parent 51041f2 commit 2ec55d4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
10 changes: 4 additions & 6 deletions src/Views/SystemView/SystemCPUView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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++) {
Expand Down
7 changes: 4 additions & 3 deletions src/Views/SystemView/SystemMemoryView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class Monitor.SystemMemoryView : Gtk.Grid {
margin = 12;
column_spacing = 12;
set_vexpand (false);

}


Expand All @@ -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;
Expand All @@ -47,15 +47,16 @@ 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);

}

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);
Expand Down
2 changes: 0 additions & 2 deletions src/Views/SystemView/SystemView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ public class Monitor.SystemView : Gtk.Box {
construct {
orientation = Gtk.Orientation.VERTICAL;
hexpand = true;


}

public SystemView (Resources _resources) {
Expand Down

0 comments on commit 2ec55d4

Please sign in to comment.