]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GText.C
some tabular fixes for the problems reported by Helge
[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 std::string;
32
33 namespace lyx {
34 namespace frontend {
35
36 GText::GText(Dialog & parent, string const & title, string const & label)
37         : GViewCB<ControlCommand, GViewGladeB>(parent, title),
38           label_(label), entry_(0)
39 {
40 }
41
42
43 void GText::apply()
44 {
45         string const contents = Glib::locale_from_utf8(entry_->get_text());
46         controller().params().setContents(contents);
47 }
48
49
50 void GText::update()
51 {
52         string const contents = support::trim(
53                 controller().params().getContents());
54         entry_->set_text(Glib::locale_to_utf8(contents));
55 }
56
57
58 void GText::doBuild()
59 {
60         string const gladeName = findGladeFile("text");
61         xml_ = Gnome::Glade::Xml::create(gladeName);
62         Gtk::Label * label;
63         Gtk::Button * restore;
64         Gtk::Button * cancel;
65         Gtk::Button * apply;
66         Gtk::Button * ok;
67         xml_->get_widget("Label", label);
68         xml_->get_widget("Text", entry_);
69         xml_->get_widget("Restore", restore);
70         xml_->get_widget("Cancel", cancel);
71         xml_->get_widget("Apply", apply);
72         xml_->get_widget("OK", ok);
73         label->set_text(Glib::locale_to_utf8(id_sc::id(label_)));
74         setOK(ok);
75         setApply(apply);
76         setCancel(cancel);
77         setRestore(restore);
78         bcview().addReadOnly(entry_);
79         entry_->signal_changed().connect(
80                 sigc::mem_fun(*this, &GText::onEntryChanged));
81 }
82
83
84 void GText::onEntryChanged()
85 {
86         bc().valid(!entry_->get_text().empty());
87 }
88
89 } // namespace frontend
90 } // namespace lyx