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

« back to all changes in this revision

Viewing changes to src/Dialogs/PreferencesDialog.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 PreferencesDialog : Gtk.Dialog {
21
 
                private SettingsManager options;
22
 
 
23
 
                private Gtk.Box box;
24
 
 
25
 
                private Gtk.Grid main_grid;
26
 
 
27
 
                private Gtk.Switch switch_save_new_servers;
28
 
                private Gtk.Switch switch_pointer_local;
29
 
                private Gtk.Switch switch_use_dark_theme;
30
 
                private Gtk.Switch switch_lossy_encoding;
31
 
                private Gtk.ComboBoxText combo_color_depth;
32
 
 
33
 
                public PreferencesDialog () {
34
 
                        options = new SettingsManager ();
35
 
 
36
 
                        this.title = _("Preferences");
37
 
                        this.border_width = 5;
38
 
                        this.resizable = false;
39
 
                        this.set_modal (true);
40
 
 
41
 
                        setup_ui ();
42
 
 
43
 
                        connect_events ();
44
 
 
45
 
                        options.settings.bind("save-new-servers", switch_save_new_servers, "active", SettingsBindFlags.DEFAULT);
46
 
                        options.settings.bind("pointer-local", switch_pointer_local, "active", SettingsBindFlags.DEFAULT);
47
 
                        options.settings.bind("use-dark-theme", switch_use_dark_theme, "active", SettingsBindFlags.DEFAULT);
48
 
                        options.settings.bind("lossy-encoding", switch_lossy_encoding, "active", SettingsBindFlags.DEFAULT);
49
 
 
50
 
                        var new_value = 0;
51
 
                        switch (options.color_depth) {
52
 
                                case "default":
53
 
                                        new_value = 0;
54
 
                                        break;
55
 
                                case "full":
56
 
                                        new_value = 1;
57
 
                                        break;
58
 
                                case "medium":
59
 
                                        new_value = 2;
60
 
                                        break;
61
 
                                case "low":
62
 
                                        new_value = 3;
63
 
                                        break;
64
 
                                case "ultra low":
65
 
                                        new_value = 4;
66
 
                                        break;
67
 
                        }
68
 
                        combo_color_depth.set_active (new_value);
69
 
 
70
 
                        this.show_all ();
71
 
                }
72
 
 
73
 
                private void setup_ui () {
74
 
                        box = this.get_content_area () as Gtk.Box;
75
 
 
76
 
                        main_grid = new Gtk.Grid ();
77
 
                        main_grid.margin = 12;
78
 
                        main_grid.column_spacing = 12;
79
 
                        main_grid.row_spacing = 12;
80
 
 
81
 
                        main_grid.attach (new AlignLabel (_("Save new servers:")), 0, 0, 1, 1);
82
 
                        switch_save_new_servers = new Gtk.Switch ();
83
 
                        switch_save_new_servers.halign = Gtk.Align.START;
84
 
                        main_grid.attach (switch_save_new_servers, 1, 0, 1, 1);
85
 
 
86
 
                        main_grid.attach (new AlignLabel (_("Use the local pointer:")), 0, 1, 1, 1);
87
 
                        switch_pointer_local = new Gtk.Switch ();
88
 
                        switch_pointer_local.halign = Gtk.Align.START;
89
 
                        main_grid.attach (switch_pointer_local, 1, 1, 1, 1);
90
 
 
91
 
                        main_grid.attach (new AlignLabel (_("Use the dark theme:")), 0, 2, 1, 1);
92
 
                        switch_use_dark_theme = new Gtk.Switch ();
93
 
                        switch_use_dark_theme.halign = Gtk.Align.START;
94
 
                        main_grid.attach (switch_use_dark_theme, 1, 2, 1, 1);
95
 
 
96
 
                        main_grid.attach (new AlignLabel (_("Use the lossy encoding:")), 0, 3, 1, 1);
97
 
                        switch_lossy_encoding = new Gtk.Switch ();
98
 
                        switch_lossy_encoding.halign = Gtk.Align.START;
99
 
                        main_grid.attach (switch_lossy_encoding, 1, 3, 1, 1);
100
 
 
101
 
                        main_grid.attach (new AlignLabel (_("Color depth:")), 0, 4, 1, 1);
102
 
                        combo_color_depth = new Gtk.ComboBoxText ();
103
 
                        combo_color_depth.append_text (_("Server configuration"));
104
 
                        combo_color_depth.append_text (_("True quality (24bit)"));
105
 
                        combo_color_depth.append_text (_("High quality (16bit)"));
106
 
                        combo_color_depth.append_text (_("Low quality (8bit)"));
107
 
                        combo_color_depth.append_text (_("Ultra low quality (3bit)"));
108
 
                        main_grid.attach (combo_color_depth, 1, 4, 1, 1);
109
 
 
110
 
                        box.pack_start (main_grid);
111
 
 
112
 
                        this.add_button (_("Close"), Gtk.ResponseType.CLOSE);
113
 
                }
114
 
 
115
 
                private void connect_events () {
116
 
                        combo_color_depth.changed.connect (() => {
117
 
                                var new_value = "default";
118
 
                                switch (combo_color_depth.get_active ()) {
119
 
                                        case 0:
120
 
                                                new_value = "default";
121
 
                                                break;
122
 
                                        case 1:
123
 
                                                new_value = "full";
124
 
                                                break;
125
 
                                        case 2:
126
 
                                                new_value = "medium";
127
 
                                                break;
128
 
                                        case 3:
129
 
                                                new_value = "low";
130
 
                                                break;
131
 
                                        case 4:
132
 
                                                new_value = "ultra low";
133
 
                                                break;
134
 
                                }
135
 
                                options.color_depth = new_value;
136
 
                        });
137
 
                }
138
 
        }
