X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=systemadm.vala;h=fdc84648dc2cb1108ee214f5b1d761274b918c22;hp=6bcb5f6a8319b705eea649880f1f06964f036c1e;hb=4e85aff465b2ce0fa34222e52a6f5a984140b22e;hpb=77a38d306922b3e980c06a3a377b344ea429edd7 diff --git a/systemadm.vala b/systemadm.vala index 6bcb5f6a8..fdc84648d 100644 --- a/systemadm.vala +++ b/systemadm.vala @@ -199,15 +199,15 @@ public class MainWindow : Window { job_vbox.pack_start(job_table, false, true, 0); unit_table.attach(new LeftLabel("Id:"), 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_id_label, 1, 5, 0, 1, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_id_label, 1, 6, 0, 1, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(new LeftLabel("Aliases:"), 0, 1, 1, 2, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_aliases_label, 1, 5, 1, 2, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_aliases_label, 1, 6, 1, 2, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(new LeftLabel("Description:"), 0, 1, 2, 3, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_description_label, 1, 5, 2, 3, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_description_label, 1, 6, 2, 3, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(new LeftLabel("Fragment Path:"), 0, 1, 3, 4, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_fragment_path_label, 1, 5, 3, 4, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_fragment_path_label, 1, 6, 3, 4, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(new LeftLabel("Control Group:"), 0, 1, 4, 5, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_cgroup_label, 1, 5, 4, 5, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_cgroup_label, 1, 6, 4, 5, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(new LeftLabel("Load State:"), 0, 1, 5, 6, AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(unit_load_state_label, 1, 2, 5, 6, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); @@ -385,8 +385,19 @@ public class MainWindow : Window { current_unit_id = unit.id; unit_id_label.set_text_or_na(current_unit_id); - unit_aliases_label.set_text_or_na(string.joinv("\n", unit.names)); + string a = ""; + foreach (string i in unit.names) { + if (i == current_unit_id) + continue; + + if (a == "") + a = i; + else + a += "\n" + i; + } + + unit_aliases_label.set_text_or_na(a); unit_description_label.set_text_or_na(unit.description); unit_load_state_label.set_text_or_na(unit.load_state); unit_active_state_label.set_text_or_na(unit.active_state); @@ -395,15 +406,15 @@ public class MainWindow : Window { uint64 t = unit.active_enter_timestamp; if (t > 0) { - TimeVal tv = { (long) (t / 1000000), (long) (t % 1000000) }; - unit_active_enter_timestamp_label.set_text_or_na(tv.to_iso8601()); + Time timestamp = Time.local((time_t) (t / 1000000)); + unit_active_enter_timestamp_label.set_text_or_na(timestamp.format("%a, %d %b %Y %H:%M:%S %z")); } else unit_active_enter_timestamp_label.set_text_or_na(); t = unit.active_exit_timestamp; if (t > 0) { - TimeVal tv = { (long) (t / 1000000), (long) (t % 1000000) }; - unit_active_exit_timestamp_label.set_text_or_na(tv.to_iso8601()); + Time timestamp = Time.local((time_t) (t / 1000000)); + unit_active_exit_timestamp_label.set_text_or_na(timestamp.format("%a, %d %b %Y %H:%M:%S %z")); } else unit_active_exit_timestamp_label.set_text_or_na(); @@ -475,7 +486,7 @@ public class MainWindow : Window { try { u.start("replace"); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } @@ -488,7 +499,7 @@ public class MainWindow : Window { try { u.stop("replace"); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } @@ -501,7 +512,7 @@ public class MainWindow : Window { try { u.reload("replace"); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } @@ -514,7 +525,7 @@ public class MainWindow : Window { try { u.restart("replace"); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } @@ -527,7 +538,7 @@ public class MainWindow : Window { try { j.cancel(); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } @@ -672,7 +683,7 @@ public class MainWindow : Window { try { manager.reload(); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } @@ -684,9 +695,19 @@ public class MainWindow : Window { unit_type_combo_box.set_active(8); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } } + + public void show_error(string e) { + var m = new MessageDialog(this, + DialogFlags.DESTROY_WITH_PARENT, + MessageType.ERROR, + ButtonsType.CLOSE, "%s", e); + m.run(); + m.destroy(); + } + } static const OptionEntry entries[] = { @@ -695,6 +716,12 @@ static const OptionEntry entries[] = { { null } }; +void show_error(string e) { + var m = new MessageDialog(null, 0, MessageType.ERROR, ButtonsType.CLOSE, "%s", e); + m.run(); + m.destroy(); +} + int main (string[] args) { try { @@ -702,12 +729,13 @@ int main (string[] args) { MainWindow window = new MainWindow(); window.show_all(); + + Gtk.main(); } catch (DBus.Error e) { - message("%s", e.message); + show_error(e.message); } catch (GLib.Error e) { - message("%s", e.message); + show_error(e.message); } - Gtk.main(); return 0; }