Commit 9295db6d authored by Petr Štětka's avatar Petr Štětka
Browse files

Fixed bug with showing active process.

Graph timespan increased to 60sec.
Merged CpuTableSingle and CpuTableMulti.
parent 74fd0f82
......@@ -2,6 +2,56 @@ using Rg;
namespace Usage {
public class CpuGraphTable : Rg.Table
{
bool multi;
public CpuGraphTable (uint timespan, uint max_samples, bool multi = false)
{
this.multi = multi;
set_timespan (timespan * 1000);
set_max_samples (max_samples);
if(multi)
{
for (int i = 0; i < get_num_processors(); i++)
{
var column = new Rg.Column("CPU: " + i.to_string(), Type.from_name("gdouble"));
add_column(column);
}
}
else
{
var column = new Rg.Column("TOTAL CPU", Type.from_name("gdouble"));
add_column(column);
}
var interval = timespan / (max_samples - 1);
var monitor = (GLib.Application.get_default() as Application).monitor;
//TODO change and move to settings
if(interval < monitor.get_update_graph_interval())
monitor.set_update_graph_interval(interval);
Timeout.add(timespan / (max_samples - 1), update_data);
}
bool update_data()
{
Rg.TableIter iter;
push (out iter, get_monotonic_time ());
if(multi)
{
for (int i = 0; i < get_num_processors(); i++)
iter.set (i, (GLib.Application.get_default() as Application).monitor.x_cpu_load_graph[i], -1);
}
else
iter.set (0, (GLib.Application.get_default() as Application).monitor.cpu_load_graph, -1);
return true;
}
}
public class CpuGraphTableSingle : Rg.Table
{
public CpuGraphTableSingle (uint timespan, uint max_samples)
......
......@@ -4,13 +4,13 @@ namespace Usage
{
public class CpuGraphSingle : Rg.Graph
{
private static CpuGraphTableSingle table;
private static CpuGraphTable table;
public CpuGraphSingle (uint timespan, uint max_samples)
{
if(table == null)
{
table = new CpuGraphTableSingle(timespan, max_samples);
table = new CpuGraphTable(timespan, max_samples, false);
set_table(table);
}
else
......@@ -37,13 +37,13 @@ namespace Usage
"#ce5c00",
};
private static CpuGraphTableMulti table;
private static CpuGraphTable table;
public CpuGraphMulti (uint timespan, uint max_samples)
{
if(table == null)
{
table = new CpuGraphTableMulti(timespan, max_samples);
table = new CpuGraphTable(timespan, max_samples, true);
set_table(table);
}
else
......
......@@ -27,7 +27,7 @@ namespace Usage
process_list_box = new ProcessList();
var cpu_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
var cpu_graph = new CpuGraphMulti(30000, 60);
var cpu_graph = new CpuGraphMulti(60000, 60);
var cpu_graph_frame = new Gtk.Frame(null);
cpu_graph_frame.height_request = 200;
cpu_graph_frame.margin_start = margin_side;
......@@ -61,21 +61,19 @@ namespace Usage
cpu_load_label.set_text(((int) monitor.cpu_load).to_string() + " %");
process_row_list = new List<ProcessRow>();
foreach(unowned Process process in monitor.get_processes()) {
if(show_active_process)
{
if((int) process.cpu_load > 0)
insert_process_row(process);
} else
insert_process_row(process);
foreach(unowned Process process in monitor.get_processes())
{
if(show_active_process)
{
if((int) process.cpu_load > 0)
insert_process_row(process);
}
else
insert_process_row(process);
}
for(int i = 0; i < process_row_list.length(); i++)
{
process_list_box.add(process_row_list.data);
process_row_list =(owned) process_row_list.next;
}
process_list_box.add(process_row_list.nth_data (i));
return true;
}
......
......@@ -4,28 +4,28 @@ namespace Usage
{
public GraphSwitcherButton.processor(string label)
{
Rg.Graph processor_graph = new CpuGraphSingle(30000, 30);
Rg.Graph processor_graph = new CpuGraphSingle(60000, 60);
child = createContent(processor_graph, label);
relief = Gtk.ReliefStyle.NONE;
}
public GraphSwitcherButton.memory(string label)
{
Rg.Graph memory_graph = new CpuGraphSingle(30000, 30);
Rg.Graph memory_graph = new CpuGraphSingle(60000, 60);
child = createContent(memory_graph, label);
relief = Gtk.ReliefStyle.NONE;
}
public GraphSwitcherButton.disk(string label)
{
Rg.Graph disk_graph = new CpuGraphSingle(30000, 30);
Rg.Graph disk_graph = new CpuGraphSingle(60000, 60);
child = createContent(disk_graph, label);
relief = Gtk.ReliefStyle.NONE;
}
public GraphSwitcherButton.network(string label)
{
Rg.Graph network_graph = new CpuGraphSingle(30000, 30);
Rg.Graph network_graph = new CpuGraphSingle(60000, 60);
child = createContent(network_graph, label);
relief = Gtk.ReliefStyle.NONE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment