/** * \file GUrl.C * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Huang Ying * * Full author contact details are available in file CREDITS. */ #include #include #include #include "ControlCommand.h" #include "GUrl.h" #include "support/filetools.h" #include "support/lstrings.h" using std::string; GUrl::GUrl(Dialog & parent) : GViewCB(parent, _("URL")) { } void GUrl::doBuild() { string const gladeName = lyx::support::LibFileSearch("glade", "url", "glade"); xml_ = Gnome::Glade::Xml::create(gladeName); Gtk::Button * restore; Gtk::Button * ok; Gtk::Button * apply; Gtk::Button * cancel; xml_->get_widget("Url", url_); xml_->get_widget("Name", name_); xml_->get_widget("Html", htmlType_); xml_->get_widget("Restore", restore); xml_->get_widget("Ok", ok); xml_->get_widget("Apply", apply); xml_->get_widget("Cancel", cancel); bcview().setOK(ok); bcview().setCancel(cancel); bcview().setApply(apply); bcview().setRestore(restore); bcview().addReadOnly(name_); bcview().addReadOnly(url_); bcview().addReadOnly(htmlType_); ok->signal_clicked().connect( SigC::slot(*this, &GViewBase::onOK)); apply->signal_clicked().connect( SigC::slot(*this, &GViewBase::onApply)); cancel->signal_clicked().connect( SigC::slot(*this, &GViewBase::onCancel)); restore->signal_clicked().connect( SigC::slot(*this, &GViewBase::onRestore)); url_->signal_changed().connect( SigC::slot(*this, &GUrl::onEntryChanged)); name_->signal_changed().connect( SigC::slot(*this, &GUrl::onEntryChanged)); } void GUrl::onEntryChanged() { bc().valid(!url_->get_text().empty() || !name_->get_text().empty()); } void GUrl::update() { url_->set_text(Glib::locale_to_utf8( controller().params().getContents())); name_->set_text(Glib::locale_to_utf8( controller().params().getOptions())); if (controller().params().getCmdName() == "url") htmlType_->set_active(false); else htmlType_->set_active(); } void GUrl::apply() { controller().params().setContents( Glib::locale_to_utf8(url_->get_text())); controller().params().setOptions( Glib::locale_to_utf8(name_->get_text())); if (htmlType_->get_active()) controller().params().setCmdName("htmlurl"); else controller().params().setCmdName("url"); }