Skip to content

Commit c4df8cf

Browse files
committed
ProcessView: reduce object access, build ui in construct
1 parent af684ef commit c4df8cf

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

src/Views/ProcessView/ProcessView.vala

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,39 @@
44
*/
55

66
public class Monitor.ProcessView : Gtk.Box {
7-
public TreeViewModel treeview_model;
8-
public CPUProcessTreeView process_tree_view;
7+
public TreeViewModel treeview_model { get; private set; }
8+
public CPUProcessTreeView process_tree_view { get; private set; }
99

10-
public ProcessInfoView process_info_view;
10+
private ProcessInfoView process_info_view;
1111

1212
construct {
13-
process_info_view = new ProcessInfoView ();
14-
15-
// hide on startup
16-
process_info_view.no_show_all = true;
17-
}
18-
19-
public ProcessView () {
2013
treeview_model = new TreeViewModel ();
2114

2215
process_tree_view = new CPUProcessTreeView (treeview_model);
2316
process_tree_view.process_selected.connect ((process) => on_process_selected (process));
2417

25-
// making tree view scrollable
26-
var process_tree_view_scrolled = new Gtk.ScrolledWindow (null, null);
27-
process_tree_view_scrolled.add (process_tree_view);
18+
var process_tree_view_scrolled = new Gtk.ScrolledWindow (null, null) {
19+
child = process_tree_view
20+
};
2821

29-
var paned = new Gtk.Paned (Gtk.Orientation.HORIZONTAL);
22+
process_info_view = new ProcessInfoView () {
23+
// hide on startup
24+
no_show_all = true
25+
};
26+
27+
var paned = new Gtk.Paned (HORIZONTAL) {
28+
hexpand = true
29+
};
30+
paned.position = paned.max_position;
3031
paned.pack1 (process_tree_view_scrolled, true, false);
3132
paned.pack2 (process_info_view, false, false);
32-
// paned.set_min_position (200);
33-
paned.set_position (paned.max_position);
34-
paned.set_hexpand (true);
3533

3634
add (paned);
3735
}
3836

3937
public void on_process_selected (Process process) {
4038
process_info_view.process = process;
4139
process_info_view.no_show_all = false;
42-
// process_info_view.show_all ();
4340
}
4441

4542
public void update () {
@@ -54,5 +51,4 @@ public class Monitor.ProcessView : Gtk.Box {
5451
});
5552

5653
}
57-
5854
}

0 commit comments

Comments
 (0)