chiark / gitweb /
systemadm: use color for dependency links
[elogind.git] / src / systemadm.vala
index c893da01da1fbc56f765fd70abff7f20c2a5666b..eed46b57e9e9ebd64d3342b7836ad153dc0ad655 100644 (file)
@@ -457,7 +457,30 @@ public class MainWindow : Window {
                 unit_cgroup_label.set_text_or_na();
         }
 
                 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) {
         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;
 
                 bool first = true;
                 string r;
 
@@ -466,7 +489,7 @@ public class MainWindow : Window {
                 else
                         r = prefix;
 
                 else
                         r = prefix;
 
-                foreach (string i in dependencies) {
+                foreach (string i in sorted) {
                         if (r != "")
                                 r += first ? "\n" : ",";
 
                         if (r != "")
                                 r += first ? "\n" : ",";
 
@@ -475,7 +498,7 @@ public class MainWindow : Window {
                                 first = false;
                         }
 
                                 first = false;
                         }
 
-                        r += " <a href=\"" + i + "\">" + i + "</a>";
+                        r += format_unit_link(i);
                 }
 
                 return r;
                 }
 
                 return r;