]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GPreamble.C
ws changes
[lyx.git] / src / frontends / gnome / GPreamble.C
1 /**
2  * \file GPreamble.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Michael Koziarski
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #ifdef __GNUG__
12 #pragma implementation
13 #endif
14
15 #include <config.h>
16
17 #include "gnomeBC.h"
18 #include "GPreamble.h"
19
20 #include <gtkmm/textview.h>
21 #include <gtkmm/button.h>
22
23 GPreamble::GPreamble(ControlPreamble & c)
24         : GnomeCB<ControlPreamble>(c, "GPreamble")
25 {}
26
27
28 GPreamble::~GPreamble()
29 {}
30
31
32 void GPreamble::build()
33 {
34         // Connect the buttons.
35         ok_btn()->signal_clicked().connect(SigC::slot(*this, &GPreamble::OKClicked));
36         cancel_btn()->signal_clicked().connect(SigC::slot(*this, &GPreamble::CancelClicked));
37         apply_btn()->signal_clicked().connect(SigC::slot(*this, &GPreamble::ApplyClicked));
38         // Manage the buttons state
39         bc().setOK(ok_btn());
40         bc().setCancel(cancel_btn());
41         bc().setApply(apply_btn());
42         bc().refresh();
43 }
44
45 void GPreamble::apply()
46 {
47         controller().params() = preamble()->get_buffer()->get_text(preamble()->get_buffer()->get_start_iter(),
48                                                                    preamble()->get_buffer()->get_end_iter(),
49                                                                    false);
50 }
51
52
53 void GPreamble::update()
54 {
55         disconnect_signals();
56         preamble()->get_buffer()->set_text(controller().params());
57         connect_signals();
58 }
59
60 void GPreamble::connect_signals()
61 {
62         slot_preamble_ = preamble()->
63                 get_buffer()->
64                 signal_changed().connect(SigC::slot(*this, &GPreamble::InputChanged));
65 }
66
67 void GPreamble::disconnect_signals()
68 {
69         slot_preamble_.disconnect();
70 }
71
72 Gtk::Button * GPreamble::ok_btn() const
73 {
74         return getWidget<Gtk::Button>("r_ok_btn");
75 }
76 Gtk::Button * GPreamble::apply_btn() const
77 {
78         return getWidget<Gtk::Button>("r_apply_btn");
79 }
80 Gtk::Button * GPreamble::cancel_btn() const
81 {
82         return getWidget<Gtk::Button>("r_cancel_btn");
83 }
84 Gtk::TextView * GPreamble::preamble() const
85 {
86         return getWidget<Gtk::TextView>("r_preamble");
87 }