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