~l-admin-3/evnc/automatic-cleanup-branch

« back to all changes in this revision

Viewing changes to src/Dialogs/ConnectDialog.vala

  • Committer: Marcus Wichelmann
  • Date: 2015-07-09 18:17:05 UTC
  • Revision ID: marcus.wichelmann@hotmail.de-20150709181705-aliu5vv3gvha1p0a
Automatic code cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
*/
18
18
 
19
19
namespace evnc.Dialogs {
20
 
        public class ConnectDialog : Gtk.Dialog {
21
 
                private Gtk.Box box;
22
 
 
23
 
                private Gtk.Grid grid_input;
24
 
 
25
 
                private Gtk.Label label_host;
26
 
                public Gtk.Entry entry_host;
27
 
 
28
 
                private Gtk.Label label_port;
29
 
                public Gtk.Entry entry_port;
30
 
 
31
 
                private Gtk.Label label_user;
32
 
                public Gtk.Entry entry_user;
33
 
 
34
 
                public Gtk.CheckButton btn_bookmark;
35
 
                public Gtk.Entry entry_bookmark;
36
 
 
37
 
                private Gtk.Button btn_connect;
38
 
 
39
 
                public ConnectDialog () {
40
 
                        this.title = _("Connection set-up");
41
 
                        this.resizable = false;
42
 
                        this.set_modal (true);
43
 
 
44
 
                        setup_ui ();
45
 
 
46
 
                        connect_events ();
47
 
 
48
 
                        this.show_all ();
49
 
                }
50
 
 
51
 
                private void setup_ui () {
52
 
                        box = this.get_content_area () as Gtk.Box;
53
 
 
54
 
                        grid_input = new Gtk.Grid ();
55
 
                        grid_input.margin = 12;
56
 
                        grid_input.column_spacing = 12;
57
 
 
58
 
                        label_host = new Gtk.Label (_("Hostname:"));
59
 
                        label_port = new Gtk.Label (_("Port:"));
60
 
                        label_user = new Gtk.Label (_("Username:"));
61
 
 
62
 
                        label_host.hexpand = true;
63
 
                        label_port.hexpand = true;
64
 
                        label_user.hexpand = true;
65
 
                        label_host.halign = Gtk.Align.END;
66
 
                        label_port.halign = Gtk.Align.END;
67
 
                        label_user.halign = Gtk.Align.END;
68
 
 
69
 
                        grid_input.attach (label_host, 0, 0, 1, 1);
70
 
                        grid_input.attach (label_port, 0, 1, 1, 1);
71
 
                        grid_input.attach (label_user, 0, 2, 1, 1);
72
 
 
73
 
                        entry_host = new Gtk.Entry ();
74
 
                        entry_port = new Gtk.Entry ();
75
 
                        entry_user = new Gtk.Entry ();
76
 
 
77
 
                        entry_host.set_hexpand (true);
78
 
                        entry_port.set_hexpand (true);
79
 
                        entry_user.set_hexpand (true);
80
 
 
81
 
                        entry_host.set_placeholder_text (_("e.g.: joe-pc"));
82
 
                        entry_port.set_placeholder_text (_("e.g.: 5900"));
83
 
                        entry_user.set_placeholder_text (_("e.g.: joe"));
84
 
 
85
 
                        entry_port.set_text ("5900");
86
 
 
87
 
                        grid_input.attach (entry_host, 1, 0, 1, 1);
88
 
                        grid_input.attach (entry_port, 1, 1, 1, 1);
89
 
                        grid_input.attach (entry_user, 1, 2, 1, 1);
90
 
 
91
 
                        btn_bookmark = new Gtk.CheckButton.with_label (_("New Bookmark:"));
92
 
                        btn_bookmark.set_margin_top (6);
93
 
                        entry_bookmark = new Gtk.Entry ();
94
 
                        entry_bookmark.set_margin_top (6);
95
 
                        entry_bookmark.set_hexpand (true);
96
 
                        entry_bookmark.sensitive = false;
97
 
                        entry_bookmark.set_placeholder_text (_("optional"));
98
 
 
99
 
                        grid_input.attach (btn_bookmark, 0, 3, 1, 1);
100
 
                        grid_input.attach (entry_bookmark, 1, 3, 1, 1);
101
 
                        grid_input.row_spacing = 12;
102
 
 
103
 
                        box.pack_start (grid_input);
104
 
 
105
 
                        this.add_button (_("Cancel"), Gtk.ResponseType.CLOSE);
106
 
 
107
 
                        btn_connect = this.add_button (_("Connect"), Gtk.ResponseType.APPLY) as Gtk.Button;
108
 
                        btn_connect.get_style_context ().add_class ("suggested-action");
109
 
                }
110
 
 
111
 
