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