From 8401f1533d6936add337a621c5e58e3bbe9f346a Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Wed, 23 Feb 2011 14:03:59 +0100 Subject: systemadm: break timestamp formatting out into a seperate function Since the timezone is always local, it doesn't make much sense to display it. The timestamp is now formatted without the timezone. I guess it can be further improved, which should be easier now that it is tucked-away in a separate function. --- src/systemadm.vala | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index d45ec64ca4..988e9f173c 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -23,6 +23,13 @@ using Pango; static bool user = false; +public string format_time(uint64 time_ns) { + if (time_ns <= 0) + return ""; + Time timestamp = Time.local((time_t) (time_ns / 1000000)); + return timestamp.format("%a, %d %b %Y %H:%M:%S"); +} + public class LeftLabel : Label { public LeftLabel(string? text = null) { if (text != null) @@ -515,19 +522,10 @@ public class MainWindow : Window { else unit_fragment_path_label.set_text_or_na(); - uint64 t = unit.active_enter_timestamp; - if (t > 0) { - 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) { - 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(); + + unit_active_enter_timestamp_label.set_text_or_na(format_time(unit.active_enter_timestamp)); + + unit_active_exit_timestamp_label.set_text_or_na(format_time(unit.active_exit_timestamp)); bool b = unit.can_start; start_button.set_sensitive(b); -- cgit v1.2.3-54-g00ecf From 661ece1029ea454ff76093a5f1b40e9209cac86d Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 24 Feb 2011 16:29:24 +0100 Subject: systemadm: allow sorting of jobs and units --- src/systemadm.vala | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index 988e9f173c..21177bf396 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -30,6 +30,13 @@ public string format_time(uint64 time_ns) { return timestamp.format("%a, %d %b %Y %H:%M:%S"); } +public void new_column(TreeView view, int column_id, string title) { + TreeViewColumn col; + col = new TreeViewColumn.with_attributes(title, new CellRendererText(), "text", column_id); + col.set_sort_column_id(column_id); + view.insert_column(col, -1); +} + public class LeftLabel : Label { public LeftLabel(string? text = null) { if (text != null) @@ -171,22 +178,24 @@ public class MainWindow : Window { unit_model_filter = new TreeModelFilter(unit_model, null); unit_model_filter.set_visible_func(unit_filter); - unit_view = new TreeView.with_model(unit_model_filter); + TreeModelSort unit_model_sort = new TreeModelSort.with_model(unit_model_filter); + + unit_view = new TreeView.with_model(unit_model_sort); job_view = new TreeView.with_model(job_model); unit_view.cursor_changed.connect(unit_changed); job_view.cursor_changed.connect(job_changed); - unit_view.insert_column_with_attributes(-1, "Load State", new CellRendererText(), "text", 2); - unit_view.insert_column_with_attributes(-1, "Active State", new CellRendererText(), "text", 3); - unit_view.insert_column_with_attributes(-1, "Unit State", new CellRendererText(), "text", 4); - unit_view.insert_column_with_attributes(-1, "Unit", new CellRendererText(), "text", 0); - unit_view.insert_column_with_attributes(-1, "Job", new CellRendererText(), "text", 5); + new_column(unit_view, 2, "Load State"); + new_column(unit_view, 3, "Active State"); + new_column(unit_view, 4, "Unit State"); + new_column(unit_view, 0, "Unit"); + new_column(unit_view, 5, "Job"); - job_view.insert_column_with_attributes(-1, "Job", new CellRendererText(), "text", 0); - job_view.insert_column_with_attributes(-1, "Unit", new CellRendererText(), "text", 1); - job_view.insert_column_with_attributes(-1, "Type", new CellRendererText(), "text", 2); - job_view.insert_column_with_attributes(-1, "State", new CellRendererText(), "text", 3); + new_column(job_view, 0, "Job"); + new_column(job_view, 1, "Unit"); + new_column(job_view, 2, "Type"); + new_column(job_view, 3, "State"); ScrolledWindow scroll = new ScrolledWindow(null, null); scroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC); @@ -897,7 +906,7 @@ public class MainWindow : Window { } public void unit_type_changed() { - TreeModelFilter model = (TreeModelFilter) unit_view.get_model(); + TreeModelFilter model = (TreeModelFilter) ((TreeModelSort) unit_view.get_model()).get_model(); model.refilter(); } -- cgit v1.2.3-54-g00ecf From a3c159a23c7cae889f89ed69bbe82c272bf163ca Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Fri, 25 Feb 2011 18:20:16 +0100 Subject: systemadm: split the type+status combo box into type combo & status checkbox --- src/systemadm.vala | 62 ++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index 21177bf396..e78fd7c4d4 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -113,6 +113,7 @@ public class MainWindow : Window { private RightLabel job_type_label; private ComboBox unit_type_combo_box; + private CheckButton inactive_checkbox; public MainWindow() throws IOError { title = user ? "systemd User Service Manager" : "systemd System Manager"; @@ -137,8 +138,7 @@ public class MainWindow : Window { type_hbox.pack_start(unit_type_combo_box, false, false, 0); unit_vbox.pack_start(type_hbox, false, false, 0); - unit_type_combo_box.append_text("Show All Units"); - unit_type_combo_box.append_text("Show Only Live Units"); + unit_type_combo_box.append_text("Show All"); unit_type_combo_box.append_text("Services"); unit_type_combo_box.append_text("Sockets"); unit_type_combo_box.append_text("Devices"); @@ -146,9 +146,13 @@ public class MainWindow : Window { unit_type_combo_box.append_text("Automounts"); unit_type_combo_box.append_text("Targets"); unit_type_combo_box.append_text("Snapshots"); - unit_type_combo_box.set_active(1); + unit_type_combo_box.set_active(0); // Show All unit_type_combo_box.changed.connect(unit_type_changed); + inactive_checkbox = new CheckButton.with_label("inactive too"); + inactive_checkbox.toggled.connect(unit_type_changed); + type_hbox.pack_start(inactive_checkbox, false, false, 0); + unit_load_entry = new Entry(); unit_load_button = new Button.with_mnemonic("_Load"); unit_load_button.set_sensitive(false); @@ -872,37 +876,31 @@ public class MainWindow : Window { if (id == null) return false; - switch (unit_type_combo_box.get_active()) { - - case 0: - return true; - - case 1: - return active_state != "inactive" || job != ""; - - case 2: - return id.has_suffix(".service"); - - case 3: - return id.has_suffix(".socket"); - - case 4: - return id.has_suffix(".device"); - - case 5: - return id.has_suffix(".mount"); - - case 6: - return id.has_suffix(".automount"); - - case 7: - return id.has_suffix(".target"); + if (!inactive_checkbox.get_active() + && active_state == "inactive" && job == "") + return false; - case 8: - return id.has_suffix(".snapshot"); + switch (unit_type_combo_box.get_active()) { + case 0: + return true; + case 1: + return id.has_suffix(".service"); + case 2: + return id.has_suffix(".socket"); + case 3: + return id.has_suffix(".device"); + case 4: + return id.has_suffix(".mount"); + case 5: + return id.has_suffix(".automount"); + case 6: + return id.has_suffix(".target"); + case 7: + return id.has_suffix(".snapshot"); + default: + assert(false); + return false; } - - return false; } public void unit_type_changed() { -- cgit v1.2.3-54-g00ecf From e377ad0d11e1bd9954c6084956494ebbf41b4486 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 28 Feb 2011 10:35:23 +0100 Subject: systemadm: filter on swaps, paths, and timers too. --- src/systemadm.vala | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index e78fd7c4d4..6126eca221 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -138,13 +138,16 @@ public class MainWindow : Window { type_hbox.pack_start(unit_type_combo_box, false, false, 0); unit_vbox.pack_start(type_hbox, false, false, 0); - unit_type_combo_box.append_text("Show All"); + unit_type_combo_box.append_text("All unit types"); + unit_type_combo_box.append_text("Targets"); unit_type_combo_box.append_text("Services"); - unit_type_combo_box.append_text("Sockets"); unit_type_combo_box.append_text("Devices"); unit_type_combo_box.append_text("Mounts"); unit_type_combo_box.append_text("Automounts"); - unit_type_combo_box.append_text("Targets"); + unit_type_combo_box.append_text("Swaps"); + unit_type_combo_box.append_text("Sockets"); + unit_type_combo_box.append_text("Paths"); + unit_type_combo_box.append_text("Timers"); unit_type_combo_box.append_text("Snapshots"); unit_type_combo_box.set_active(0); // Show All unit_type_combo_box.changed.connect(unit_type_changed); @@ -884,9 +887,9 @@ public class MainWindow : Window { case 0: return true; case 1: - return id.has_suffix(".service"); + return id.has_suffix(".target"); case 2: - return id.has_suffix(".socket"); + return id.has_suffix(".service"); case 3: return id.has_suffix(".device"); case 4: @@ -894,8 +897,14 @@ public class MainWindow : Window { case 5: return id.has_suffix(".automount"); case 6: - return id.has_suffix(".target"); + return id.has_suffix(".swap"); case 7: + return id.has_suffix(".socket"); + case 8: + return id.has_suffix(".path"); + case 9: + return id.has_suffix(".timer"); + case 10: return id.has_suffix(".snapshot"); default: assert(false); -- cgit v1.2.3-54-g00ecf From 0dd27daff4ba4bdad99b12b85b630ab21c84fa9e Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 1 Mar 2011 11:18:13 +0100 Subject: systemadm: add a wrappable label and use it for status lines The new WrapLabel is there to work around a deficiency in GTK, namely the fact that it is hard to make labels which are both resizable and wrappable. The code is a port from libview. --- Makefile.am | 3 ++- src/.gitignore | 1 + src/systemadm.vala | 7 +++--- src/wraplabel.vala | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 src/wraplabel.vala diff --git a/Makefile.am b/Makefile.am index e1d1186887..ec0f7b5d13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1418,7 +1418,8 @@ systemd_stdio_bridge_LDADD = \ systemadm_SOURCES = \ src/systemadm.vala \ - src/systemd-interfaces.vala + src/systemd-interfaces.vala \ + src/wraplabel.vala systemadm_CFLAGS = \ $(AM_CFLAGS) \ diff --git a/src/.gitignore b/src/.gitignore index cafff82a75..a3fd20b404 100644 --- a/src/.gitignore +++ b/src/.gitignore @@ -12,4 +12,5 @@ org.freedesktop.systemd1.policy gnome-ask-password-agent.c systemd-interfaces.c systemadm.c +wraplabel.c 73-seat-late.rules diff --git a/src/systemadm.vala b/src/systemadm.vala index 6126eca221..68652d0064 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -46,12 +46,11 @@ public class LeftLabel : Label { } } -public class RightLabel : Label { +public class RightLabel : WrapLabel { + public RightLabel(string? text = null) { - set_text_or_na(text); - set_alignment(0, 0); - set_ellipsize(EllipsizeMode.START); set_selectable(true); + set_text_or_na(text); } public void set_text_or_na(string? text = null) { diff --git a/src/wraplabel.vala b/src/wraplabel.vala new file mode 100644 index 0000000000..49858c3222 --- /dev/null +++ b/src/wraplabel.vala @@ -0,0 +1,73 @@ +// Copyright (c) 2005 VMware, Inc. + +// This is a translation of http://git.gnome.org/browse/meld/tree/meld/ui/wraplabel.py, +// which in turn is a translation of WrapLabel from libview. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +// Python translation from wrapLabel.{cc|h} by Gian Mario Tagliaretti +// Vala translation from wraplabel.py by Zbigniew Jędrzejewski-Szmek + +public class WrapLabel : Gtk.Label { + private int _wrap_width; + + public WrapLabel(string? text = null) { + this._wrap_width = 0; + var layout = get_layout(); + layout.set_wrap(Pango.WrapMode.WORD_CHAR); + if (text != null) + this.set_text(text); + this.set_alignment(0, 0); + } + + public override void size_request(out Gtk.Requisition requisition) { + int width, height; + var layout = get_layout(); + layout.get_pixel_size(out width, out height); + requisition.width = 0; + requisition.height = height; + } + + public override void size_allocate(Gdk.Rectangle allocation) { + base.size_allocate (allocation); + this._set_wrap_width(allocation.width); + } + + public new void set_text(string str) { + base.set_text(str); + this._set_wrap_width(this._wrap_width); + } + + public new void set_markup(string str) { + base.set_markup(str); + this._set_wrap_width(this._wrap_width); + } + + private void _set_wrap_width(int width) { + if (width == 0) + return; + + var layout = get_layout(); + layout.set_width(width * Pango.SCALE); + if (_wrap_width != width) { + this._wrap_width = width; + this.queue_resize(); + } + } +} -- cgit v1.2.3-54-g00ecf From 11216eb0bd5aab6b14af004fd2f24d423e3d356d Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 3 Mar 2011 20:54:01 +0100 Subject: systemadm: add libgee as dependency and use it for a unit map --- Makefile.am | 1 + configure.ac | 2 +- src/systemadm.vala | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index ec0f7b5d13..0712945532 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1432,6 +1432,7 @@ systemadm_CFLAGS = \ systemadm_VALAFLAGS = \ --pkg=posix \ --pkg=gtk+-2.0 \ + --pkg=gee-1.0 \ -g systemadm_LDADD = \ diff --git a/configure.ac b/configure.ac index ca07456be6..b2411c937b 100644 --- a/configure.ac +++ b/configure.ac @@ -327,7 +327,7 @@ AM_CONDITIONAL(ENABLE_LOCALED, [test "$have_localed" = "yes"]) have_gtk=no AC_ARG_ENABLE(gtk, AS_HELP_STRING([--disable-gtk], [disable GTK tools])) if test "x$enable_gtk" != "xno"; then - PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0 > 2.26 gio-unix-2.0 ], + PKG_CHECK_MODULES(GTK, [ gtk+-2.0 glib-2.0 > 2.26 gio-unix-2.0 gee-1.0], [AC_DEFINE(HAVE_GTK, 1, [Define if GTK is available]) have_gtk=yes], have_gtk=no) AC_SUBST(GTK_CFLAGS) AC_SUBST(GTK_LIBS) diff --git a/src/systemadm.vala b/src/systemadm.vala index 68652d0064..c893da01da 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -79,6 +79,8 @@ public class MainWindow : Window { private ListStore unit_model; private ListStore job_model; + private Gee.HashMap unit_map; + private Button start_button; private Button stop_button; private Button restart_button; @@ -180,6 +182,8 @@ public class MainWindow : Window { 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)); + unit_map = new Gee.HashMap(); + TreeModelFilter unit_model_filter; unit_model_filter = new TreeModelFilter(unit_model, null); unit_model_filter.set_visible_func(unit_filter); @@ -355,6 +359,8 @@ public class MainWindow : Window { "org.freedesktop.systemd1", i.unit_path); + unit_map[i.id] = u; + unit_model.append(out iter); unit_model.set(iter, 0, i.id, @@ -415,6 +421,10 @@ public class MainWindow : Window { return u; } + public Unit? get_unit(string id) { + return this.unit_map[id]; + } + public void unit_changed() { Unit u = get_current_unit(); @@ -712,6 +722,8 @@ public class MainWindow : Window { "org.freedesktop.systemd1", path); + unit_map[id] = u; + update_unit_iter(iter, id, u); } catch (IOError e) { show_error(e.message); @@ -773,6 +785,8 @@ public class MainWindow : Window { } } while (unit_model.iter_next(ref iter)); + + unit_map.unset(id); } public void on_job_removed(uint32 id, ObjectPath path, string res) { -- cgit v1.2.3-54-g00ecf From 8278f06953f5339646e5ff98900321f1525c0a21 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 3 Mar 2011 01:30:08 +0100 Subject: systemadm: display dependencies sorted --- src/systemadm.vala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index c893da01da..088ba26be9 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -458,6 +458,10 @@ public class MainWindow : Window { } public string make_dependency_string(string? prefix, string word, string[] dependencies) { + Gee.Collection sorted = new Gee.TreeSet(); + foreach (string i in dependencies) + sorted.add(i); + bool first = true; string r; @@ -466,7 +470,7 @@ public class MainWindow : Window { else r = prefix; - foreach (string i in dependencies) { + foreach (string i in sorted) { if (r != "") r += first ? "\n" : ","; -- cgit v1.2.3-54-g00ecf From 23b51f17b1cf473bff3ae5332477e2028a5c5f53 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 3 Mar 2011 22:20:19 +0100 Subject: systemadm: use color for dependency links --- src/systemadm.vala | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index 088ba26be9..eed46b57e9 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -457,6 +457,25 @@ public class MainWindow : Window { unit_cgroup_label.set_text_or_na(); } + public string format_unit_link(string i) { + Unit? u = get_unit(i); + if(u == null) + return "" + i + "" + + i + "(" + + u.sub_state + ")" + ""; + return " " + span + ""; + } + + public string make_dependency_string(string? prefix, string word, string[] dependencies) { Gee.Collection sorted = new Gee.TreeSet(); foreach (string i in dependencies) @@ -479,7 +498,7 @@ public class MainWindow : Window { first = false; } - r += " " + i + ""; + r += format_unit_link(i); } return r; -- cgit v1.2.3-54-g00ecf From 8b1451ade7794c21d29141dc363d0f626e2070ee Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sat, 17 Sep 2011 14:57:19 +0100 Subject: systemadm: use bold for "requires", etc. --- src/systemadm.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index eed46b57e9..a3068f157d 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -494,7 +494,7 @@ public class MainWindow : Window { r += first ? "\n" : ","; if (first) { - r += word; + r += "" + word + ":"; first = false; } -- cgit v1.2.3-54-g00ecf From 37d3b881f1cc7c18d23013ff29429ab67ab5b61d Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sun, 18 Sep 2011 11:06:07 +0200 Subject: systemadm: make the dependency listing selectable There's no reason to forbid selecting the text. --- src/systemadm.vala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index a3068f157d..e7fa35402d 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -238,7 +238,7 @@ public class MainWindow : Window { job_type_label = new RightLabel(); unit_dependency_label.set_track_visited_links(false); - unit_dependency_label.set_selectable(false); + unit_dependency_label.set_selectable(true); unit_dependency_label.activate_link.connect(on_activate_link); unit_fragment_path_label.set_track_visited_links(false); -- cgit v1.2.3-54-g00ecf From 734b60d7961a28adab45ef141807a0f3e0ba11e5 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Thu, 24 Feb 2011 16:30:55 +0100 Subject: systemadm: catch exceptions generated by dbus Otherwise, access-denied dbus errors were not caught, and only caused a message to be printed out on the console. After this change a proper popup window pops up :). --- src/systemadm.vala | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index e7fa35402d..d4208008fe 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -642,7 +642,7 @@ public class MainWindow : Window { try { u.start("replace"); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -655,7 +655,7 @@ public class MainWindow : Window { try { u.stop("replace"); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -668,7 +668,7 @@ public class MainWindow : Window { try { u.reload("replace"); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -681,7 +681,7 @@ public class MainWindow : Window { try { u.restart("replace"); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -694,7 +694,7 @@ public class MainWindow : Window { try { j.cancel(); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -722,7 +722,7 @@ public class MainWindow : Window { 4, u.sub_state, 5, t != "" ? "→ %s".printf(t) : "", 6, u); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -748,7 +748,7 @@ public class MainWindow : Window { unit_map[id] = u; update_unit_iter(iter, id, u); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -784,7 +784,7 @@ public class MainWindow : Window { update_job_iter(iter, id, j); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -866,7 +866,7 @@ public class MainWindow : Window { } while (unit_model.iter_next(ref iter)); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -902,7 +902,7 @@ public class MainWindow : Window { } while (job_model.iter_next(ref iter)); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -957,7 +957,7 @@ public class MainWindow : Window { public void on_server_reload() { try { manager.reload(); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -969,7 +969,7 @@ public class MainWindow : Window { if (unit_type_combo_box.get_active() != 0) unit_type_combo_box.set_active(8); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -998,7 +998,7 @@ public class MainWindow : Window { m.destroy(); show_unit(u); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } } @@ -1018,7 +1018,7 @@ public class MainWindow : Window { path); show_unit(u); - } catch (IOError e) { + } catch (Error e) { show_error(e.message); } -- cgit v1.2.3-54-g00ecf From 8f38d5a4c6e627180809db739b2bdaa5ca0c645a Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sun, 18 Sep 2011 17:00:12 +0200 Subject: systemadm: coalesce id and decription fields This is just in interest of saving space (e.g. 5 lines for multi-user.target). --- src/systemadm.vala | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index d4208008fe..4cb5c55ef3 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -96,7 +96,6 @@ public class MainWindow : Window { private Manager manager; private RightLabel unit_id_label; - private RightLabel unit_aliases_label; private RightLabel unit_dependency_label; private RightLabel unit_description_label; private RightLabel unit_load_state_label; @@ -220,7 +219,6 @@ public class MainWindow : Window { job_vbox.pack_start(scroll, true, true, 0); unit_id_label = new RightLabel(); - unit_aliases_label = new RightLabel(); unit_dependency_label = new RightLabel(); unit_description_label = new RightLabel(); unit_load_state_label = new RightLabel(); @@ -255,8 +253,6 @@ public class MainWindow : Window { unit_table.attach(new LeftLabel("Id:"), 0, 1, 0, 1, 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, 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, 6, 2, 3, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); unit_table.attach(new LeftLabel("Dependencies:"), 0, 1, 3, 4, AttachOptions.FILL, AttachOptions.FILL, 0, 0); @@ -443,7 +439,6 @@ public class MainWindow : Window { restart_button.set_sensitive(false); unit_id_label.set_text_or_na(); - unit_aliases_label.set_text_or_na(); unit_description_label.set_text_or_na(); unit_description_label.set_text_or_na(); unit_load_state_label.set_text_or_na(); @@ -507,20 +502,23 @@ public class MainWindow : Window { public void show_unit(Unit unit) { current_unit_id = unit.id; - unit_id_label.set_text_or_na(current_unit_id); - - string a = ""; + string id_display = current_unit_id; + bool has_alias = false; foreach (string i in unit.names) { if (i == current_unit_id) continue; - if (a == "") - a = i; - else - a += "\n" + i; + if (!has_alias) { + id_display += " (aliases:"; + has_alias = true; + } + + id_display += " " + i; } + if(has_alias) + id_display += ")"; - unit_aliases_label.set_text_or_na(a); + unit_id_label.set_text_or_na(id_display); string[] requires = unit.requires, -- cgit v1.2.3-54-g00ecf From fe7e28146f30ec442c0dd7f71002a1b482d910a9 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 19 Sep 2011 08:14:02 +0200 Subject: systemadm: adjust row numbers after removing 'aliases' --- src/systemadm.vala | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index 4cb5c55ef3..11189995c8 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -253,31 +253,31 @@ public class MainWindow : Window { unit_table.attach(new LeftLabel("Id:"), 0, 1, 0, 1, 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("Description:"), 0, 1, 2, 3, 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("Dependencies:"), 0, 1, 3, 4, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_dependency_label, 1, 6, 3, 4, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(new LeftLabel("Fragment Path:"), 0, 1, 4, 5, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_fragment_path_label, 1, 6, 4, 5, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(new LeftLabel("Control Group:"), 0, 1, 5, 6, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_cgroup_label, 1, 6, 5, 6, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - - unit_table.attach(new LeftLabel("Load State:"), 0, 1, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_load_state_label, 1, 2, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(new LeftLabel("Active State:"), 0, 1, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_active_state_label, 1, 2, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(new LeftLabel("Unit State:"), 0, 1, 8, 9, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_sub_state_label, 1, 2, 8, 9, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - - unit_table.attach(new LeftLabel("Active Enter Timestamp:"), 2, 3, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_active_enter_timestamp_label, 3, 4, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(new LeftLabel("Active Exit Timestamp:"), 2, 3, 8, 9, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_active_exit_timestamp_label, 3, 4, 8, 9, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - - unit_table.attach(new LeftLabel("Can Start/Stop:"), 4, 5, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_can_start_label, 5, 6, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(new LeftLabel("Can Reload:"), 4, 5, 8, 9, AttachOptions.FILL, AttachOptions.FILL, 0, 0); - unit_table.attach(unit_can_reload_label, 5, 6, 8, 9, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(new LeftLabel("Description:"), 0, 1, 1, 2, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_description_label, 1, 6, 1, 2, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(new LeftLabel("Dependencies:"), 0, 1, 2, 3, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_dependency_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, 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, 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); + unit_table.attach(new LeftLabel("Active State:"), 0, 1, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_active_state_label, 1, 2, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(new LeftLabel("Unit State:"), 0, 1, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_sub_state_label, 1, 2, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + + unit_table.attach(new LeftLabel("Activated:"), 2, 3, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_active_enter_timestamp_label, 3, 4, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(new LeftLabel("Deactivated:"), 2, 3, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_active_exit_timestamp_label, 3, 4, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + + unit_table.attach(new LeftLabel("Can Start/Stop:"), 4, 5, 6, 7, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_can_start_label, 5, 6, 6, 7, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(new LeftLabel("Can Reload:"), 4, 5, 7, 8, AttachOptions.FILL, AttachOptions.FILL, 0, 0); + unit_table.attach(unit_can_reload_label, 5, 6, 7, 8, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); job_table.attach(new LeftLabel("Id:"), 0, 1, 0, 1, AttachOptions.FILL, AttachOptions.FILL, 0, 0); job_table.attach(job_id_label, 1, 2, 0, 1, AttachOptions.EXPAND|AttachOptions.FILL, AttachOptions.FILL, 0, 0); -- cgit v1.2.3-54-g00ecf From 79b1e6cb8080e5c88754484f5af591ce74714ff0 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Mon, 19 Sep 2011 08:20:17 +0200 Subject: systemadm: use colors for id too, remove color from fragment link --- src/systemadm.vala | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/systemadm.vala b/src/systemadm.vala index 11189995c8..5971ac07e5 100644 --- a/src/systemadm.vala +++ b/src/systemadm.vala @@ -452,7 +452,7 @@ public class MainWindow : Window { unit_cgroup_label.set_text_or_na(); } - public string format_unit_link(string i) { + public string format_unit_link(string i, bool link) { Unit? u = get_unit(i); if(u == null) return "" + i + "" + i + "(" + u.sub_state + ")" + ""; - return " " + span + ""; + if(link) + return " " + span + ""; + else + return span; } @@ -493,7 +496,7 @@ public class MainWindow : Window { first = false; } - r += format_unit_link(i); + r += format_unit_link(i, true); } return r; @@ -502,7 +505,7 @@ public class MainWindow : Window { public void show_unit(Unit unit) { current_unit_id = unit.id; - string id_display = current_unit_id; + string id_display = format_unit_link(current_unit_id, false); bool has_alias = false; foreach (string i in unit.names) { if (i == current_unit_id) @@ -518,7 +521,7 @@ public class MainWindow : Window { if(has_alias) id_display += ")"; - unit_id_label.set_text_or_na(id_display); + unit_id_label.set_markup_or_na(id_display); string[] requires = unit.requires, @@ -564,7 +567,9 @@ public class MainWindow : Window { string fp = unit.fragment_path; if (fp != "") - unit_fragment_path_label.set_markup_or_na("" + fp + "" ); + unit_fragment_path_label.set_markup_or_na( + "" + + "" + fp + ""); else unit_fragment_path_label.set_text_or_na(); -- cgit v1.2.3-54-g00ecf