chiark / gitweb /
systemadm: use colors for id too, remove color from fragment link
[elogind.git] / src / systemadm.vala
index a3068f157d04aa19a777c6513378ff4c8ef23aa6..5971ac07e5c46b404bb4e057b9eb1399bcce2666 100644 (file)
@@ -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();
@@ -238,7 +236,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);
@@ -255,33 +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("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);
-                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);
@@ -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();
@@ -457,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";
@@ -472,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;
         }
 
 
@@ -498,7 +496,7 @@ public class MainWindow : Window {
                                 first = false;
                         }
 
-                        r += format_unit_link(i);
+                        r += format_unit_link(i, true);
                 }
 
                 return r;
@@ -507,20 +505,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 = format_unit_link(current_unit_id, false);
+                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_markup_or_na(id_display);
 
                 string[]
                         requires = unit.requires,
@@ -566,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();
 
@@ -642,7 +645,7 @@ public class MainWindow : Window {
 
                 try {
                         u.start("replace");
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -655,7 +658,7 @@ public class MainWindow : Window {
 
                 try {
                         u.stop("replace");
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -668,7 +671,7 @@ public class MainWindow : Window {
 
                 try {
                         u.reload("replace");
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -681,7 +684,7 @@ public class MainWindow : Window {
 
                 try {
                         u.restart("replace");
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -694,7 +697,7 @@ public class MainWindow : Window {
 
                 try {
                         j.cancel();
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -722,7 +725,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 +751,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 +787,7 @@ public class MainWindow : Window {
 
                         update_job_iter(iter, id, j);
 
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -866,7 +869,7 @@ public class MainWindow : Window {
 
                         } while (unit_model.iter_next(ref iter));
 
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -902,7 +905,7 @@ public class MainWindow : Window {
 
                         } while (job_model.iter_next(ref iter));
 
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -957,7 +960,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 +972,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 +1001,7 @@ public class MainWindow : Window {
                         m.destroy();
 
                         show_unit(u);
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }
         }
@@ -1018,7 +1021,7 @@ public class MainWindow : Window {
                                         path);
 
                         show_unit(u);
-                } catch (IOError e) {
+                } catch (Error e) {
                         show_error(e.message);
                 }