c5de2b75c68da125357db095188937d8460a4c8f
[moonshot-ui.git] / src / moonshot-password-dialog.vala
1 using Gtk;
2
3 class AddPasswordDialog : Dialog
4 {
5     private Entry password_entry;
6
7     public string password {
8         get { return password_entry.get_text (); }
9     }
10
11     public AddPasswordDialog ()
12     {
13         this.set_title (_("Please enter your password"));
14         this.set_modal (true);
15
16         this.add_buttons (_("Send"), ResponseType.OK,
17                           _("Return to application"), ResponseType.CANCEL);
18
19         var content_area = this.get_content_area ();
20         ((Box) content_area).set_spacing (12);
21
22         var password_label = new Label (_("Password:"));
23         password_label.set_alignment (1, (float) 0.5);
24         this.password_entry = new Entry ();
25         password_entry.set_invisible_char ('*');
26         password_entry.set_visibility (false);
27         var remember_checkbutton = new CheckButton.with_label (_("Remember password"));
28
29         set_atk_relation (password_entry, password_entry, Atk.RelationType.LABEL_FOR);
30
31         var table = new Table (2, 2, false);
32         table.set_col_spacings (10);
33         table.set_row_spacings (10);
34         table.attach_defaults (password_label, 0, 1, 2, 3);
35         table.attach_defaults (password_entry, 1, 2, 2, 3);
36         table.attach_defaults (remember_checkbutton,  1, 2, 3, 4);
37
38         var vbox = new VBox (false, 0);
39         vbox.set_border_width (6);
40         vbox.pack_start (table, false, false, 0);
41
42         ((Container) content_area).add (vbox);
43
44         this.set_border_width (6);
45         this.set_resizable (false);
46         this.show_all ();
47     }
48
49     private void set_atk_relation (Widget widget, Widget target_widget, Atk.RelationType relationship)
50     {
51         var atk_widget = widget.get_accessible ();
52         var atk_target_widget = target_widget.get_accessible ();
53
54         atk_widget.add_relationship (relationship, atk_target_widget);
55     }
56 }