Commit 64ea83fa authored by Petr Štětka's avatar Petr Štětka
Browse files

Fixed compiler warnings.

Process dialog show name of process.
parent b779fd09
No preview for this file type
......@@ -7,31 +7,31 @@ namespace Usage
**/
public class CpuGraphMostUsed : Rg.Graph
{
private static CpuGraphTableMostUsedCore table;
private static CpuGraphTableMostUsedCore rg_table;
private LineRenderer renderer;
private const string red_color = "#ee2222";
private const string blue_color = "#4a90d9";
public CpuGraphMostUsed ()
{
if(table == null)
if(rg_table == null)
{
table = new CpuGraphTableMostUsedCore();
set_table(table);
rg_table = new CpuGraphTableMostUsedCore();
set_table(rg_table);
}
else
set_table(table);
set_table(rg_table);
renderer = new LineRenderer();
renderer.stroke_color = blue_color;
renderer.line_width = 1.2;
add_renderer(renderer);
table.big_process_usage.connect (() => {
rg_table.big_process_usage.connect (() => {
renderer.stroke_color = red_color;
});
table.small_process_usage.connect (() => {
rg_table.small_process_usage.connect (() => {
renderer.stroke_color = blue_color;
});
}
......@@ -42,20 +42,20 @@ namespace Usage
**/
public class CpuGraphAllCores : Rg.Graph
{
private static CpuGraphTableComplex table;
private static CpuGraphTableComplex rg_table;
private LineRenderer[] renderers;
private const string red_color = "#ee2222";
private const string blue_color = "#a8c9ed";
public CpuGraphAllCores ()
{
if(table == null)
if(rg_table == null)
{
table = new CpuGraphTableComplex();
set_table(table);
rg_table = new CpuGraphTableComplex();
set_table(rg_table);
}
else
set_table(table);
set_table(rg_table);
renderers = new LineRenderer[get_num_processors()];
for(int i = 0; i < get_num_processors(); i++)
......@@ -67,11 +67,11 @@ namespace Usage
add_renderer(renderers[i]);
}
table.big_process_usage.connect ((column) => {
rg_table.big_process_usage.connect ((column) => {
renderers[column].stroke_color = red_color;
});
table.small_process_usage.connect ((column) => {
rg_table.small_process_usage.connect ((column) => {
renderers[column].stroke_color = blue_color;
});
}
......
......@@ -2,8 +2,6 @@ namespace Usage
{
public class ProcessorSubView : View
{
bool show_active_process = true;
public ProcessorSubView()
{
name = "PROCESSOR";
......
......@@ -4,17 +4,17 @@ namespace Usage
{
public class MemoryGraph: Rg.Graph
{
private static MemoryGraphTable table;
private static MemoryGraphTable rg_table;
public MemoryGraph ()
{
if(table == null)
if(rg_table == null)
{
table = new MemoryGraphTable();
set_table(table);
rg_table = new MemoryGraphTable();
set_table(rg_table);
}
else
set_table(table);
set_table(rg_table);
LineRenderer renderer_ram = new LineRenderer();
renderer_ram.column = MemoryGraphTable.column_ram_id;
......
......@@ -4,7 +4,6 @@ namespace Usage
public class MemorySubView : View
{
Gtk.Label memory_load_label;
bool show_active_process = true;
public MemorySubView()
{
......
......@@ -4,14 +4,13 @@ namespace Usage
{
public class ProcessDialog : Gtk.Dialog
{
private Gtk.Widget kill_button;
private pid_t pid;
public ProcessDialog(pid_t pid)
public ProcessDialog(pid_t pid, string name)
{
Object(use_header_bar: 1);
this.pid = pid;
this.title = "Process";
this.title = name;
this.border_width = 5;
set_default_size (350, 100);
create_widgets();
......
......@@ -78,7 +78,7 @@ namespace Usage
row.post_update();
if(row.get_alive() == false)
{
process_rows_table.remove(row.get_name());
process_rows_table.remove(row.get_cmdline());
rows.remove(row);
}
}
......
......@@ -11,9 +11,9 @@ namespace Usage
Gtk.EventBox event_box;
SubProcessListBox sub_process_list_box;
bool in_box = false;
pid_t pid; //TODO pid should be type of pid_t no uint.
pid_t pid;
int value;
string name;
string cmdline;
bool alive = true;
bool group = false;
......@@ -21,16 +21,16 @@ namespace Usage
public bool showing_details { get; private set; }
public bool max_usage { get; private set; }
public ProcessRow(pid_t pid, int value, string name)
public ProcessRow(pid_t pid, int value, string cmdline)
{
this.pid = pid;
this.name = name;
this.cmdline = cmdline;
this.margin = 0;
this.orientation = Gtk.Orientation.VERTICAL;
var main_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
main_box.margin = 12;
title_label = new Gtk.Label(name); //TODO implement give name
title_label = new Gtk.Label(cmdline); //TODO implement give name
load_label = new Gtk.Label(null);
load_label.ellipsize = Pango.EllipsizeMode.END;
load_label.max_width_chars = 30;
......@@ -53,7 +53,7 @@ namespace Usage
switch_details();
else
{
var dialog = new ProcessDialog(pid);
var dialog = new ProcessDialog(pid, cmdline);
dialog.show_all ();
}
......@@ -62,13 +62,13 @@ namespace Usage
event_box.enter_notify_event.connect ((event) => {
in_box = true;
style();
style_css();
return false;
});
event_box.leave_notify_event.connect ((event) => {
in_box = false;
style();
style_css();
return false;
});
......@@ -96,7 +96,7 @@ namespace Usage
if(sub_process_list_box.get_sub_rows_count() == 1)
{
group = false;
name = sub_process_list_box.get_first_name();
cmdline = sub_process_list_box.get_first_cmdline();
pid = sub_process_list_box.get_first_pid();
set_value(pid, sub_process_list_box.get_first_value());
sub_process_list_box.remove_all();
......@@ -112,16 +112,15 @@ namespace Usage
return sub_process_list_box.is_in_table(pid);
}
public void add_sub_row(pid_t pid, int value, string name)
public void add_sub_row(pid_t pid, int value, string cmdline)
{
alive = true;
if(sub_process_list_box.get_sub_rows_count() == 0)
{
sub_process_list_box.add_sub_row(this.pid, this.value, this.name);
sub_process_list_box.add_sub_row(this.pid, this.value, this.cmdline);
group = true;
}
sub_process_list_box.add_sub_row(pid, value, name);
sub_process_list_box.add_sub_row(pid, value, cmdline);
}
public void update_sub_row(pid_t pid, int value)
......@@ -130,9 +129,9 @@ namespace Usage
sub_process_list_box.update_sub_row(pid, value);
}
public string get_name()
public string get_cmdline()
{
return name;
return cmdline;
}
public bool get_alive()
......@@ -157,7 +156,7 @@ namespace Usage
sub_process_list_box.update_sub_row(pid, value);
else
if(group)
sub_process_list_box.add_sub_row(pid, value, name);
sub_process_list_box.add_sub_row(pid, value, cmdline);
else
{
if(pid == this.pid)
......@@ -196,10 +195,10 @@ namespace Usage
else
max_usage = false;
style();
style_css();
}
private void style()
private void style_css()
{
event_box.get_style_context().remove_class("processRow-max");
event_box.get_style_context().remove_class("processRow-max-hover");
......@@ -233,7 +232,7 @@ namespace Usage
showing_details = false;
revealer.set_reveal_child(false);
load_label.visible = true;
style();
style_css();
}
private void show_details()
......@@ -241,7 +240,7 @@ namespace Usage
showing_details = true;
revealer.set_reveal_child(true);
load_label.visible = false;
style();
style_css();
}
private void switch_details()
......
......@@ -13,9 +13,9 @@ namespace Usage
process_sub_rows_table = new HashTable<pid_t?, SubProcessSubRow>(int_hash, int_equal);
}
public string get_first_name()
public string get_first_cmdline()
{
return process_sub_rows_table.get_values().nth_data(0).get_name();
return process_sub_rows_table.get_values().nth_data(0).get_cmdline();
}
public pid_t get_first_pid()
......@@ -64,9 +64,9 @@ namespace Usage
this.add(sub_row);
}
public void add_sub_row(pid_t pid, int value, string name)
public void add_sub_row(pid_t pid, int value, string cmdline)
{
SubProcessSubRow sub_row = new SubProcessSubRow((int) pid, value, name);
SubProcessSubRow sub_row = new SubProcessSubRow((int) pid, value, cmdline);
process_sub_rows_table.insert ((int) pid, (owned) sub_row);
}
......
......@@ -11,22 +11,22 @@ namespace Usage
bool in_box = false;
pid_t pid;
int value;
string name;
string cmdline;
bool alive = true;
//public bool is_headline { get; private set; }
public bool max_usage { get; private set; }
public SubProcessSubRow(pid_t pid, int value, string name)
public SubProcessSubRow(pid_t pid, int value, string cmdline)
{
this.name = name;
this.cmdline = cmdline;
this.pid = pid;
this.margin = 0;
this.orientation = Gtk.Orientation.VERTICAL;
var main_box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
main_box.margin = 12;
title_label = new Gtk.Label(name);
title_label = new Gtk.Label(cmdline);
load_label = new Gtk.Label(null);
//load_label.ellipsize = Pango.EllipsizeMode.END;
icon = new Gtk.Image.from_icon_name("system-run-symbolic", Gtk.IconSize.BUTTON);
......@@ -39,20 +39,20 @@ namespace Usage
event_box.add(main_box);
event_box.button_press_event.connect ((event) => {
var dialog = new ProcessDialog(pid);
var dialog = new ProcessDialog(pid, cmdline);
dialog.show_all ();
return false;
});
event_box.enter_notify_event.connect ((event) => {
in_box = true;
style();
style_css();
return false;
});
event_box.leave_notify_event.connect ((event) => {
in_box = false;
style();
style_css();
return false;
});
......@@ -66,9 +66,9 @@ namespace Usage
show_all();
}
public string get_name()
public string get_cmdline()
{
return name;
return cmdline;
}
public pid_t get_pid()
......@@ -105,10 +105,10 @@ namespace Usage
max_usage = false;
load_label.set_label(value.to_string() + " %");
style();
style_css();
}
private void style()
private void style_css()
{
event_box.get_style_context().remove_class("subProcessSubRow-max");
event_box.get_style_context().remove_class("subProcessSubRow-max-hover");
......
......@@ -149,7 +149,6 @@ namespace Usage
process.pid = pids[i];
process.alive = true;
process.cmdline = get_full_process_cmd ((string) proc_state.cmd, arguments);
process.cpu_load = 0;
process.cpu_last_used = proc_time.rtime;
process.mem_usage = 0;
......
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