X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=systemadm.vala;h=c5c90b34af23e7090b559feb88d3c4f4c7df16f9;hb=92aa6f363360cbb4e300648e5cbdb6fe4cce1b57;hp=6ea464f58dba461ab3d1d86aa9fbaf6cc8fdc40a;hpb=dd28669fc734941fffbba233ed69243a36daa0ac;p=elogind.git diff --git a/systemadm.vala b/systemadm.vala index 6ea464f58..c5c90b34a 100644 --- a/systemadm.vala +++ b/systemadm.vala @@ -66,6 +66,9 @@ public class MainWindow : Window { private Button reload_button; private Button cancel_button; + private Entry unit_load_entry; + private Button unit_load_button; + private Button server_snapshot_button; private Button server_reload_button; @@ -126,7 +129,19 @@ public class MainWindow : Window { unit_type_combo_box.set_active(1); unit_type_combo_box.changed += unit_type_changed; - server_snapshot_button = new Button.with_mnemonic("Take _Snapshot"); + unit_load_entry = new Entry(); + unit_load_button = new Button.with_mnemonic("_Load"); + unit_load_button.set_sensitive(false); + + unit_load_entry.changed += on_unit_load_entry_changed; + unit_load_entry.activate += on_unit_load; + unit_load_button.clicked += on_unit_load; + + Box unit_load_hbox = new HBox(false, 6); + unit_load_hbox.pack_start(unit_load_entry, false, true, 0); + unit_load_hbox.pack_start(unit_load_button, false, true, 0); + + server_snapshot_button = new Button.with_mnemonic("Take S_napshot"); server_reload_button = new Button.with_mnemonic("Reload _Configuration"); server_snapshot_button.clicked += on_server_snapshot; @@ -134,6 +149,7 @@ public class MainWindow : Window { type_hbox.pack_end(server_snapshot_button, false, true, 0); type_hbox.pack_end(server_reload_button, false, true, 0); + type_hbox.pack_end(unit_load_hbox, false, true, 24); unit_model = new ListStore(7, typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(string), typeof(Unit)); job_model = new ListStore(6, typeof(string), typeof(string), typeof(string), typeof(string), typeof(Job), typeof(uint32)); @@ -768,11 +784,44 @@ public class MainWindow : Window { } } + public void on_unit_load() { + string t = unit_load_entry.get_text(); + + if (t == "") + return; + + try { + var path = manager.load_unit(t); + + Unit u = bus.get_object( + "org.freedesktop.systemd1", + path, + "org.freedesktop.systemd1.Unit") as Unit; + + var m = new MessageDialog(this, + DialogFlags.DESTROY_WITH_PARENT, + MessageType.INFO, + ButtonsType.CLOSE, + "Unit available as id %s", u.id); + m.title = "Unit"; + m.run(); + m.destroy(); + + } catch (DBus.Error e) { + show_error(e.message); + } + } + + public void on_unit_load_entry_changed() { + unit_load_button.set_sensitive(unit_load_entry.get_text() != ""); + } + public void show_error(string e) { var m = new MessageDialog(this, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR, ButtonsType.CLOSE, "%s", e); + m.title = "Error"; m.run(); m.destroy(); }