3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include <libglademm.h>
15 #include "support/lstrings.h"
16 #include "support/filetools.h"
17 #include "ControlCommand.h"
21 GText::GText(Dialog & parent, string const & title, string const & label)
22 : GViewCB<ControlCommand, GViewGladeB>(parent, title),
23 label_(label), entry_(0)
29 string const contents = Glib::locale_from_utf8(entry_->get_text());
30 controller().params().setContents(contents);
35 string const contents = lyx::support::trim(
36 controller().params().getContents());
37 entry_->set_text(Glib::locale_to_utf8(contents));
42 string const gladeName =
43 lyx::support::LibFileSearch("glade", "text", "glade");
44 xml_ = Gnome::Glade::Xml::create(gladeName);
46 Gtk::Button * restore;
50 xml_->get_widget("Label", label);
51 xml_->get_widget("Text", entry_);
52 xml_->get_widget("Restore", restore);
53 xml_->get_widget("Cancel", cancel);
54 xml_->get_widget("Apply", apply);
55 xml_->get_widget("OK", ok);
56 label->set_text(Glib::locale_to_utf8(id_sc::id(label_)));
58 bcview().setApply(apply);
59 bcview().setCancel(cancel);
60 bcview().setRestore(restore);
61 bcview().addReadOnly(entry_);
62 ok->signal_clicked().connect(
63 SigC::slot(*this, &GViewBase::onOK));
64 apply->signal_clicked().connect(
65 SigC::slot(*this, &GViewBase::onApply));
66 cancel->signal_clicked().connect(
67 SigC::slot(*this, &GViewBase::onCancel));
68 restore->signal_clicked().connect(
69 SigC::slot(*this, &GViewBase::onRestore));
70 entry_->signal_changed().connect(
71 SigC::slot(*this, >ext::onEntryChanged));
74 void GText::onEntryChanged()
76 bc().valid(!entry_->get_text().empty());