~julien-spautz/cable/model-view

« back to all changes in this revision

Viewing changes to src/Dialogs/ManageNetwork.vala

  • Committer: Julien Spautz
  • Date: 2013-07-30 00:52:16 UTC
  • Revision ID: spautz.julien@gmail.com-20130730005216-chro25g4728950sd
fixed issued with renaming, some internal changes, created autoscrolled class, stub controller class

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
     * a new one.
33
33
     */
34
34
    public ManageNetwork (Settings.Network? network = null) {
 
35
        var new_network = network == null;
 
36
        var in_use = (new_network) ? false : network.servers.size > 0;
 
37
    
35
38
        this.modal = true;
36
39
        this.window_position = Gtk.WindowPosition.CENTER;
37
40
        
43
46
        var address = new Gtk.Entry ();
44
47
        address.placeholder_text = _("irc.network.net");
45
48
        address.width_request = 250;
 
49
        address.sensitive = !in_use;
 
50
        
46
51
        var name = new Gtk.Entry ();
47
52
        name.placeholder_text = _("Network IRC");
 
53
        
48
54
        var password = new Gtk.Entry ();
49
55
        password.placeholder_text = _("Optional");
50
56
        password.caps_lock_warning = true;
51
57
        password.set_visibility (false);
52
58
 
53
 
        grid.attach (new Utils.Label.right (_("Address:")), 0, 0, 1, 1);
 
59
        grid.attach (new Utils.Label.right (_("Address:"), !in_use), 0, 0, 1, 1);
54
60
        grid.attach (address, 1, 0, 1, 1);
55
61
        grid.attach (new Utils.Label.right (_("Name:")), 0, 1, 1, 1);
56
62
        grid.attach (name, 1, 1, 1, 1);
59
65
 
60
66
        var cancel_button = new Gtk.Button.from_stock (Gtk.Stock.CANCEL);
61
67
        Gtk.Button apply_button;
 
68
        
62
69
        if (network == null) {
63
70
            apply_button = new Gtk.Button.from_stock (Gtk.Stock.ADD);
64
71
            apply_button.get_style_context ().add_class ("affirmative");
65
 
        } else
 
72
        } else {
66
73
            apply_button = new Gtk.Button.from_stock (Gtk.Stock.APPLY);
 
74
        }
 
75
        
67
76
        apply_button.sensitive = (network != null);
68
77
        
69
78
        var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
74
83
        grid.attach (button_box, 0, 3, 2, 1);
75
84
 
76
85
        this.add (grid);
77
 
        this.title = (network == null) ? _("Add Network")
78
 
                                        : _("Change Network");
 
86
        this.title = (network == null) ? _("Add Network") : _("Edit Network");
79
87
 
80
88
        if (network != null) {
81
89
            address.text = network.address;
102
110
        });
103
111
    }
104
112
 
105
 
    Settings.Network create_network (string address, string name,
106
 
                                       string password)
 
113
    Settings.Network create_network (string address, string name, string password)
107
114
        requires (address.strip () != "") {
108
115
 
109
116
        if (address.strip () == "")