]> git.lyx.org Git - features.git/blob - src/frontends/gtk/GERT.C
2b558db8ac4d3df467634507902285b454e08217
[features.git] / src / frontends / gtk / GERT.C
1 /**
2  * \file GERT.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Spray
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "GERT.h"
14 #include "ControlERT.h"
15 #include "ghelpers.h"
16
17 #include <libglademm.h>
18
19 using std::string;
20
21 namespace lyx {
22 namespace frontend {
23
24 GERT::GERT(Dialog & parent)
25         : GViewCB<ControlERT, GViewGladeB>(parent, _("TeX Settings"), false)
26 {}
27
28
29 void GERT::doBuild()
30 {
31         string const gladeName = findGladeFile("ERT");
32         xml_ = Gnome::Glade::Xml::create(gladeName);
33
34         Gtk::Button * cancelbutton;
35         xml_->get_widget("Close", cancelbutton);
36         setCancel(cancelbutton);
37
38         xml_->get_widget("Inline", inlineradio_);
39         xml_->get_widget("Open", openradio_);
40         xml_->get_widget("Collapsed", collapsedradio_);
41
42         inlineradio_->signal_toggled().connect(
43                 sigc::mem_fun(*this, &GERT::apply));
44         openradio_->signal_toggled().connect(
45                 sigc::mem_fun(*this, &GERT::apply));
46         collapsedradio_->signal_toggled().connect(
47                 sigc::mem_fun(*this, &GERT::apply));
48
49         bcview().addReadOnly(inlineradio_);
50         bcview().addReadOnly(openradio_);
51         bcview().addReadOnly(collapsedradio_);
52 }
53
54
55 void GERT::update()
56 {
57         applylock_ = true;
58
59         bc().refreshReadOnly();
60
61         switch (controller().status()) {
62         case InsetERT::Open:
63                 openradio_->set_active(true);
64                 break;
65         case InsetERT::Collapsed:
66                 collapsedradio_->set_active(true);
67                 break;
68         case InsetERT::Inlined:
69                 inlineradio_->set_active(true);
70                 break;
71         }
72
73         applylock_ = false;
74 }
75
76
77 void GERT::apply()
78 {
79         if (applylock_)
80                 return;
81
82         if (openradio_->get_active())
83                 controller().setStatus(InsetERT::Open);
84         else if (collapsedradio_->get_active())
85                 controller().setStatus(InsetERT::Collapsed);
86         else
87                 controller().setStatus(InsetERT::Inlined);
88
89         controller().dispatchParams();
90 }
91
92 } // namespace frontend
93 } // namespace lyx