summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-05-16 03:58:16 +0200
committerLennart Poettering <lennart@poettering.net>2010-05-16 03:58:16 +0200
commitdd28669fc734941fffbba233ed69243a36daa0ac (patch)
tree93b30bf59ba1e82e50579e83b9d9a464b201ab2d
parent37a8e6831650bdf6439038d802775b182fa599e7 (diff)
systemadm: update UI when jobs/units change
-rw-r--r--systemadm.vala93
1 files changed, 81 insertions, 12 deletions
diff --git a/systemadm.vala b/systemadm.vala
index 92ee503b11..6ea464f58d 100644
--- a/systemadm.vala
+++ b/systemadm.vala
@@ -297,6 +297,8 @@ public class MainWindow : Window {
i.unit_path,
"org.freedesktop.systemd1.Unit") as Unit;
+ u.changed += on_unit_changed;
+
unit_model.append(out iter);
unit_model.set(iter,
0, i.id,
@@ -322,6 +324,8 @@ public class MainWindow : Window {
i.job_path,
"org.freedesktop.systemd1.Job") as Job;
+ j.changed += on_job_changed;
+
job_model.append(out iter);
job_model.set(iter,
0, "%u".printf(i.id),
@@ -542,11 +546,7 @@ public class MainWindow : Window {
}
}
- public void on_unit_new(string id, ObjectPath path) {
- Unit u = bus.get_object(
- "org.freedesktop.systemd1",
- path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ public void update_unit_iter(TreeIter iter, string id, Unit u) {
string t = "";
Unit.JobLink jl = u.job;
@@ -560,8 +560,6 @@ public class MainWindow : Window {
t = j.job_type;
}
- TreeIter iter;
- unit_model.append(out iter);
unit_model.set(iter,
0, id,
1, u.description,
@@ -572,16 +570,22 @@ public class MainWindow : Window {
6, u);
}
- public void on_job_new(uint32 id, ObjectPath path) {
- Job j = bus.get_object(
+ public void on_unit_new(string id, ObjectPath path) {
+ Unit u = bus.get_object(
"org.freedesktop.systemd1",
path,
- "org.freedesktop.systemd1.Job") as Job;
+ "org.freedesktop.systemd1.Unit") as Unit;
+
+ u.changed += on_unit_changed;
TreeIter iter;
- job_model.append(out iter);
+ unit_model.append(out iter);
+ update_unit_iter(iter, id, u);
+ }
+
+ public void update_job_iter(TreeIter iter, uint32 id, Job j) {
job_model.set(iter,
- 0, "%u".printf(j.id),
+ 0, "%u".printf(id),
1, j.unit.id,
2, "→ %s".printf(j.job_type),
3, j.state,
@@ -589,6 +593,19 @@ public class MainWindow : Window {
5, id);
}
+ public void on_job_new(uint32 id, ObjectPath path) {
+ Job j = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Job") as Job;
+
+ j.changed += on_job_changed;
+
+ TreeIter iter;
+ job_model.append(out iter);
+ update_job_iter(iter, id, j);
+ }
+
public void on_unit_removed(string id, ObjectPath path) {
TreeIter iter;
if (!(unit_model.get_iter_first(out iter)))
@@ -632,6 +649,58 @@ public class MainWindow : Window {
} while (job_model.iter_next(ref iter));
}
+ public void on_unit_changed(Unit u) {
+ TreeIter iter;
+ string id;
+
+ if (!(unit_model.get_iter_first(out iter)))
+ return;
+
+ id = u.id;
+
+ do {
+ string name;
+
+ unit_model.get(iter, 0, out name);
+
+ if (id == name) {
+ update_unit_iter(iter, id, u);
+
+ if (current_unit_id == id)
+ show_unit(u);
+
+ break;
+ }
+
+ } while (unit_model.iter_next(ref iter));
+ }
+
+ public void on_job_changed(Job j) {
+ TreeIter iter;
+ uint32 id;
+
+ if (!(job_model.get_iter_first(out iter)))
+ return;
+
+ id = j.id;
+
+ do {
+ uint32 k;
+
+ job_model.get(iter, 5, out k);
+
+ if (id == k) {
+ update_job_iter(iter, id, j);
+
+ if (current_job_id == id)
+ show_job(j);
+
+ break;
+ }
+
+ } while (job_model.iter_next(ref iter));
+ }
+
public bool unit_filter(TreeModel model, TreeIter iter) {
string id, active_state, job;