Add the foreground color chooser to the parameters window
[valaterm:valaterm.git] / src / main-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 MainWindow : Gtk.Window
19 {
20         private Menubar menubar = new Menubar();
21         private Terminal terminal = new Terminal();
22
23         public MainWindow()
24         {
25                 this.title = "ValaTerm";
26                 this.icon = new Gdk.Pixbuf.from_xpm_data(Pictures.logo);
27
28                 var scrolled_window = new Gtk.ScrolledWindow(null, null);
29                 scrolled_window.add(this.terminal);
30                 scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
31
32                 var main_box = new Gtk.VBox(false, 1);
33                 main_box.pack_start(this.menubar, false);
34                 main_box.pack_start(scrolled_window);
35
36                 this.active_signals();
37                 this.add(main_box);
38         }
39
40         public void display()
41         {
42                 this.show_all();
43                 this.resize(this.terminal.calcul_width(80), this.terminal.calcul_height(24));
44         }
45
46         private void active_signals()
47         {
48                 this.menubar.active_signals(this.add_accel_group,
49                                                                         () => About.display(this),
50                                                                         () => ConfigurationsWindow.display(this,
51                                                                                                                                            (font) => this.terminal.set_font_from_string(font),
52                                                                                                                                            (color) => this.terminal.set_color_background(color),
53                                                                                                                                            (color) => this.terminal.set_color_foreground(color)),
54                                                                         () => this.terminal.reset(true, true),
55                                                                         () => this.terminal.copy_clipboard(),
56                                                                         () => this.terminal.paste_clipboard());
57
58                 this.destroy.connect(Gtk.main_quit);
59                 this.terminal.child_exited.connect(Gtk.main_quit);
60
61                 this.terminal.active_signals((title) => this.title = title);
62         }
63 }