]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GERT.C
A lean, clean and working start to the new, improved gnome frontend.
[lyx.git] / src / frontends / gnome / GERT.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 <michael@koziarski.org>
10  */
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17
18 #include "gnomeBC.h"
19 #include "GERT.h"
20
21 #include <gtk--/radiobutton.h>
22 #include <gtk--/button.h>
23
24 FormERT::FormERT(ControlERT & c)
25         : FormCB<ControlERT>(c, "FormERT")
26 {}
27
28
29 FormERT::~FormERT()
30 {}
31
32
33 void FormERT::build()
34 {
35         // Connect the buttons.
36         ok_btn()->clicked.connect(SigC::slot(this, &FormERT::OKClicked));
37         cancel_btn()->clicked.connect(SigC::slot(this, &FormERT::CancelClicked));
38         apply_btn()->clicked.connect(SigC::slot(this, &FormERT::ApplyClicked));
39
40         // Manage the buttons state
41         bc().setOK(ok_btn());
42         bc().setCancel(cancel_btn());
43         bc().setApply(apply_btn());
44
45         // Make sure everything is in the correct state.
46         bc().refresh();
47         
48         // Manage the read-only aware widgets.
49         bc().addReadOnly(open());
50         bc().addReadOnly(inlined());
51         bc().addReadOnly(collapsed());
52
53 }
54
55
56 void FormERT::connect_signals()
57 {
58         slot_open = open()->clicked.connect(SigC::slot(this, &FormERT::InputChanged));
59         slot_collapsed = collapsed()->clicked.connect(SigC::slot(this, &FormERT::InputChanged));
60         slot_inlined = inlined()->clicked.connect(SigC::slot(this, &FormERT::InputChanged));
61 }
62
63
64 void FormERT::disconnect_signals()
65 {
66         slot_open.disconnect();
67         slot_collapsed.disconnect();
68         slot_inlined.disconnect();
69 }
70
71
72 void FormERT::apply()
73 {
74
75         if (open()->get_active())
76                 controller().params().status = InsetERT::Open;
77         else if (collapsed()->get_active())
78                 controller().params().status = InsetERT::Collapsed;
79         else 
80                 controller().params().status = InsetERT::Inlined;
81
82 }
83
84
85 void FormERT::update()
86 {
87         disconnect_signals();
88         switch (controller().params().status) {
89         case InsetERT::Open:
90                 open()->set_active(true);
91                 break;
92         case InsetERT::Collapsed:
93                 collapsed()->set_active(true);
94                 break;
95         case InsetERT::Inlined:
96                 inlined()->set_active(true);
97                 break;
98         }
99         connect_signals();
100
101 }
102
103 bool FormERT::validate() const
104 {
105         return true;
106 }
107
108
109 Gtk::Button * FormERT::ok_btn() const 
110 {
111         return getWidget<Gtk::Button>("r_ok_btn");
112 }
113 Gtk::Button * FormERT::apply_btn() const 
114 {
115         return getWidget<Gtk::Button>("r_apply_btn");
116 }
117 Gtk::Button * FormERT::cancel_btn() const 
118 {
119         return getWidget<Gtk::Button>("r_cancel_btn");
120 }
121 Gtk::RadioButton * FormERT::open() const 
122 {
123         return getWidget<Gtk::RadioButton>("r_open");
124 }
125 Gtk::RadioButton * FormERT::collapsed() const 
126 {
127         return getWidget<Gtk::RadioButton>("r_collapsed");
128 }
129 Gtk::RadioButton * FormERT::inlined() const 
130 {
131         return getWidget<Gtk::RadioButton>("r_inlined");
132 }