Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public class Monitor.MainWindow : Gtk.ApplicationWindow {
search_revealer.reveal_child = stack.visible_child == process_view;
});

new Thread<void> ("upd", () => {
Timeout.add_seconds (MonitorApp.settings.get_int ("update-time"), () => {
process_view.update ();
var process_manager = ProcessManager.get_default ();

Timeout.add_seconds (MonitorApp.settings.get_int ("update-time"), () => {
process_manager.update ();
Idle.add (() => {
system_view.update ();
dbusserver.indicator_state (MonitorApp.settings.get_boolean ("indicator-state"));
Expand All @@ -103,8 +103,7 @@ public class Monitor.MainWindow : Gtk.ApplicationWindow {
dbusserver.update (res);
return false;
});
return true;
});
return true;
});

dbusserver.indicator_state (MonitorApp.settings.get_boolean ("indicator-state"));
Expand Down
18 changes: 15 additions & 3 deletions src/Managers/ProcessManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

namespace Monitor {
public class ProcessManager {
public class ProcessManager : GLib.Object {
private static GLib.Once<ProcessManager> instance;
public static unowned ProcessManager get_default () {
return instance.once (() => { return new ProcessManager (); });
Expand Down Expand Up @@ -33,7 +33,7 @@ namespace Monitor {
apps_info_list = new Gee.HashMap<string, AppInfo> ();

populate_apps_info ();
update_processes.begin ();
update ();
}

public void populate_apps_info () {
Expand Down Expand Up @@ -102,7 +102,7 @@ namespace Monitor {
/**
* Gets all new process and adds them
*/
public async void update_processes () {
public void update_processes () {
/* CPU */
GTop.Cpu cpu_data;
GTop.get_cpu (out cpu_data);
Expand Down Expand Up @@ -158,6 +158,18 @@ namespace Monitor {

}

public void update () {
new Thread<bool> ("update-processes", () => {
Idle.add (() => {
update_processes ();
return false;
});
return true;
});
/* emit the updated signal so that subscribers can update */
updated ();
}

/** Sets name and icon for a process that is a Flatpak app and its children. */
private void set_flatpak_name_icon (Process process, GLib.Icon icon, string name) {
process.application_name = name;
Expand Down
15 changes: 2 additions & 13 deletions src/Views/ProcessView/ProcessView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class Monitor.ProcessView : Granite.Bin {
visible = false,
};

treeview_model.process_manager.updated.connect (process_info_view.update);

var paned = new Gtk.Paned (HORIZONTAL) {
start_child = process_tree_view,
end_child = process_info_view,
Expand Down Expand Up @@ -132,17 +134,4 @@ public class Monitor.ProcessView : Granite.Bin {
kill_action.set_enabled (process.uid == Posix.getuid ());
}

public void update () {
new Thread<bool> ("update-processes", () => {
Idle.add (() => {
process_info_view.update ();
treeview_model.process_manager.update_processes.begin ();

return false;
});
return true;
});

}

}
Loading