using DBus;
using Pango;
-static bool session = false;
+static bool user = false;
public class LeftLabel : Label {
public LeftLabel(string? text = null) {
private ComboBox unit_type_combo_box;
public MainWindow() throws DBus.Error {
- title = session ? "systemd Session Manager" : "systemd System Manager";
+ title = user ? "systemd User Service Manager" : "systemd System Manager";
position = WindowPosition.CENTER;
set_default_size(1000, 700);
set_border_width(12);
bbox.pack_start(cancel_button, false, true, 0);
- bus = Bus.get(session ? BusType.SESSION : BusType.SYSTEM);
+ bus = DBus.Bus.get(user ? DBus.BusType.SESSION : DBus.BusType.SYSTEM);
manager = bus.get_object(
"org.freedesktop.systemd1",
foreach (var i in list) {
TreeIter iter;
+ Properties p = bus.get_object(
+ "org.freedesktop.systemd1",
+ i.unit_path,
+ "org.freedesktop.DBus.Properties") as Properties;
+
+
+ p.properties_changed.connect(on_unit_changed);
+
Unit u = bus.get_object(
"org.freedesktop.systemd1",
i.unit_path,
"org.freedesktop.systemd1.Unit") as Unit;
- u.changed.connect(on_unit_changed);
-
unit_model.append(out iter);
unit_model.set(iter,
0, i.id,
foreach (var i in list) {
TreeIter iter;
+ Properties p = bus.get_object(
+ "org.freedesktop.systemd1",
+ i.job_path,
+ "org.freedesktop.DBus.Properties") as Properties;
+
+ p.properties_changed.connect(on_job_changed);
+
Job j = bus.get_object(
"org.freedesktop.systemd1",
i.job_path,
"org.freedesktop.systemd1.Job") as Job;
- j.changed.connect(on_job_changed);
-
job_model.append(out iter);
job_model.set(iter,
0, "%u".printf(i.id),
}
public void on_unit_new(string id, ObjectPath path) {
- Unit u = bus.get_object(
+ Properties p = bus.get_object(
"org.freedesktop.systemd1",
path,
- "org.freedesktop.systemd1.Unit") as Unit;
+ "org.freedesktop.DBus.Properties") as Properties;
- u.changed.connect(on_unit_changed);
+ p.properties_changed.connect(on_unit_changed);
TreeIter iter;
unit_model.append(out iter);
+
+ Unit u = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Unit") as Unit;
+
update_unit_iter(iter, id, u);
}
}
public void on_job_new(uint32 id, ObjectPath path) {
- Job j = bus.get_object(
+
+ Properties p = bus.get_object(
"org.freedesktop.systemd1",
path,
- "org.freedesktop.systemd1.Job") as Job;
+ "org.freedesktop.DBus.Properties") as Properties;
- j.changed.connect(on_job_changed);
+ p.properties_changed.connect(on_job_changed);
TreeIter iter;
job_model.append(out iter);
+
+ Job j = bus.get_object(
+ "org.freedesktop.systemd1",
+ path,
+ "org.freedesktop.systemd1.Job") as Job;
+
update_job_iter(iter, id, j);
}
} while (job_model.iter_next(ref iter));
}
- public void on_unit_changed(Unit u) {
+ public void on_unit_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
TreeIter iter;
string id;
+ Unit u = bus.get_object(
+ p.get_bus_name(),
+ p.get_path(),
+ "org.freedesktop.systemd1.Unit") as Unit;
+
if (!(unit_model.get_iter_first(out iter)))
return;
} while (unit_model.iter_next(ref iter));
}
- public void on_job_changed(Job j) {
+ public void on_job_changed(Properties p, string iface, HashTable<string, Value?> changed_properties, string[] invalidated_properties) {
TreeIter iter;
uint32 id;
+ Job j = bus.get_object(
+ p.get_bus_name(),
+ p.get_path(),
+ "org.freedesktop.systemd1.Job") as Job;
+
if (!(job_model.get_iter_first(out iter)))
return;
}
static const OptionEntry entries[] = {
- { "session", 0, 0, OptionArg.NONE, out session, "Connect to session bus", null },
- { "system", 0, OptionFlags.REVERSE, OptionArg.NONE, out session, "Connect to system bus", null },
+ { "user", 0, 0, OptionArg.NONE, out user, "Connect to user service manager", null },
+ { "system", 0, OptionFlags.REVERSE, OptionArg.NONE, out user, "Connect to system manager", null },
{ null }
};
m.destroy();
}
-int main (string[] args) {
+int main(string[] args) {
try {
Gtk.init_with_args(ref args, "[OPTION...]", entries, "systemadm");