]> err.no Git - systemd/commitdiff
systemadm: use color for dependency links
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 3 Mar 2011 21:20:19 +0000 (22:20 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Sep 2011 23:07:27 +0000 (01:07 +0200)
src/systemadm.vala

index 088ba26be9fda31981107e73444fd228312f221f..eed46b57e9e9ebd64d3342b7836ad153dc0ad655 100644 (file)
@@ -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;