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.
14 #include <libglademm.h>
16 #include "ControlCommand.h"
18 #include "support/filetools.h"
19 #include "support/lstrings.h"
23 GUrl::GUrl(Dialog & parent)
24 : GViewCB<ControlCommand, GViewGladeB>(parent, _("URL"))
31 string const gladeName =
32 lyx::support::LibFileSearch("glade", "url", "glade");
33 xml_ = Gnome::Glade::Xml::create(gladeName);
34 Gtk::Button * restore;
38 xml_->get_widget("Url", url_);
39 xml_->get_widget("Name", name_);
40 xml_->get_widget("Html", htmlType_);
41 xml_->get_widget("Restore", restore);
42 xml_->get_widget("Ok", ok);
43 xml_->get_widget("Apply", apply);
44 xml_->get_widget("Cancel", cancel);
46 bcview().setCancel(cancel);
47 bcview().setApply(apply);
48 bcview().setRestore(restore);
49 bcview().addReadOnly(name_);
50 bcview().addReadOnly(url_);
51 bcview().addReadOnly(htmlType_);
53 ok->signal_clicked().connect(
54 SigC::slot(*this, &GViewBase::onOK));
55 apply->signal_clicked().connect(
56 SigC::slot(*this, &GViewBase::onApply));
57 cancel->signal_clicked().connect(
58 SigC::slot(*this, &GViewBase::onCancel));
59 restore->signal_clicked().connect(
60 SigC::slot(*this, &GViewBase::onRestore));
61 url_->signal_changed().connect(
62 SigC::slot(*this, &GUrl::onEntryChanged));
63 name_->signal_changed().connect(
64 SigC::slot(*this, &GUrl::onEntryChanged));
68 void GUrl::onEntryChanged()
70 bc().valid(!url_->get_text().empty() || !name_->get_text().empty());
76 url_->set_text(Glib::locale_to_utf8(
77 controller().params().getContents()));
78 name_->set_text(Glib::locale_to_utf8(
79 controller().params().getOptions()));
80 if (controller().params().getCmdName() == "url")
81 htmlType_->set_active(false);
83 htmlType_->set_active();
89 controller().params().setContents(
90 Glib::locale_to_utf8(url_->get_text()));
91 controller().params().setOptions(
92 Glib::locale_to_utf8(name_->get_text()));
93 if (htmlType_->get_active())
94 controller().params().setCmdName("htmlurl");
96 controller().params().setCmdName("url");