]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GNote.C
some tabular fixes for the problems reported by Helge
[lyx.git] / src / frontends / gtk / GNote.C
1 /**
2  * \file GNote.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 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
16 #endif
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
19 #endif
20
21 #include "GNote.h"
22 #include "ControlNote.h"
23 #include "ghelpers.h"
24
25 #include "insets/insetnote.h"
26
27 #include <libglademm.h>
28
29 using std::string;
30
31 namespace lyx {
32 namespace frontend {
33
34 GNote::GNote(Dialog & parent)
35         : GViewCB<ControlNote, GViewGladeB>(parent, _("Note Settings"), false)
36 {}
37
38
39 void GNote::doBuild()
40 {
41         string const gladeName = findGladeFile("note");
42         xml_ = Gnome::Glade::Xml::create(gladeName);
43
44         Gtk::Button * cancelbutton;
45         xml_->get_widget("Close", cancelbutton);
46         setCancel(cancelbutton);
47
48         xml_->get_widget("LyXNote", lyxnoteradio_);
49         xml_->get_widget("Comment", commentradio_);
50         xml_->get_widget("GreyedOut", greyedoutradio_);
51
52         lyxnoteradio_->signal_toggled().connect(
53                 sigc::mem_fun(*this, &GNote::apply));
54         commentradio_->signal_toggled().connect(
55                 sigc::mem_fun(*this, &GNote::apply));
56         greyedoutradio_->signal_toggled().connect(
57                 sigc::mem_fun(*this, &GNote::apply));
58
59         bcview().addReadOnly(lyxnoteradio_);
60         bcview().addReadOnly(commentradio_);
61         bcview().addReadOnly(greyedoutradio_);
62 }
63
64
65 void GNote::update()
66 {
67         applylock_ = true;
68
69         bc().refreshReadOnly();
70
71         switch (controller().params().type) {
72         case InsetNoteParams::Note:
73                 lyxnoteradio_->set_active(true);
74                 break;
75         case InsetNoteParams::Comment:
76                 commentradio_->set_active(true);
77                 break;
78         case InsetNoteParams::Greyedout:
79                 greyedoutradio_->set_active(true);
80                 break;
81         }
82
83         applylock_ = false;
84 }
85
86
87 void GNote::apply()
88 {
89         if (applylock_)
90                 return;
91
92         InsetNoteParams::Type type;
93
94         if (lyxnoteradio_->get_active())
95                 type = InsetNoteParams::Note;
96         else if (greyedoutradio_->get_active())
97                 type = InsetNoteParams::Greyedout;
98         else
99                 type = InsetNoteParams::Comment;
100
101         controller().params().type = type;
102         controller().dispatchParams();
103 }
104
105 } // namespace frontend
106 } // namespace lyx