Change about Gtk.Dialog.vbox in Gtk 3.0
[valaterm:valaterm.git] / src / parameters-window.vala
1 /****************************
2 ** Copyright © 2011 Jacques-Pascal Deplaix
3 **
4 ** ValaTerm is free software: you can redistribute it and/or modify
5 ** it under the terms of the GNU General Public License as published by
6 ** the Free Software Foundation, either version 3 of the License, or
7 ** (at your option) any later version.
8 **
9 ** This program is distributed in the hope that it will be useful,
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 ** GNU General Public License for more details.
13 **
14 ** You should have received a copy of the GNU General Public License
15 ** along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 ****************************/
17
18 public class ParametersWindow : DefaultDialog
19 {
20         private FontButton font_chooser = new FontButton(Settings.font);
21         private ColorButton background_color_chooser = new ColorButton(Settings.background_color);
22         private ColorButton foreground_color_chooser = new ColorButton(Settings.foreground_color);
23         private SpinButton scrollback_lines_chooser = new SpinButton(Settings.scrollback_lines);
24         private CheckButton transparency_chooser = new CheckButton(Settings.transparency);
25
26         public signal void font_changed(string font);
27         public signal void background_color_changed(Gdk.Color color);
28         public signal void foreground_color_changed(Gdk.Color color);
29         public signal void scrollback_lines_changed(long lines);
30         public signal void transparency_changed(bool tranparency);
31
32         public ParametersWindow(MainWindow parent_window)
33         {
34                 this.title = _("ValaTerm Preferences");
35                 this.transient_for = parent_window;
36
37                 var font_box = new ParameterBox(_("Font:"), this.font_chooser);
38
39                 var background_color_box = new ParameterBox(_("Background color:"),
40                                                                                                         this.background_color_chooser);
41
42                 var foreground_color_box = new ParameterBox(_("Foreground color:"),
43                                                                                                         this.foreground_color_chooser);
44
45                 var scrollback_lines_box = new ParameterBox(_("Scrollback lines:"),
46                                                                                                         this.scrollback_lines_chooser);
47
48                 var transparency_box = new ParameterBox(_("Transparency:"),
49                                                                                                 this.transparency_chooser);
50
51                 var main_box = (Gtk.Box)(this.get_content_area());
52                 main_box.pack_start(font_box);
53                 main_box.pack_start(background_color_box);
54                 main_box.pack_start(foreground_color_box);
55                 main_box.pack_start(scrollback_lines_box);
56                 main_box.pack_start(transparency_box);
57         }
58
59         protected override void ok_clicked()
60         {
61                 Settings.font = this.font_chooser.font_name;
62                 this.font_changed(this.font_chooser.font_name);
63
64                 Settings.background_color = this.background_color_chooser.color;
65                 this.background_color_changed(this.background_color_chooser.color);
66
67                 Settings.foreground_color = this.foreground_color_chooser.color;
68                 this.foreground_color_changed(this.foreground_color_chooser.color);
69
70                 Settings.scrollback_lines = this.scrollback_lines_chooser.get_value_as_int();
71                 this.scrollback_lines_changed(this.scrollback_lines_chooser.get_value_as_int());
72
73                 Settings.transparency = this.transparency_chooser.active;
74                 this.transparency_changed(this.transparency_chooser.active);
75         }
76 }