windows: send correct data in response to get identity
[moonshot-ui.git] / src / moonshot-add-dialog.vala
index 233d1ff..141f788 100644 (file)
@@ -2,9 +2,15 @@ using Gtk;
 
 class AddIdentityDialog : Dialog
 {
+    private Entry displayname_entry;
     private Entry issuer_entry;
     private Entry username_entry;
     private Entry password_entry;
+    private CheckButton remember_checkbutton;
+    
+    public string display_name {
+        get { return displayname_entry.get_text(); }
+    }
 
     public string issuer {
         get { return issuer_entry.get_text (); }
@@ -18,17 +24,28 @@ class AddIdentityDialog : Dialog
         get { return password_entry.get_text (); }
     }
 
+    public bool store_password {
+        get { return remember_checkbutton.active; }
+    }
+
     public AddIdentityDialog ()
     {
         this.set_title (_("Add ID Card"));
         this.set_modal (true);
 
         this.add_buttons (_("Add ID Card"), ResponseType.OK,
+#if VALA_0_12
                           Stock.CANCEL, ResponseType.CANCEL);
+#else
+                          STOCK_CANCEL, ResponseType.CANCEL);
+#endif
 
         var content_area = this.get_content_area ();
         ((Box) content_area).set_spacing (12);
-
+        
+        var displayname_label = new Label (_("Display Name:"));
+        displayname_label.set_alignment (1, (float) 0.5);
+        displayname_entry = new Entry ();
         var issuer_label = new Label (_("Issuer:"));
         issuer_label.set_alignment (1, (float) 0.5);
         this.issuer_entry = new Entry ();
@@ -40,17 +57,26 @@ class AddIdentityDialog : Dialog
         this.password_entry = new Entry ();
         password_entry.set_invisible_char ('*');
         password_entry.set_visibility (false);
-        var remember_checkbutton = new CheckButton.with_label (_("Remember password"));
-        var table = new Table (4, 4, false);
+        this.remember_checkbutton = new CheckButton.with_label (_("Remember password"));
+
+        set_atk_relation (displayname_label, displayname_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation (issuer_label, issuer_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation (username_label, username_entry, Atk.RelationType.LABEL_FOR);
+        set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
+
+        var table = new Table (5, 5, false);
         table.set_col_spacings (10);
         table.set_row_spacings (10);
-        table.attach_defaults (issuer_label, 0, 1, 0, 1);
-        table.attach_defaults (issuer_entry, 1, 2, 0, 1);
-        table.attach_defaults (username_label, 0, 1, 1, 2);
-        table.attach_defaults (username_entry, 1, 2, 1, 2);
-        table.attach_defaults (password_label, 0, 1, 2, 3);
-        table.attach_defaults (password_entry, 1, 2, 2, 3);
-        table.attach_defaults (remember_checkbutton,  1, 2, 3, 4);
+        
+        table.attach_defaults (displayname_label, 0, 1, 0, 1);
+        table.attach_defaults (displayname_entry, 1, 2, 0, 1);
+        table.attach_defaults (issuer_label, 0, 1, 1, 2);
+        table.attach_defaults (issuer_entry, 1, 2, 1, 2);
+        table.attach_defaults (username_label, 0, 1, 2, 3);
+        table.attach_defaults (username_entry, 1, 2, 2, 3);
+        table.attach_defaults (password_label, 0, 1, 3, 4);
+        table.attach_defaults (password_entry, 1, 2, 3, 4);
+        table.attach_defaults (remember_checkbutton,  1, 2, 4, 5);
 
         var vbox = new VBox (false, 0);
         vbox.set_border_width (6);
@@ -62,4 +88,12 @@ class AddIdentityDialog : Dialog
         this.set_resizable (false);
         this.show_all ();
     }
+
+    private void set_atk_relation (Widget widget, Widget target_widget, Atk.RelationType relationship)
+    {
+        var atk_widget = widget.get_accessible ();
+        var atk_target_widget = target_widget.get_accessible ();
+
+        atk_widget.add_relationship (relationship, atk_target_widget);
+    }
 }