Fixed display of the no_identity widget, and don't allow it to be removed
[moonshot-ui.git] / src / moonshot-idcard-widget.vala
index 9a63dae..a697481 100644 (file)
@@ -35,6 +35,8 @@ class IdCardWidget : Box
 {
     static MoonshotLogger logger = get_logger("IdCardWidget");
 
+    private static const ShadowType ARROW_SHADOW = ShadowType.NONE;
+
     private IdentityManagerView manager_view;
 
     public IdCard id_card { get; set; default = null; }
@@ -42,6 +44,7 @@ class IdCardWidget : Box
     private HBox table;
     private EventBox event_box;
     private bool   is_selected = false;
+    private Arrow arrow;
     
     private Label label;
 
@@ -72,6 +75,7 @@ class IdCardWidget : Box
         update_id_card_label();
 
         set_idcard_color();
+        arrow.set(ArrowType.DOWN, ARROW_SHADOW);
         this.expanded();
     }
 
@@ -81,6 +85,7 @@ class IdCardWidget : Box
         update_id_card_label();
 
         set_idcard_color();
+        arrow.set(ArrowType.RIGHT, ARROW_SHADOW);
     }
 
     private bool button_press_cb()
@@ -116,15 +121,14 @@ class IdCardWidget : Box
 
             }
         }
-        var state = this.get_state();
-        this.event_box.modify_bg(state, color);
+        this.event_box.modify_bg(StateType.NORMAL, color);
+        this.arrow.modify_bg(StateType.NORMAL, color);
     }
     
     private void
     update_id_card_label()
     {
         // !!TODO: Use a table to format the labels and values
-        string services_text = _("Services:  ");
         string service_spacer = _("\n                ");
 
         var display_name = (manager_view.selection_in_progress() && this.id_card.is_no_identity()
@@ -133,12 +137,15 @@ class IdCardWidget : Box
 
         if (is_selected)
         {
-            label_text += "\nUsername:  " + id_card.username;
-            label_text += "\nRealm:  " + id_card.issuer;
-            if (!id_card.trust_anchor.is_empty()) {
-                label_text += _("\nTrust anchor: Enterprise provisioned");
+            if (!this.id_card.is_no_identity()) {
+                label_text += "\nUsername:  " + id_card.username;
+                label_text += "\nRealm:  " + id_card.issuer;
+                if (!id_card.trust_anchor.is_empty()) {
+                    label_text += _("\nTrust anchor: Enterprise provisioned");
+                }
             }
-            services_text += this.id_card.get_services_string(service_spacer);
+
+            string services_text = _("Services:  ") + this.id_card.get_services_string(service_spacer);
             label_text += _("\n") + services_text;
         }
 
@@ -150,16 +157,22 @@ class IdCardWidget : Box
         this.id_card = id_card;
         this.manager_view = manager_view;
 
-        var image = new Image.from_pixbuf(get_pixbuf(id_card));
-
         label = new Label(null);
         label.set_alignment((float) 0, (float) 0.5);
         label.set_ellipsize(Pango.EllipsizeMode.END);
         update_id_card_label();
 
         table = new Gtk.HBox(false, 6);
+        var image = new Image.from_pixbuf(get_pixbuf(id_card));
+        if (this.id_card.is_no_identity()) {
+            image.clear();
+            // Use padding to make the image size =  48x48 (size = 2x padding)
+            image.set_padding(24, 24);
+        }
         table.pack_start(image, false, false, 0);
         table.pack_start(label, true, true, 0);
+        this.arrow = new Arrow(ArrowType.RIGHT, ARROW_SHADOW);
+        table.pack_start(arrow, false, false);
 
         this.main_vbox = new VBox(false, 12);
         main_vbox.pack_start(table, true, true, 0);