]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GText.C
more compile fixes
[lyx.git] / src / frontends / gtk / GText.C
1 /**
2  * \file GText.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Huang Ying
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 "GText.h"
22 #include "ControlCommand.h"
23 #include "ghelpers.h"
24 #include "IdSc.h"
25
26 #include "support/lstrings.h"
27
28 #include <gtkmm.h>
29 #include <libglademm.h>
30
31 using lyx::docstring;
32
33 using std::string;
34
35 namespace lyx {
36 namespace frontend {
37
38 GText::GText(Dialog & parent, docstring const & title, docstring const & label)
39         : GViewCB<ControlCommand, GViewGladeB>(parent, title),
40           label_(lyx::to_utf8(label)), entry_(0)
41 {
42 }
43
44
45 void GText::apply()
46 {
47         controller().params().setContents(entry_->get_text());
48 }
49
50
51 void GText::update()
52 {
53         string const contents = support::trim(
54                 controller().params().getContents());
55         entry_->set_text(contents);
56 }
57
58
59 void GText::doBuild()
60 {
61         string const gladeName = findGladeFile("text");
62         xml_ = Gnome::Glade::Xml::create(gladeName);
63         Gtk::Label * label;
64         Gtk::Button * restore;
65         Gtk::Button * cancel;
66         Gtk::Button * apply;
67         Gtk::Button * ok;
68         xml_->get_widget("Label", label);
69         xml_->get_widget("Text", entry_);
70         xml_->get_widget("Restore", restore);
71         xml_->get_widget("Cancel", cancel);
72         xml_->get_widget("Apply", apply);
73         xml_->get_widget("OK", ok);
74         label->set_text(Glib::locale_to_utf8(id_sc::id(label_)));
75         setOK(ok);
76         setApply(apply);
77         setCancel(cancel);
78         setRestore(restore);
79         bcview().addReadOnly(entry_);
80         entry_->signal_changed().connect(
81                 sigc::mem_fun(*this, &GText::onEntryChanged));
82 }
83
84
85 void GText::onEntryChanged()
86 {
87         bc().valid(!entry_->get_text().empty());
88 }
89
90 } // namespace frontend
91 } // namespace lyx