systemadm: update UI when jobs/units change
This commit is contained in:
parent
37a8e68316
commit
dd28669fc7
|
@ -297,6 +297,8 @@ public class MainWindow : Window {
|
||||||
i.unit_path,
|
i.unit_path,
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
"org.freedesktop.systemd1.Unit") as Unit;
|
||||||
|
|
||||||
|
u.changed += on_unit_changed;
|
||||||
|
|
||||||
unit_model.append(out iter);
|
unit_model.append(out iter);
|
||||||
unit_model.set(iter,
|
unit_model.set(iter,
|
||||||
0, i.id,
|
0, i.id,
|
||||||
|
@ -322,6 +324,8 @@ public class MainWindow : Window {
|
||||||
i.job_path,
|
i.job_path,
|
||||||
"org.freedesktop.systemd1.Job") as Job;
|
"org.freedesktop.systemd1.Job") as Job;
|
||||||
|
|
||||||
|
j.changed += on_job_changed;
|
||||||
|
|
||||||
job_model.append(out iter);
|
job_model.append(out iter);
|
||||||
job_model.set(iter,
|
job_model.set(iter,
|
||||||
0, "%u".printf(i.id),
|
0, "%u".printf(i.id),
|
||||||
|
@ -542,11 +546,7 @@ public class MainWindow : Window {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_unit_new(string id, ObjectPath path) {
|
public void update_unit_iter(TreeIter iter, string id, Unit u) {
|
||||||
Unit u = bus.get_object(
|
|
||||||
"org.freedesktop.systemd1",
|
|
||||||
path,
|
|
||||||
"org.freedesktop.systemd1.Unit") as Unit;
|
|
||||||
|
|
||||||
string t = "";
|
string t = "";
|
||||||
Unit.JobLink jl = u.job;
|
Unit.JobLink jl = u.job;
|
||||||
|
@ -560,8 +560,6 @@ public class MainWindow : Window {
|
||||||
t = j.job_type;
|
t = j.job_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
TreeIter iter;
|
|
||||||
unit_model.append(out iter);
|
|
||||||
unit_model.set(iter,
|
unit_model.set(iter,
|
||||||
0, id,
|
0, id,
|
||||||
1, u.description,
|
1, u.description,
|
||||||
|
@ -572,21 +570,40 @@ public class MainWindow : Window {
|
||||||
6, u);
|
6, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void on_unit_new(string id, ObjectPath path) {
|
||||||
|
Unit u = bus.get_object(
|
||||||
|
"org.freedesktop.systemd1",
|
||||||
|
path,
|
||||||
|
"org.freedesktop.systemd1.Unit") as Unit;
|
||||||
|
|
||||||
|
u.changed += on_unit_changed;
|
||||||
|
|
||||||
|
TreeIter 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(id),
|
||||||
|
1, j.unit.id,
|
||||||
|
2, "→ %s".printf(j.job_type),
|
||||||
|
3, j.state,
|
||||||
|
4, j,
|
||||||
|
5, id);
|
||||||
|
}
|
||||||
|
|
||||||
public void on_job_new(uint32 id, ObjectPath path) {
|
public void on_job_new(uint32 id, ObjectPath path) {
|
||||||
Job j = bus.get_object(
|
Job j = bus.get_object(
|
||||||
"org.freedesktop.systemd1",
|
"org.freedesktop.systemd1",
|
||||||
path,
|
path,
|
||||||
"org.freedesktop.systemd1.Job") as Job;
|
"org.freedesktop.systemd1.Job") as Job;
|
||||||
|
|
||||||
|
j.changed += on_job_changed;
|
||||||
|
|
||||||
TreeIter iter;
|
TreeIter iter;
|
||||||
job_model.append(out iter);
|
job_model.append(out iter);
|
||||||
job_model.set(iter,
|
update_job_iter(iter, id, j);
|
||||||
0, "%u".printf(j.id),
|
|
||||||
1, j.unit.id,
|
|
||||||
2, "→ %s".printf(j.job_type),
|
|
||||||
3, j.state,
|
|
||||||
4, j,
|
|
||||||
5, id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void on_unit_removed(string id, ObjectPath path) {
|
public void on_unit_removed(string id, ObjectPath path) {
|
||||||
|
@ -632,6 +649,58 @@ public class MainWindow : Window {
|
||||||
} while (job_model.iter_next(ref iter));
|
} 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) {
|
public bool unit_filter(TreeModel model, TreeIter iter) {
|
||||||
string id, active_state, job;
|
string id, active_state, job;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue