[systemd-devel] [PATCH 08/14] systemadm: use color for dependency links

Zbigniew Jędrzejewski-Szmek zbyszek at in.waw.pl
Mon Sep 19 04:24:23 PDT 2011


---
 src/systemadm.vala |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/src/systemadm.vala b/src/systemadm.vala
index 1c0c99f..26fac01 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) {
                 List<string> sorted = new List<string>();
                 foreach (string i in dependencies)
@@ -480,7 +499,7 @@ public class MainWindow : Window {
                                 first = false;
                         }
 
-                        r += " <a href=\"" + i + "\">" + i + "</a>";
+                        r += format_unit_link(i);
                 }
 
                 return r;
-- 
1.7.5.4



More information about the systemd-devel mailing list