[systemd-commits] 15 commits - configure.ac Makefile.am src/.gitignore src/systemadm.vala src/wraplabel.vala
Lennart Poettering
lennart at kemper.freedesktop.org
Wed Nov 2 06:10:47 PDT 2011
Makefile.am | 4
configure.ac | 2
src/.gitignore | 1
src/systemadm.vala | 289 +++++++++++++++++++++++++++++++----------------------
src/wraplabel.vala | 73 +++++++++++++
5 files changed, 249 insertions(+), 120 deletions(-)
New commits:
commit 263653e10353d8ad155f1faba01981816a2bb712
Merge: f5a613c... 79b1e6c...
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 2 14:08:49 2011 +0100
Merge remote-tracking branch 'zbigniew/systemadm_changes'
commit 79b1e6cb8080e5c88754484f5af591ce74714ff0
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Sep 19 08:20:17 2011 +0200
systemadm: use colors for id too, remove color from fragment link
diff --git a/src/systemadm.vala b/src/systemadm.vala
index 1118999..5971ac0 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 "<span color='grey'>" + i + "</span";
@@ -467,7 +467,10 @@ public class MainWindow : Window {
string span = "<span underline='none' color='" + color + "'>"
+ i + "(" +
u.sub_state + ")" + "</span>";
- return " <a href='" + i + "'>" + span + "</a>";
+ if(link)
+ return " <a href='" + i + "'>" + span + "</a>";
+ 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("<a href=\"file://" + fp +"\">" + fp + "</a>" );
+ unit_fragment_path_label.set_markup_or_na(
+ "<a href=\"file://" + fp +"\">" +
+ "<span underline='none' color='black'>" + fp + "</span></a>");
else
unit_fragment_path_label.set_text_or_na();
commit fe7e28146f30ec442c0dd7f71002a1b482d910a9
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Sep 19 08:14:02 2011 +0200
systemadm: adjust row numbers after removing 'aliases'
diff --git a/src/systemadm.vala b/src/systemadm.vala
index 4cb5c55..1118999 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);
commit 8f38d5a4c6e627180809db739b2bdaa5ca0c645a
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Sep 18 17:00:12 2011 +0200
systemadm: coalesce id and decription fields
This is just in interest of saving space (e.g. 5 lines for multi-user.target).
diff --git a/src/systemadm.vala b/src/systemadm.vala
index d420800..4cb5c55 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,
commit 734b60d7961a28adab45ef141807a0f3e0ba11e5
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Feb 24 16:30:55 2011 +0100
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 :).
diff --git a/src/systemadm.vala b/src/systemadm.vala
index e7fa354..d420800 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);
}
commit 37d3b881f1cc7c18d23013ff29429ab67ab5b61d
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sun Sep 18 11:06:07 2011 +0200
systemadm: make the dependency listing selectable
There's no reason to forbid selecting the text.
diff --git a/src/systemadm.vala b/src/systemadm.vala
index a3068f1..e7fa354 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);
commit 8b1451ade7794c21d29141dc363d0f626e2070ee
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Sat Sep 17 14:57:19 2011 +0100
systemadm: use bold for "requires", etc.
diff --git a/src/systemadm.vala b/src/systemadm.vala
index eed46b5..a3068f1 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 += "<b>" + word + ":</b>";
first = false;
}
commit 23b51f17b1cf473bff3ae5332477e2028a5c5f53
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Mar 3 22:20:19 2011 +0100
systemadm: use color for dependency links
diff --git a/src/systemadm.vala b/src/systemadm.vala
index 088ba26..eed46b5 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 "<span color='grey'>" + i + "</span";
+
+ string color;
+ switch (u.sub_state) {
+ case "active": color = "blue"; break;
+ case "dead": color = "red"; break;
+ case "running": color = "green"; break;
+ default: color = "black"; break;
+ }
+ string span = "<span underline='none' color='" + color + "'>"
+ + i + "(" +
+ u.sub_state + ")" + "</span>";
+ return " <a href='" + i + "'>" + span + "</a>";
+ }
+
+
public string make_dependency_string(string? prefix, string word, string[] dependencies) {
Gee.Collection<unowned string> sorted = new Gee.TreeSet<string>();
foreach (string i in dependencies)
@@ -479,7 +498,7 @@ public class MainWindow : Window {
first = false;
}
- r += " <a href=\"" + i + "\">" + i + "</a>";
+ r += format_unit_link(i);
}
return r;
commit 8278f06953f5339646e5ff98900321f1525c0a21
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Mar 3 01:30:08 2011 +0100
systemadm: display dependencies sorted
diff --git a/src/systemadm.vala b/src/systemadm.vala
index c893da0..088ba26 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<unowned string> sorted = new Gee.TreeSet<string>();
+ 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" : ",";
commit 11216eb0bd5aab6b14af004fd2f24d423e3d356d
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Mar 3 20:54:01 2011 +0100
systemadm: add libgee as dependency and use it for a unit map
diff --git a/Makefile.am b/Makefile.am
index ec0f7b5..0712945 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 ca07456..b2411c9 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 68652d0..c893da0 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<string, Unit> 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<string, Unit>();
+
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) {
commit 0dd27daff4ba4bdad99b12b85b630ab21c84fa9e
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Tue Mar 1 11:18:13 2011 +0100
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.
diff --git a/Makefile.am b/Makefile.am
index e1d1186..ec0f7b5 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 cafff82..a3fd20b 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 6126eca..68652d0 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 0000000..49858c3
--- /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();
+ }
+ }
+}
commit e377ad0d11e1bd9954c6084956494ebbf41b4486
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Mon Feb 28 10:35:23 2011 +0100
systemadm: filter on swaps, paths, and timers too.
diff --git a/src/systemadm.vala b/src/systemadm.vala
index e78fd7c..6126eca 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);
commit a3c159a23c7cae889f89ed69bbe82c272bf163ca
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Fri Feb 25 18:20:16 2011 +0100
systemadm: split the type+status combo box into type combo & status checkbox
diff --git a/src/systemadm.vala b/src/systemadm.vala
index 21177bf..e78fd7c 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() {
commit 661ece1029ea454ff76093a5f1b40e9209cac86d
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Feb 24 16:29:24 2011 +0100
systemadm: allow sorting of jobs and units
diff --git a/src/systemadm.vala b/src/systemadm.vala
index 988e9f1..21177bf 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();
}
commit 8401f1533d6936add337a621c5e58e3bbe9f346a
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Feb 23 14:03:59 2011 +0100
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.
diff --git a/src/systemadm.vala b/src/systemadm.vala
index d45ec64..988e9f1 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);
More information about the systemd-commits
mailing list