                private void connect_events () {
112
 
                        btn_bookmark.toggled.connect (() => {
113
 
                                if (btn_bookmark.active) {
114
 
                                        btn_connect.label = _("Save and connect");
115
 
                                        entry_bookmark.sensitive = true;
116
 
                                } else {
117
 
                                        btn_connect.label = _("Connect");
118
 
                                        entry_bookmark.sensitive = false;
119
 
                                }
120
 
                        });
121
 
                }
122
 
        }
 
20
    public class ConnectDialog : Gtk.Dialog {
 
21
        private Gtk.Box box;
 
22
 
 
23
        private Gtk.Grid grid_input;
 
24
 
 
25
        private Gtk.Label label_host;
 
26
        public Gtk.Entry entry_host;
 
27
 
 
28
        private Gtk.Label label_port;
 
29
        public Gtk.Entry entry_port;
 
30
 
 
31
        private Gtk.Label label_user;
 
32
        public Gtk.Entry entry_user;
 
33
 
 
34
        public Gtk.CheckButton btn_bookmark;
 
35
        public Gtk.Entry entry_bookmark;
 
36
 
 
37
        private Gtk.Button btn_connect;
 
38
 
 
39
        public ConnectDialog () {
 
40
            this.title = _ ("Connection set-up");
 
41
            this.resizable = false;
 
42
            this.set_modal (true);
 
43
 
 
44
            setup_ui ();
 
45
 
 
46
            connect_events ();
 
47
 
 
48
            this.show_all ();
 
49
        }
 
50
 
 
51
        private void setup_ui () {
 
52
            box = this.get_content_area () as Gtk.Box;
 
53
 
 
54
            grid_input = new Gtk.Grid ();
 
55
            grid_input.margin = 12;
 
56
            grid_input.column_spacing = 12;
 
57
 
 
58
            label_host = new Gtk.Label (_ ("Hostname:"));
 
59
            label_port = new Gtk.Label (_ ("Port:"));
 
60
            label_user = new Gtk.Label (_ ("Username:"));
 
61
 
 
62
            label_host.hexpand = true;
 
63
            label_port.hexpand = true;
 
64
            label_user.hexpand = true;
 
65
            label_host.halign = Gtk.Align.END;
 
66
            label_port.halign = Gtk.Align.END;
 
67
            label_user.halign = Gtk.Align.END;
 
68
 
 
69
            grid_input.attach (label_host, 0, 0, 1, 1);
 
70
            grid_input.attach (label_port, 0, 1, 1, 1);
 
71
            grid_input.attach (label_user, 0, 2, 1, 1);
 
72
 
 
73
            entry_host = new Gtk.Entry ();
 
74
            entry_port = new Gtk.Entry ();
 
75
            entry_user = new Gtk.Entry ();
 
76
 
 
77
            entry_host.set_hexpand (true);
 
78
            entry_port.set_hexpand (true);
 
79
            entry_user.set_hexpand (true);
 
80
 
 
81
            entry_host.set_placeholder_text (_ ("e.g.: joe-pc"));
 
82
            entry_port.set_placeholder_text (_ ("e.g.: 5900"));
 
83
            entry_user.set_placeholder_text (_ ("e.g.: joe"));
 
84
 
 
85
            entry_port.set_text ("5900");
 
86
 
 
87
            grid_input.attach (entry_host, 1, 0, 1, 1);
 
88
            grid_input.attach (entry_port, 1, 1, 1, 1);
 
89
            grid_input.attach (entry_user, 1, 2, 1, 1);
 
90
 
 
91
            btn_bookmark = new Gtk.CheckButton.with_label (_ ("New Bookmark:"));
 
92
            btn_bookmark.set_margin_top (6);
 
93
            entry_bookmark = new Gtk.Entry ();
 
94
            entry_bookmark.set_margin_top (6);
 
95
            entry_bookmark.set_hexpand (true);
 
96
            entry_bookmark.sensitive = false;
 
97
            entry_bookmark.set_placeholder_text (_ ("optional"));
 
98
 
 
99
            grid_input.attach (btn_bookmark, 0, 3, 1, 1);
 
100
            grid_input.attach (entry_bookmark, 1, 3, 1, 1);
 
101
            grid_input.row_spacing = 12;
 
102
 
 
103
            box.pack_start (grid_input);
 
104
 
 
105
            this.add_button (_ ("Cancel"), Gtk.ResponseType.CLOSE);
 
106
 
 
107
            btn_connect = this.add_button (_ ("Connect"), Gtk.ResponseType.APPLY) as Gtk.Button;
 
108
            btn_connect.get_style_context ().add_class ("suggested-action");
 
109
        }
 
110
 
 
111
        private void connect_events () {
 
112
            btn_bookmark.toggled.connect (() => {
 
113
                if (btn_bookmark.active) {
 
114
                    btn_connect.label = _ ("Save and connect");
 
115
                    entry_bookmark.sensitive = true;
 
116
                } else {
 
117
                    btn_connect.label = _ ("Connect");
 
118
                    entry_bookmark.sensitive = false;
 
119
                }
 
120
            });
 
121
        }
 
122
    }
123
123
}
 
 
b'\\ No newline at end of file'