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