]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GPreamble.C
fix bug 391, parrot patch from herbert
[lyx.git] / src / frontends / gnome / GPreamble.C
1 /* This file is part of
2  * =================================================
3  * 
4  *          LyX, The Document Processor
5  *          Copyright 1995-2000 The LyX Team.
6  *
7  * ================================================= 
8  *
9  * \author Michael Koziarski 
10  */
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17
18 #include "gnomeBC.h"
19 #include "GPreamble.h"
20
21 #include <gtk--/text.h>
22 #include <gtk--/button.h>
23
24 GPreamble::GPreamble(ControlPreamble & c)
25         : FormCB<ControlPreamble>(c, "GPreamble")
26 {}
27
28
29 GPreamble::~GPreamble()
30 {}
31
32
33 void GPreamble::build()
34 {
35         // Connect the buttons.
36         ok_btn()->clicked.connect(SigC::slot(this, &GPreamble::OKClicked));
37         cancel_btn()->clicked.connect(SigC::slot(this, &GPreamble::CancelClicked));
38         apply_btn()->clicked.connect(SigC::slot(this, &GPreamble::ApplyClicked));
39         // Manage the buttons state
40         bc().setOK(ok_btn());
41         bc().setCancel(cancel_btn());
42         bc().setApply(apply_btn());
43         bc().refresh();
44 }
45
46 void GPreamble::apply()
47 {
48         controller().params() = preamble()->get_chars(0,-1);
49 }
50
51
52 void GPreamble::update()
53 {
54         disconnect_signals();
55         preamble()->set_point(0);
56         preamble()->forward_delete(preamble()->get_length());
57         preamble()->insert(controller().params());
58         connect_signals();
59 }
60
61 void GPreamble::connect_signals()
62 {
63         slot_preamble_ = preamble()->changed.connect(SigC::slot(this, &GPreamble::InputChanged));
64 }
65
66 void GPreamble::disconnect_signals() 
67 {
68         slot_preamble_.disconnect();
69 }
70
71 Gtk::Button * GPreamble::ok_btn() const 
72 {
73         return getWidget<Gtk::Button>("r_ok_btn");
74 }
75 Gtk::Button * GPreamble::apply_btn() const 
76 {
77         return getWidget<Gtk::Button>("r_apply_btn");
78 }
79 Gtk::Button * GPreamble::cancel_btn() const 
80 {
81         return getWidget<Gtk::Button>("r_cancel_btn");
82 }
83 Gtk::Text * GPreamble::preamble() const 
84 {
85         return getWidget<Gtk::Text>("r_preamble");
86 }