~ubuntu-branches/ubuntu/saucy/geary/saucy-updates

« back to all changes in this revision

Viewing changes to src/client/accounts/login-dialog.vala

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-03-14 13:48:23 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130314134823-gyk5av1g508zyj8a
Tags: 0.3.0~pr1-0ubuntu1
New upstream version (FFE lp: #1154316), supports multiple account as
well as full conversation views with inline replies

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2011-2013 Yorba Foundation
 
2
 *
 
3
 * This software is licensed under the GNU Lesser General Public License
 
4
 * (version 2.1 or later).  See the COPYING file in this distribution.
 
5
 */
 
6
 
 
7
// Displays a dialog for collecting the user's login data.
 
8
public class LoginDialog : Gtk.Dialog {
 
9
    private Gtk.Button ok_button;
 
10
    private Gtk.Button cancel_button;
 
11
    private AddEditPage page = new AddEditPage();
 
12
    private AccountSpinnerPage spinner_page = new AccountSpinnerPage();
 
13
    
 
14
    public LoginDialog() {
 
15
        Object();
 
16
        set_type_hint(Gdk.WindowTypeHint.DIALOG);
 
17
        set_size_request(450, -1); // Sets min width.
 
18
        
 
19
        page.margin = 5;
 
20
        spinner_page.margin = 5;
 
21
        get_content_area().pack_start(page, true, true, 0);
 
22
        get_content_area().pack_start(spinner_page, true, true, 0);
 
23
        spinner_page.visible = false;
 
24
        page.size_changed.connect(() => { resize(1, 1); });
 
25
        page.info_changed.connect(on_info_changed);
 
26
        
 
27
        cancel_button = new Gtk.Button.from_stock(Gtk.Stock.CANCEL);
 
28
        add_action_widget(cancel_button, Gtk.ResponseType.CANCEL);
 
29
        ok_button = new Gtk.Button.from_stock(Gtk.Stock.ADD);
 
30
        ok_button.can_default = true;
 
31
        add_action_widget(ok_button, Gtk.ResponseType.OK);
 
32
        set_default_response(Gtk.ResponseType.OK);
 
33
        get_action_area().show_all();
 
34
        
 
35
        on_info_changed();
 
36
    }
 
37
    
 
38
    public LoginDialog.from_account_information(Geary.AccountInformation initial_account_information) {
 
39
        this();
 
40
        set_account_information(initial_account_information);
 
41
    }
 
42
    
 
43
    public void set_account_information(Geary.AccountInformation info,
 
44
        Geary.Engine.ValidationResult result = Geary.Engine.ValidationResult.OK) {
 
45
        page.set_account_information(info, result);
 
46
        page.update_ui();
 
47
    }
 
48
    
 
49
    public Geary.AccountInformation get_account_information() {
 
50
        return page.get_account_information();
 
51
    }
 
52
 
 
53
    private void on_info_changed() {
 
54
        if (!spinner_page.visible)
 
55
            ok_button.sensitive = page.is_complete();
 
56
        else
 
57
            ok_button.sensitive = false;
 
58
    }
 
59
    
 
60
    // Switches between the account page and the busy spinner.
 
61
    public void show_spinner(bool visible) {
 
62
        spinner_page.visible = visible;
 
63
        page.visible = !visible;
 
64
        cancel_button.sensitive = !visible;
 
65
        on_info_changed(); // sets OK button sensitivity
 
66
    }
 
67
}
 
68