2003-10-28 16:45:09 +00:00
|
|
|
/**
|
|
|
|
* \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 <config.h>
|
|
|
|
|
|
|
|
#include "ControlCommand.h"
|
|
|
|
#include "GUrl.h"
|
2004-04-27 12:48:45 +00:00
|
|
|
#include "ghelpers.h"
|
2004-09-26 18:36:07 +00:00
|
|
|
|
2003-10-28 16:45:09 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
2004-09-26 18:36:07 +00:00
|
|
|
#include <gtkmm.h>
|
|
|
|
#include <libglademm.h>
|
|
|
|
|
2003-10-28 16:45:09 +00:00
|
|
|
using std::string;
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2004-09-26 13:18:29 +00:00
|
|
|
|
2003-10-28 16:45:09 +00:00
|
|
|
GUrl::GUrl(Dialog & parent)
|
|
|
|
: GViewCB<ControlCommand, GViewGladeB>(parent, _("URL"))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GUrl::doBuild()
|
|
|
|
{
|
2004-04-27 12:48:45 +00:00
|
|
|
string const gladeName = findGladeFile("url");
|
2003-10-28 16:45:09 +00:00
|
|
|
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);
|
2004-02-23 00:21:04 +00:00
|
|
|
setOK(ok);
|
|
|
|
setCancel(cancel);
|
|
|
|
setApply(apply);
|
|
|
|
setRestore(restore);
|
2003-10-28 16:45:09 +00:00
|
|
|
bcview().addReadOnly(name_);
|
|
|
|
bcview().addReadOnly(url_);
|
|
|
|
bcview().addReadOnly(htmlType_);
|
|
|
|
|
|
|
|
url_->signal_changed().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GUrl::onEntryChanged));
|
2003-10-28 16:45:09 +00:00
|
|
|
name_->signal_changed().connect(
|
2004-09-26 16:48:30 +00:00
|
|
|
sigc::mem_fun(*this, &GUrl::onEntryChanged));
|
2003-10-28 16:45:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
2004-05-19 15:11:37 +00:00
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|