]> git.lyx.org Git - lyx.git/blob - src/frontends/gtk/GText.C
Change glob() API to accept a dir parameter.
[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 _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
16 #endif
17
18 #include "GText.h"
19 #include "ControlCommand.h"
20 #include "ghelpers.h"
21 #include "IdSc.h"
22
23 #include "support/lstrings.h"
24
25 #include <gtkmm.h>
26 #include <libglademm.h>
27
28 using std::string;
29
30 namespace lyx {
31 namespace frontend {
32
33 GText::GText(Dialog & parent, string const & title, string const & label)
34         : GViewCB<ControlCommand, GViewGladeB>(parent, title),
35           label_(label), entry_(0)
36 {
37 }
38
39
40 void GText::apply()
41 {
42         string const contents = Glib::locale_from_utf8(entry_->get_text());
43         controller().params().setContents(contents);
44 }
45
46
47 void GText::update()
48 {
49         string const contents = support::trim(
50                 controller().params().getContents());
51         entry_->set_text(Glib::locale_to_utf8(contents));
52 }
53
54
55 void GText::doBuild()
56 {
57         string const gladeName = findGladeFile("text");
58         xml_ = Gnome::Glade::Xml::create(gladeName);
59         Gtk::Label * label;
60         Gtk::Button * restore;
61         Gtk::Button * cancel;
62         Gtk::Button * apply;
63         Gtk::Button * ok;
64         xml_->get_widget("Label", label);
65         xml_->get_widget("Text", entry_);
66         xml_->get_widget("Restore", restore);
67         xml_->get_widget("Cancel", cancel);
68         xml_->get_widget("Apply", apply);
69         xml_->get_widget("OK", ok);
70         label->set_text(Glib::locale_to_utf8(id_sc::id(label_)));
71         setOK(ok);
72         setApply(apply);
73         setCancel(cancel);
74         setRestore(restore);
75         bcview().addReadOnly(entry_);
76         entry_->signal_changed().connect(
77                 sigc::mem_fun(*this, &GText::onEntryChanged));
78 }
79
80
81 void GText::onEntryChanged()
82 {
83         bc().valid(!entry_->get_text().empty());
84 }
85
86 } // namespace frontend
87 } // namespace lyx