Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Librem5
gnome-usage
Commits
1da281f5
Commit
1da281f5
authored
Oct 19, 2016
by
Petr Štětka
Browse files
Added basic RAM graph.
Updated screenshot.
parent
6115f754
Changes
14
Hide whitespace changes
Inline
Side-by-side
gnome-usage.avprj
View file @
1da281f5
### AutoVala Project ###
autovala_version: 23
project_name: gnome-usage
*vala_version: 0.3
2
*vala_version: 0.3
4
vala_binary: src/gnome-usage
...
...
@@ -31,6 +31,8 @@ c_library: gtop-2.0 ${CMAKE_SOURCE_DIR}/external/rg/librg.a ${CMAKE_SOURCE_DIR}/
*vala_source: graph-stack-switcher.vala
*vala_source: graph-switcher-button.vala
*vala_source: header-bar.vala
*vala_source: memory-graph-table.vala
*vala_source: memory-graph.vala
*vala_source: memory-sub-view.vala
*vala_source: network-sub-view.vala
*vala_source: performance-view.vala
...
...
@@ -46,23 +48,25 @@ h_folder: /usr/include/libgtop-2.0
*po: po
*translate: vala src/cpu-
graph-table
.vala
*translate: vala src/cpu-
sub-view
.vala
*translate: vala src/system-monitor.vala
*translate: vala src/memory-sub-view.vala
*translate: vala src/network-sub-view.vala
*translate: vala src/process-list.vala
*translate: vala src/header-bar.vala
*translate: vala src/
dis
k-sub-view.vala
*translate: vala src/graph
-switcher-button
.vala
*translate: vala src/
networ
k-sub-view.vala
*translate: vala src/
cpu-
graph.vala
*translate: vala src/performance-view.vala
*translate: vala src/graph-stack-switcher.vala
*translate: vala src/gnome-usage.vala
*translate: vala src/view.vala
*translate: vala src/cpu-sub-view.vala
*translate: vala src/window.vala
*translate: vala src/cpu-graph.vala
*translate: vala src/view.vala
*translate: vala src/memory-graph-table.vala
*translate: vala src/disk-sub-view.vala
*translate: vala src/graph-switcher-button.vala
*translate: vala src/memory-sub-view.vala
*translate: vala src/cpu-graph-table.vala
*translate: vala src/memory-graph.vala
*translate: vala src/storage-view.vala
*translate: vala src/power-view.vala
*translate: vala src/process-list.vala
*translate: vala src/application.vala
*translate: vala src/data-view.vala
...
...
po/POTFILES.in
View file @
1da281f5
...
...
@@ -8,6 +8,8 @@ src/gnome-usage.vala
src/graph-stack-switcher.vala
src/graph-switcher-button.vala
src/header-bar.vala
src/memory-graph-table.vala
src/memory-graph.vala
src/memory-sub-view.vala
src/network-sub-view.vala
src/performance-view.vala
...
...
screenshot.png
View replaced file @
6115f754
View file @
1da281f5
90.7 KB
|
W:
|
H:
96.3 KB
|
W:
|
H:
2-up
Swipe
Onion skin
src/CMakeLists.txt
View file @
1da281f5
...
...
@@ -19,7 +19,7 @@ link_libraries ( ${DEPS_LIBRARIES} )
link_directories
(
${
DEPS_LIBRARY_DIRS
}
)
find_package
(
Vala REQUIRED
)
include
(
ValaVersion
)
ensure_vala_version
(
"0.3
2
"
MINIMUM
)
ensure_vala_version
(
"0.3
4
"
MINIMUM
)
include
(
ValaPrecompile
)
set
(
VALA_PACKAGES
${
VALA_PACKAGES
}
posix
)
...
...
@@ -45,6 +45,8 @@ set (APP_SOURCES ${APP_SOURCES} gnome-usage.vala)
set
(
APP_SOURCES
${
APP_SOURCES
}
graph-stack-switcher.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
graph-switcher-button.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
header-bar.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
memory-graph-table.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
memory-graph.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
memory-sub-view.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
network-sub-view.vala
)
set
(
APP_SOURCES
${
APP_SOURCES
}
performance-view.vala
)
...
...
src/cpu-graph-table.vala
View file @
1da281f5
...
...
@@ -51,56 +51,4 @@ namespace Usage {
return
true
;
}
}
public
class
CpuGraphTableSingle
:
Rg
.
Table
{
public
CpuGraphTableSingle
(
uint
timespan
,
uint
max_samples
)
{
set_timespan
(
timespan
*
1000
);
set_max_samples
(
max_samples
);
var
column
=
new
Rg
.
Column
(
"TOTAL CPU"
,
Type
.
from_name
(
"gdouble"
));
add_column
(
column
);
Timeout
.
add
(
timespan
/
(
max_samples
-
1
),
update_data
);
}
bool
update_data
()
{
Rg
.
TableIter
iter
;
push
(
out
iter
,
get_monotonic_time
());
iter
.
set
(
0
,
(
GLib
.
Application
.
get_default
()
as
Application
).
monitor
.
cpu_load_graph
,
-
1
);
return
true
;
}
}
public
class
CpuGraphTableMulti
:
Rg
.
Table
{
public
CpuGraphTableMulti
(
uint
timespan
,
uint
max_samples
)
{
set_timespan
(
timespan
*
1000
);
set_max_samples
(
max_samples
);
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
);
}
(
GLib
.
Application
.
get_default
()
as
Application
).
monitor
.
set_update_graph_interval
(
timespan
/
(
max_samples
-
1
));
Timeout
.
add
(
timespan
/
(
max_samples
-
1
),
update_data
);
}
bool
update_data
()
{
Rg
.
TableIter
iter
;
push
(
out
iter
,
get_monotonic_time
());
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
);
return
true
;
}
}
}
src/cpu-sub-view.vala
View file @
1da281f5
using
Rg
;
namespace
Usage
{
public
class
ProcessorSubView
:
View
...
...
@@ -55,7 +53,8 @@ namespace Usage
Timeout
.
add
(
1000
,
update_process
);
}
public
bool
update_process
()
//TODO better management
private
bool
update_process
()
{
process_list_box
.
foreach
((
widget
)
=>
{
widget
.
destroy
();
});
cpu_load_label
.
set_text
(((
int
)
monitor
.
cpu_load
).
to_string
()
+
" %"
);
...
...
@@ -78,7 +77,7 @@ namespace Usage
return
true
;
}
p
ublic
void
insert_process_row
(
Process
process
)
p
rivate
void
insert_process_row
(
Process
process
)
{
var
process_row
=
new
ProcessRow
(
process
.
cmdline
,(
int
)
process
.
cpu_load
);
process_row
.
sort_id
=(
int
)(
10
*
process
.
cpu_load
);
...
...
@@ -90,7 +89,7 @@ namespace Usage
private
void
construct_menu_button
()
{
var
popover_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
popover_box
.
margin
=
5
;
popover_box
.
margin
=
7
;
var
active
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
null
,
_
(
"Active process"
));
popover_box
.
pack_start
(
active
,
false
,
false
,
0
);
...
...
src/disk-sub-view.vala
View file @
1da281f5
...
...
@@ -2,119 +2,14 @@ namespace Usage
{
public
class
DiskSubView
:
View
{
ProcessList
process_list_box
;
Gtk
.
Label
cpu_load_label
;
List
<
ProcessRow
>
process_row_list
;
bool
show_active_process
=
true
;
public
DiskSubView
()
{
name
=
"DISK"
;
cpu_load_label
=
new
Gtk
.
Label
(
null
);
cpu_load_label
.
margin_right
=
100
;
var
processor_label
=
new
Gtk
.
Label
(
"<b>"
+
_
(
"Disk I/O"
)
+
"</b>"
);
processor_label
.
set_use_markup
(
true
);
var
processor_text_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
HORIZONTAL
,
0
);
processor_text_box
.
set_center_widget
(
processor_label
);
processor_text_box
.
pack_end
(
cpu_load_label
,
false
,
true
,
0
);
processor_text_box
.
margin_top
=
20
;
process_list_box
=
new
ProcessList
();
var
cpu_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
var
process_list_box_frame
=
new
Gtk
.
Frame
(
null
);
process_list_box_frame
.
margin_start
=
100
;
process_list_box_frame
.
margin_end
=
100
;
process_list_box_frame
.
margin_bottom
=
20
;
process_list_box_frame
.
add
(
process_list_box
);
cpu_box
.
pack_start
(
processor_text_box
,
false
,
false
,
0
);
cpu_box
.
pack_start
(
process_list_box_frame
,
true
,
false
,
0
);
var
scrolled_window
=
new
Gtk
.
ScrolledWindow
(
null
,
null
);
scrolled_window
.
add
(
cpu_box
);
scrolled_window
.
set_policy
(
Gtk
.
PolicyType
.
AUTOMATIC
,
Gtk
.
PolicyType
.
AUTOMATIC
);
//construct_menu_button();
add
(
scrolled_window
);
Timeout
.
add
(
1000
,
update_process
);
}
public
bool
update_process
()
{
process_list_box
.
foreach
((
widget
)
=>
{
widget
.
destroy
();
});
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
);
}
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
;
}
return
true
;
}
public
void
insert_process_row
(
Process
process
)
{
var
process_row
=
new
ProcessRow
(
process
.
cmdline
,(
int
)
process
.
cpu_load
);
process_row
.
sort_id
=(
int
)(
10
*
process
.
cpu_load
);
process_row_list
.
insert_sorted
(
process_row
,(
a
,
b
)
=>
{
return
(
b
as
ProcessRow
).
sort_id
-(
a
as
ProcessRow
).
sort_id
;
});
}
private
void
construct_menu_button
()
{
var
popover_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
popover_box
.
margin
=
5
;
var
active
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
null
,
_
(
"Active process"
));
popover_box
.
pack_start
(
active
,
false
,
false
,
0
);
active
.
toggled
.
connect
(()
=>
{
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
ALL
);
show_active_process
=
true
;
update_process
();
});
var
all
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
active
,
_
(
"All process"
));
popover_box
.
pack_start
(
all
,
false
,
false
,
0
);
all
.
toggled
.
connect
(()
=>
{
show_active_process
=
false
;
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
ALL
);
monitor
.
update_data
();
update_process
();
});
var
my
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
active
,
_
(
"My process"
));
popover_box
.
pack_start
(
my
,
false
,
false
,
0
);
my
.
toggled
.
connect
(()
=>
{
show_active_process
=
false
;
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
USER
);
monitor
.
update_data
();
update_process
();
});
popover_box
.
show_all
();
header_bar
.
set_menu_button
(
popover_box
);
}
public
override
void
update_header_bar
()
{
header_bar
.
clear
();
//headerBar.showMenuButton();
header_bar
.
show_stack_switcher
();
}
}
...
...
src/graph-switcher-button.vala
View file @
1da281f5
...
...
@@ -11,7 +11,7 @@ namespace Usage
public
GraphSwitcherButton
.
memory
(
string
label
)
{
Rg
.
Graph
memory_graph
=
new
CpuGraphSingle
(
60000
,
60
);
Rg
.
Graph
memory_graph
=
new
MemoryGraph
(
60000
,
60
);
child
=
createContent
(
memory_graph
,
label
);
relief
=
Gtk
.
ReliefStyle
.
NONE
;
}
...
...
src/memory-graph-table.vala
0 → 100644
View file @
1da281f5
using
Rg
;
namespace
Usage
{
public
class
MemoryGraphTable
:
Rg
.
Table
{
public
MemoryGraphTable
(
uint
timespan
,
uint
max_samples
)
{
set_timespan
(
timespan
*
1000
);
set_max_samples
(
max_samples
);
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
());
iter
.
set
(
0
,
(
GLib
.
Application
.
get_default
()
as
Application
).
monitor
.
mem_usage_graph
,
-
1
);
return
true
;
}
}
}
src/memory-graph.vala
0 → 100644
View file @
1da281f5
using
Rg
;
namespace
Usage
{
public
class
MemoryGraph
:
Rg
.
Graph
{
private
static
MemoryGraphTable
table
;
public
MemoryGraph
(
uint
timespan
,
uint
max_samples
)
{
if
(
table
==
null
)
{
table
=
new
MemoryGraphTable
(
timespan
,
max_samples
);
set_table
(
table
);
}
else
set_table
(
table
);
LineRenderer
renderer
=
new
LineRenderer
();
renderer
.
stroke_color
=
"#ef2929"
;
renderer
.
line_width
=
2
;
add_renderer
(
renderer
);
}
}
}
src/memory-sub-view.vala
View file @
1da281f5
...
...
@@ -3,118 +3,82 @@ namespace Usage
public
class
MemorySubView
:
View
{
ProcessList
process_list_box
;
Gtk
.
Label
cpu
_load_label
;
Gtk
.
Label
memory
_load_label
;
List
<
ProcessRow
>
process_row_list
;
bool
show_active_process
=
true
;
public
MemorySubView
()
{
name
=
"MEMORY"
;
const
int
margin_side
=
50
;
cpu
_load_label
=
new
Gtk
.
Label
(
null
);
cpu
_load_label
.
margin_right
=
100
;
memory
_load_label
=
new
Gtk
.
Label
(
null
);
memory
_load_label
.
margin_right
=
margin_side
;
var
processor_label
=
new
Gtk
.
Label
(
"<b>"
+
_
(
"Memory"
)
+
"</b>"
);
processor_label
.
set_use_markup
(
true
);
var
processor_text_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
HORIZONTAL
,
0
);
processor_text_box
.
set_center_widget
(
processor_label
);
processor_text_box
.
pack_end
(
cpu_load_label
,
false
,
true
,
0
);
processor_text_box
.
margin_top
=
20
;
processor_text_box
.
pack_end
(
memory_load_label
,
false
,
true
,
0
);
processor_text_box
.
margin_top
=
10
;
processor_text_box
.
margin_bottom
=
10
;
process_list_box
=
new
ProcessList
();
var
cpu_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
var
memory_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
var
memory_graph
=
new
MemoryGraph
(
60000
,
60
);
var
memory_graph_frame
=
new
Gtk
.
Frame
(
null
);
memory_graph_frame
.
height_request
=
200
;
memory_graph_frame
.
margin_start
=
margin_side
;
memory_graph_frame
.
margin_end
=
margin_side
;
memory_graph_frame
.
margin_bottom
=
10
;
memory_graph_frame
.
add
(
memory_graph
);
var
process_list_box_frame
=
new
Gtk
.
Frame
(
null
);
process_list_box_frame
.
margin_start
=
100
;
process_list_box_frame
.
margin_end
=
100
;
process_list_box_frame
.
margin_start
=
margin_side
;
process_list_box_frame
.
margin_end
=
margin_side
;
process_list_box_frame
.
margin_bottom
=
20
;
process_list_box_frame
.
add
(
process_list_box
);
cpu_box
.
pack_start
(
processor_text_box
,
false
,
false
,
0
);
cpu_box
.
pack_start
(
process_list_box_frame
,
true
,
false
,
0
);
memory_box
.
pack_start
(
processor_text_box
,
false
,
false
,
0
);
memory_box
.
pack_start
(
memory_graph_frame
,
true
,
true
,
0
);
memory_box
.
pack_start
(
process_list_box_frame
,
true
,
false
,
0
);
var
scrolled_window
=
new
Gtk
.
ScrolledWindow
(
null
,
null
);
scrolled_window
.
add
(
cpu
_box
);
scrolled_window
.
add
(
memory
_box
);
scrolled_window
.
set_policy
(
Gtk
.
PolicyType
.
AUTOMATIC
,
Gtk
.
PolicyType
.
AUTOMATIC
);
//construct_menu_button();
add
(
scrolled_window
);
Timeout
.
add
(
1000
,
update_process
);
//
Timeout.add(1000, update_process);
}
p
ublic
bool
update_process
()
p
rivate
bool
update_process
()
{
process_list_box
.
foreach
((
widget
)
=>
{
widget
.
destroy
();
});
cpu
_load_label
.
set_text
(((
int
)
monitor
.
cpu_load
).
to_string
()
+
" %"
);
memory
_load_label
.
set_text
(((
int
)
monitor
.
mem_usage
).
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
())
{
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
;
}
p
ublic
void
insert_process_row
(
Process
process
)
p
rivate
void
insert_process_row
(
Process
process
)
{
var
process_row
=
new
ProcessRow
(
process
.
cmdline
,(
int
)
process
.
cpu_load
);
process_row
.
sort_id
=(
int
)(
10
*
process
.
cpu_load
);
var
process_row
=
new
ProcessRow
(
process
.
cmdline
,(
int
)
process
.
mem_usage
);
process_row
.
sort_id
=(
int
)(
10
*
process
.
mem_usage
);
process_row_list
.
insert_sorted
(
process_row
,(
a
,
b
)
=>
{
return
(
b
as
ProcessRow
).
sort_id
-(
a
as
ProcessRow
).
sort_id
;
});
}
private
void
construct_menu_button
()
{
var
popover_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
popover_box
.
margin
=
5
;
var
active
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
null
,
_
(
"Active process"
));
popover_box
.
pack_start
(
active
,
false
,
false
,
0
);
active
.
toggled
.
connect
(()
=>
{
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
ALL
);
show_active_process
=
true
;
update_process
();
});
var
all
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
active
,
_
(
"All process"
));
popover_box
.
pack_start
(
all
,
false
,
false
,
0
);
all
.
toggled
.
connect
(()
=>
{
show_active_process
=
false
;
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
ALL
);
monitor
.
update_data
();
update_process
();
});
var
my
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
active
,
_
(
"My process"
));
popover_box
.
pack_start
(
my
,
false
,
false
,
0
);
my
.
toggled
.
connect
(()
=>
{
show_active_process
=
false
;
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
USER
);
monitor
.
update_data
();
update_process
();
});
popover_box
.
show_all
();
header_bar
.
set_menu_button
(
popover_box
);
}
public
override
void
update_header_bar
()
{
header_bar
.
clear
();
//headerBar.showMenuButton();
header_bar
.
show_stack_switcher
();
}
}
...
...
src/network-sub-view.vala
View file @
1da281f5
...
...
@@ -2,119 +2,14 @@ namespace Usage
{
public
class
NetworkSubView
:
View
{
ProcessList
process_list_box
;
Gtk
.
Label
cpu_load_label
;
List
<
ProcessRow
>
process_row_list
;
bool
show_active_process
=
true
;
public
NetworkSubView
()
{
name
=
"NETWORK"
;
cpu_load_label
=
new
Gtk
.
Label
(
null
);
cpu_load_label
.
margin_right
=
100
;
var
processor_label
=
new
Gtk
.
Label
(
"<b>"
+
_
(
"Network"
)
+
"</b>"
);
processor_label
.
set_use_markup
(
true
);
var
processor_text_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
HORIZONTAL
,
0
);
processor_text_box
.
set_center_widget
(
processor_label
);
processor_text_box
.
pack_end
(
cpu_load_label
,
false
,
true
,
0
);
processor_text_box
.
margin_top
=
20
;
process_list_box
=
new
ProcessList
();
var
cpu_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
var
process_list_box_frame
=
new
Gtk
.
Frame
(
null
);
process_list_box_frame
.
margin_start
=
100
;
process_list_box_frame
.
margin_end
=
100
;
process_list_box_frame
.
margin_bottom
=
20
;
process_list_box_frame
.
add
(
process_list_box
);
cpu_box
.
pack_start
(
processor_text_box
,
false
,
false
,
0
);
cpu_box
.
pack_start
(
process_list_box_frame
,
true
,
false
,
0
);
var
scrolled_window
=
new
Gtk
.
ScrolledWindow
(
null
,
null
);
scrolled_window
.
add
(
cpu_box
);
scrolled_window
.
set_policy
(
Gtk
.
PolicyType
.
AUTOMATIC
,
Gtk
.
PolicyType
.
AUTOMATIC
);
//construct_menu_button();
add
(
scrolled_window
);
Timeout
.
add
(
1000
,
update_process
);
}
public
bool
update_process
()
{
process_list_box
.
foreach
((
widget
)
=>
{
widget
.
destroy
();
});
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
);
}
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
;
}
return
true
;
}
public
void
insert_process_row
(
Process
process
)
{
var
process_row
=
new
ProcessRow
(
process
.
cmdline
,(
int
)
process
.
cpu_load
);
process_row
.
sort_id
=(
int
)(
10
*
process
.
cpu_load
);
process_row_list
.
insert_sorted
(
process_row
,(
a
,
b
)
=>
{
return
(
b
as
ProcessRow
).
sort_id
-(
a
as
ProcessRow
).
sort_id
;
});
}
private
void
construct_menu_button
()
{
var
popover_box
=
new
Gtk
.
Box
(
Gtk
.
Orientation
.
VERTICAL
,
0
);
popover_box
.
margin
=
5
;
var
active
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
null
,
_
(
"Active process"
));
popover_box
.
pack_start
(
active
,
false
,
false
,
0
);
active
.
toggled
.
connect
(()
=>
{
monitor
.
set_process_mode
(
SystemMonitor
.
ProcessMode
.
ALL
);
show_active_process
=
true
;
update_process
();
});
var
all
=
new
Gtk
.
RadioButton
.
with_label_from_widget
(
active
,
_
(
"All process"
));
popover_box
.
pack_start
(
all
,
false
,
false
,
0
);
all
.
toggled
.