Add copyright to source code
[moonshot-ui.git] / src / moonshot-password-dialog.vala
index 35f239b..772d12c 100644 (file)
@@ -1,3 +1,34 @@
+/*
+ * Copyright (c) 2011-2014, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+*/
 using Gtk;
 
 class AddPasswordDialog : Dialog
@@ -13,17 +44,35 @@ class AddPasswordDialog : Dialog
         get { return remember_checkbutton.get_active (); }
     }
 
-    public AddPasswordDialog ()
+    public AddPasswordDialog (IdCard id_card, IdentityRequest? request)
     {
-        this.set_title (_("Please enter your password"));
+        this.set_title (_("Please enter password for ") + id_card.display_name);
         this.set_modal (true);
 
-        this.add_buttons (_("Send"), ResponseType.OK,
-                          _("Return to application"), ResponseType.CANCEL);
+       if (request != null) {
+            this.add_buttons (_("Send"), ResponseType.OK,
+                              _("Return to application"), ResponseType.CANCEL);
+        } else {
+            this.add_buttons (_("Done"), ResponseType.OK,
+                              _("Cancel"), ResponseType.CANCEL);
+        }
         this.set_default_response (ResponseType.OK);
 
         var content_area = this.get_content_area ();
         ((Box) content_area).set_spacing (12);
+        Label service_label = null;
+        Label service_value = null;
+       if (request != null) {
+            service_label = new Label (_("for use with:"));
+            service_label.set_alignment (1, (float) 0.5);
+            service_value = new Label (request.service);
+            service_value.set_alignment (0, (float) 0.5);
+        }
+
+        var nai_label = new Label (_("Network Access Identifier:"));
+        nai_label.set_alignment (1, (float) 0.5);
+        var nai_value = new Label (id_card.nai);
+        nai_value.set_alignment (0, (float) 0.5);
 
         var password_label = new Label (_("Password:"));
         password_label.set_alignment (1, (float) 0.5);
@@ -35,12 +84,22 @@ class AddPasswordDialog : Dialog
 
         set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
 
-        var table = new Table (2, 2, false);
+        var table = new Table (4, 2, false);
+        int row = 0;
         table.set_col_spacings (10);
         table.set_row_spacings (10);
-        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);
+        if (request != null) {
+            table.attach_defaults (service_label, 0, 1, row, row + 1);
+            table.attach_defaults (service_value, 1, 2, row, row + 1);
+            row++;
+        }
+        table.attach_defaults (nai_label, 0, 1, row, row+1);
+        table.attach_defaults (nai_value, 1, 2, row, row+1);
+        row++;
+        table.attach_defaults (password_label, 0, 1, row, row+1);
+        table.attach_defaults (password_entry, 1, 2, row, row+1);
+        row++;
+        table.attach_defaults (remember_checkbutton,  1, 2, row, row+1);
 
         var vbox = new VBox (false, 0);
         vbox.set_border_width (6);
@@ -49,7 +108,7 @@ class AddPasswordDialog : Dialog
         ((Container) content_area).add (vbox);
 
         this.set_border_width (6);
-        this.set_resizable (false);
+        //this.set_resizable (false);
         this.show_all ();
     }