139
 
 
140
 
        public class AlignLabel : Gtk.Label
141
 
        {
142
 
                public AlignLabel (string text) {
143
 
                        this.hexpand = true;
144
 
                        this.halign = Gtk.Align.END;
145
 
                        this.label = text;
146
 
                }
147
 
        }
 
20
    public class PreferencesDialog : Gtk.Dialog {
 
21
        private SettingsManager options;
 
22
 
 
23
        private Gtk.Box box;
 
24
 
 
25
        private Gtk.Grid main_grid;
 
26
 
 
27
        private Gtk.Switch switch_save_new_servers;
 
28
        private Gtk.Switch switch_pointer_local;
 
29
        private Gtk.Switch switch_use_dark_theme;
 
30
        private Gtk.Switch switch_lossy_encoding;
 
31
        private Gtk.ComboBoxText combo_color_depth;
 
32
 
 
33
        public PreferencesDialog () {
 
34
            options = new SettingsManager ();
 
35
 
 
36
            this.title = _ ("Preferences");
 
37
            this.border_width = 5;
 
38
            this.resizable = false;
 
39
            this.set_modal (true);
 
40
 
 
41
            setup_ui ();
 
42
 
 
43
            connect_events ();
 
44
 
 
45
            options.settings.bind ("save-new-servers", switch_save_new_servers, "active", SettingsBindFlags.DEFAULT);
 
46
            options.settings.bind ("pointer-local", switch_pointer_local, "active", SettingsBindFlags.DEFAULT);
 
47
            options.settings.bind ("use-dark-theme", switch_use_dark_theme, "active", SettingsBindFlags.DEFAULT);
 
48
            options.settings.bind ("lossy-encoding", switch_lossy_encoding, "active", SettingsBindFlags.DEFAULT);
 
49
 
 
50
            var new_value = 0;
 
51
 
 
52
            switch (options.color_depth) {
 
53
                case "default":
 
54
                    new_value = 0;
 
55
                    break;
 
56
 
 
57
                case "full":
 
58
                    new_value = 1;
 
59
                    break;
 
60
 
 
61
                case "medium":
 
62
                    new_value = 2;
 
63
                    break;
 
64
 
 
65
                case "low":
 
66
                    new_value = 3;
 
67
                    break;
 
68
 
 
69
                case "ultra low":
 
70
                    new_value = 4;
 
71
                    break;
 
72
            }
 
73
 
 
74
            combo_color_depth.set_active (new_value);
 
75
 
 
76
            this.show_all ();
 
77
        }
 
78
 
 
79
        private void setup_ui () {
 
80
            box = this.get_content_area () as Gtk.Box;
 
81
 
 
82
            main_grid = new Gtk.Grid ();
 
83
            main_grid.margin = 12;
 
84
            main_grid.column_spacing = 12;
 
85
            main_grid.row_spacing = 12;
 
86
 
 
87
            main_grid.attach (new AlignLabel (_ ("Save new servers:")), 0, 0, 1, 1);
 
88
            switch_save_new_servers = new Gtk.Switch ();
 
89
            switch_save_new_servers.halign = Gtk.Align.START;
 
90
            main_grid.attach (switch_save_new_servers, 1, 0, 1, 1);
 
91
 
 
92
            main_grid.attach (new AlignLabel (_ ("Use the local pointer:")), 0, 1, 1, 1);
 
93
            switch_pointer_local = new Gtk.Switch ();
 
94
            switch_pointer_local.halign = Gtk.Align.START;
 
95
            main_grid.attach (switch_pointer_local, 1, 1, 1, 1);
 
96
 
 
97
            main_grid.attach (new AlignLabel (_ ("Use the dark theme:")), 0, 2, 1, 1);
 
98
            switch_use_dark_theme = new Gtk.Switch ();
 
99
            switch_use_dark_theme.halign = Gtk.Align.START;
 
100
            main_grid.attach (switch_use_dark_theme, 1, 2, 1, 1);
 
101
 
 
102
            main_grid.attach (new AlignLabel (_ ("Use the lossy encoding:")), 0, 3, 1, 1);
 
103
            switch_lossy_encoding = new Gtk.Switch ();
 
104
            switch_lossy_encoding.halign = Gtk.Align.START;
 
105
            main_grid.attach (switch_lossy_encoding, 1, 3, 1, 1);
 
106
 
 
107
            main_grid.attach (new AlignLabel (_ ("Color depth:")), 0, 4, 1, 1);
 
108
            combo_color_depth = new Gtk.ComboBoxText ();
 
109
            combo_color_depth.append_text (_ ("Server configuration"));
 
110
            combo_color_depth.append_text (_ ("True quality (24bit)"));
 
111
            combo_color_depth.append_text (_ ("High quality (16bit)"));
 
112
            combo_color_depth.append_text (_ ("Low quality (8bit)"));
 
113
            combo_color_depth.append_text (_ ("Ultra low quality (3bit)"));
 
114
            main_grid.attach (combo_color_depth, 1, 4, 1, 1);
 
115
 
 
116
            box.pack_start (main_grid);
 
117
 
 
118
            this.add_button (_ ("Close"), Gtk.ResponseType.CLOSE);
 
119
        }
 
120
 
 
121
        private void connect_events () {
 
122
            combo_color_depth.changed.connect (() => {
 
123
                var new_value = "default";
 
124
 
 
125
                switch (combo_color_depth.get_active ()) {
 
126
                    case 0:
 
127
                        new_value = "default";
 
128
                        break;
 
129
 
 
130
                    case 1:
 
131
                        new_value = "full";
 
132
                        break;
 
133
 
 
134
                    case 2:
 
135
                        new_value = "medium";
 
136
                        break;
 
137
 
 
138
                    case 3:
 
139
                        new_value = "low";
 
140
                        break;
 
141
 
 
142
                    case 4:
 
143
                        new_value = "ultra low";
 
144
                        break;
 
145
                }
 
146
 
 
147
                options.color_depth = new_value;
 
148
            });
 
149
        }
 
150
    }
 
151
 
 
152
    public class AlignLabel : Gtk.Label
 
153
    {
 
154
        public AlignLabel (string text) {
 
155
            this.hexpand = true;
 
156
            this.halign = Gtk.Align.END;
 
157
            this.label = text;
 
158
        }
 
159
    }
148
160
}
 
 
b'\\ No newline at end of file'