2003-09-02 10:29:05 +00:00
|
|
|
/**
|
|
|
|
* \file GText.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Huang Ying
|
|
|
|
*
|
2003-09-02 17:02:32 +00:00
|
|
|
* Full author contact details are available in file CREDITS.
|
2003-09-02 10:29:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <libglademm.h>
|
|
|
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "ControlCommand.h"
|
|
|
|
#include "GText.h"
|
2004-04-27 12:48:45 +00:00
|
|
|
#include "ghelpers.h"
|
2003-09-02 10:29:05 +00:00
|
|
|
#include "IdSc.h"
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
2003-10-06 15:43:21 +00:00
|
|
|
|
2003-09-02 10:29:05 +00:00
|
|
|
GText::GText(Dialog & parent, string const & title, string const & label)
|
|
|
|
: GViewCB<ControlCommand, GViewGladeB>(parent, title),
|
|
|
|
label_(label), entry_(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GText::apply()
|
|
|
|
{
|
|
|
|
string const contents = Glib::locale_from_utf8(entry_->get_text());
|
|
|
|
controller().params().setContents(contents);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GText::update()
|
|
|
|
{
|
2004-05-19 15:11:37 +00:00
|
|
|
string const contents = support::trim(
|
2003-09-02 10:29:05 +00:00
|
|
|
controller().params().getContents());
|
|
|
|
entry_->set_text(Glib::locale_to_utf8(contents));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GText::doBuild()
|
|
|
|
{
|
2004-04-27 12:48:45 +00:00
|
|
|
string const gladeName = findGladeFile("text");
|
2003-09-02 10:29:05 +00:00
|
|
|
xml_ = Gnome::Glade::Xml::create(gladeName);
|
|
|
|
Gtk::Label * label;
|
|
|
|
Gtk::Button * restore;
|
|
|
|
Gtk::Button * cancel;
|
|
|
|
Gtk::Button * apply;
|
|
|
|
Gtk::Button * ok;
|
|
|
|
xml_->get_widget("Label", label);
|
|
|
|
xml_->get_widget("Text", entry_);
|
|
|
|
xml_->get_widget("Restore", restore);
|
|
|
|
xml_->get_widget("Cancel", cancel);
|
|
|
|
xml_->get_widget("Apply", apply);
|
|
|
|
xml_->get_widget("OK", ok);
|
|
|
|
label->set_text(Glib::locale_to_utf8(id_sc::id(label_)));
|
2004-02-23 00:21:04 +00:00
|
|
|
setOK(ok);
|
|
|
|
setApply(apply);
|
|
|
|
setCancel(cancel);
|
|
|
|
setRestore(restore);
|
2003-09-02 10:29:05 +00:00
|
|
|
bcview().addReadOnly(entry_);
|
|
|
|
entry_->signal_changed().connect(
|
|
|
|
SigC::slot(*this, >ext::onEntryChanged));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GText::onEntryChanged()
|
|
|
|
{
|
|
|
|
bc().valid(!entry_->get_text().empty());
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|