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

Fixed graph "laging" in right.

Process name in ProcessDialog have max width 15chars.
ProcesListBox, SubprocesListBox have fixed public methods.
Fix sorting process by ram and cpu usage in row.
parent ebd8804d
......@@ -5,8 +5,8 @@ New GNOME Usage!
## Actual TODO:
- [x] Processor Usage
- [x] Memory usage
- [ ] Disk usage (What library we can use?)
- [ ] Network usage [#1](http://github.com/petr-stety-stetka/gnome-usage/issues/1)
- [ ] Disk usage (What library we can use?)
- [ ] Thumbnails of of graphs corresponding to design
- [ ] Data view
- [ ] Storage view
......@@ -24,7 +24,7 @@ sudo make install
In terminal run ```gnome-usage``` command or run GNOME Usage application from app launcher.
##Version
Actual version is 0.2.3
Actual version is 0.2.4
##License
Code is under GNU GPLv3 license.
......
No preview for this file type
......@@ -175,7 +175,7 @@ rg_graph_ensure_surface (RgGraph *self)
priv->surface_dirty = TRUE;
priv->surface = gdk_window_create_similar_surface (gtk_widget_get_window (GTK_WIDGET (self)),
CAIRO_CONTENT_COLOR_ALPHA,
alloc.width,
alloc.width+(alloc.width/14), // + (alloc.width/14) is fix or hack for lagging graph in right
alloc.height);
}
......@@ -189,7 +189,7 @@ rg_graph_ensure_surface (RgGraph *self)
cr = cairo_create (priv->surface);
cairo_save (cr);
cairo_rectangle (cr, 0, 0, alloc.width, alloc.height);
cairo_rectangle (cr, 0, 0, alloc.width + (alloc.width/14), alloc.height); // + (alloc.width/14) is fix or hack for lagging graph in right
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_fill (cr);
cairo_restore (cr);
......@@ -210,7 +210,12 @@ rg_graph_ensure_surface (RgGraph *self)
renderer = g_ptr_array_index (priv->renderers, i);
cairo_save (cr);
rg_renderer_render (renderer, priv->table, begin_time, end_time, y_begin, y_end, cr, &alloc);
GtkAllocation surface_alloc;
surface_alloc.x = alloc.x;
surface_alloc.y = alloc.y;
surface_alloc.width = alloc.width+(alloc.width/14); // + (alloc.width/14) is fix or hack for lagging graph in right
surface_alloc.height = alloc.height;
rg_renderer_render (renderer, priv->table, begin_time, end_time, y_begin, y_end, cr, &surface_alloc);
cairo_restore (cr);
}
......
......@@ -5,7 +5,7 @@ project_name: gnome-usage
vala_binary: src/gnome-usage
*version: 0.2.3
*version: 0.2.4
*vala_vapi: vapis/better.vapi
*vala_vapi: vapis/egg.vapi
*vala_vapi: vapis/glibtop.vapi
......@@ -148,24 +148,24 @@ translate: c src/../external/rg/rg-table.c
*translate: vala src/process-dialog.vala
*translate: vala src/system-monitor.vala
*translate: vala src/graph-block.vala
*translate: vala src/process-list-box.vala
*translate: vala src/process-row.vala
*translate: vala src/network-sub-view.vala
*translate: vala src/memory-graph-table.vala
*translate: vala src/performance-view.vala
*translate: vala src/gnome-usage.vala
*translate: vala src/process-list-box.vala
*translate: vala src/memory-sub-view.vala
*translate: vala src/graph-box.vala
*translate: vala src/view.vala
*translate: vala src/disk-sub-view.vala
*translate: vala src/sub-process-list-box.vala
*translate: vala src/sub-process-sub-row.vala
*translate: vala src/cpu-graph.vala
*translate: vala src/window.vala
*translate: vala src/sub-process-sub-row.vala
*translate: vala src/sub-process-list-box.vala
*translate: vala src/color-rectangle.vala
*translate: vala src/graph-stack-switcher.vala
*translate: vala src/storage-view.vala
*translate: vala src/process-row.vala
*translate: vala src/settings.vala
*translate: vala src/gnome-usage.vala
*translate: vala src/power-view.vala
*translate: vala src/cpu-sub-view.vala
*translate: vala src/graph-block-row.vala
......
......@@ -7,13 +7,13 @@ set (GETTEXT_PACKAGE "gnome-usage")
set (RELEASE_NAME "gnome-usage")
set (CMAKE_C_FLAGS "")
set (PREFIX ${CMAKE_INSTALL_PREFIX})
set (VERSION "0.2.3")
set (VERSION "0.2.4")
set (TESTSRCDIR "${CMAKE_SOURCE_DIR}")
set (DOLLAR "$")
configure_file (${CMAKE_SOURCE_DIR}/src/Config.vala.cmake ${CMAKE_BINARY_DIR}/src/Config.vala)
add_definitions(-DGETTEXT_PACKAGE=\"${GETTEXT_PACKAGE}\")
set (VERSION "0.2.3")
set (VERSION "0.2.4")
add_definitions (${DEPS_CFLAGS})
link_libraries ( ${DEPS_LIBRARIES} )
link_directories ( ${DEPS_LIBRARY_DIRS} )
......
// project version=0.2.3
// project version=0.2.4
public static int main (string[] args)
{
......
......@@ -12,6 +12,8 @@ namespace Usage {
var color_rectangle = new ColorRectangle(css_class);
var label = new Gtk.Label(label_text);
label.margin = 5;
label.ellipsize = Pango.EllipsizeMode.END;
label.max_width_chars = 15;
value_label = new Gtk.Label("0 %");
this.pack_start(color_rectangle, false, false);
this.pack_start(label, false, true, 5);
......
......@@ -50,7 +50,7 @@ namespace Usage
});
}
public bool update()
private bool update()
{
model.remove_all();
......@@ -70,7 +70,7 @@ namespace Usage
return true;
}
public Gtk.Widget on_row_created (Object item)
private Gtk.Widget on_row_created (Object item)
{
Process process = (Process) item;
bool opened = false;
......@@ -90,8 +90,8 @@ namespace Usage
return row;
}
void update_header(Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row)
{
private void update_header(Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row)
{
if(before_row == null)
row.set_header(null);
else
......@@ -101,9 +101,9 @@ namespace Usage
separator.show();
row.set_header(separator);
}
}
}
public int sort(GLib.CompareDataFunc.G a, GLib.CompareDataFunc.G b)
private int sort(GLib.CompareDataFunc.G a, GLib.CompareDataFunc.G b)
{
switch(type)
{
......
......@@ -59,7 +59,7 @@ namespace Usage
show_details();
}
public Gtk.Widget on_subrow_created (Object item)
private Gtk.Widget on_subrow_created (Object item)
{
Process process = (Process) item;
var row = new SubProcessSubRow(process, type);
......@@ -123,16 +123,24 @@ namespace Usage
private void update()
{
CompareFunc<int> sort = (a, b) => {
return (int) (a < b) - (int) (a > b);
};
switch(type)
{
case ProcessListBoxType.PROCESSOR:
if(process.sub_processes != null)
{
string values = "";
string values_string = "";
var values = new GLib.List<int>();
foreach(Process sub_process in process.sub_processes.get_values())
values += " " + ((int) sub_process.cpu_load).to_string() + " %";
values.insert_sorted((int) sub_process.cpu_load, sort);
foreach(int value in values)
values_string += " " + value.to_string() + " %";
load_label.set_label(values);
load_label.set_label(values_string);
}
else
load_label.set_label(((int) process.cpu_load).to_string() + " %");
......@@ -145,11 +153,15 @@ namespace Usage
case ProcessListBoxType.MEMORY:
if(process.sub_processes != null)
{
string values = "";
string values_string = "";
var values = new GLib.List<int>();
foreach(Process sub_process in process.sub_processes.get_values())
values += " " + ((int) sub_process.mem_usage).to_string() + " MB";
values.insert_sorted((int) sub_process.mem_usage, sort);
foreach(int value in values)
values_string += " " + value.to_string() + " MB";
load_label.set_label(values);
load_label.set_label(values_string);
}
else
load_label.set_label(((int) process.mem_usage).to_string() + " MB");
......
......@@ -32,7 +32,7 @@ namespace Usage
update();
}
public void update()
private void update()
{
if(parent_process.sub_processes != null)
{
......@@ -43,14 +43,14 @@ namespace Usage
}
}
public Gtk.Widget on_row_created (Object item)
private Gtk.Widget on_row_created (Object item)
{
Process process = (Process) item;
var row = new SubProcessSubRow(process, type);
return row;
}
void update_header(Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row)
private void update_header(Gtk.ListBoxRow row, Gtk.ListBoxRow? before_row)
{
if(before_row == null)
row.set_header(null);
......@@ -63,7 +63,7 @@ namespace Usage
}
}
public int sort(GLib.CompareDataFunc.G a, GLib.CompareDataFunc.G b)
private int sort(GLib.CompareDataFunc.G a, GLib.CompareDataFunc.G b)
{
switch(type)
{
......
......@@ -378,16 +378,20 @@ namespace Usage
}
else
{
int max_value = 0;
int max_cpu_load = 0;
int mem_usage = 0;
foreach(unowned Process sub_process in process.sub_processes.get_values())
{
if (sub_process.alive == false)
process.sub_processes.remove(sub_process.pid);
if(sub_process.cpu_load > max_value)
max_value = (int) sub_process.cpu_load;
if(sub_process.cpu_load > max_cpu_load)
max_cpu_load = (int) sub_process.cpu_load;
mem_usage += (int) sub_process.mem_usage;
}
process.cpu_load = max_value;
process.cpu_load = max_cpu_load;
process.mem_usage = mem_usage;
if(process.sub_processes.size() == 1) //tranform to process
{
......
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