3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Michael Koziarski
9 * Full author contact details are available in file CREDITS.
18 #include <gtkmm/entry.h>
19 #include <gtkmm/checkbutton.h>
20 #include <gtkmm/button.h>
23 : GControlledView<ControlUrl>("GUrl")
33 // Connect the buttons.
34 ok_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::OKClicked));
35 cancel_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::CancelClicked));
36 apply_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::ApplyClicked));
37 restore_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::RestoreClicked));
39 // Manage the buttons state
41 bc().setCancel(cancel_btn());
42 bc().setApply(apply_btn());
43 bc().setRestore(restore_btn());
45 // Manage the read-only aware widgets.
46 bc().addReadOnly(html_cb());
47 bc().addReadOnly(name());
48 bc().addReadOnly(url());
50 // Make sure everything is in the correct state.
55 void GUrl::connect_signals()
57 // Get notifications on input change
58 slot_url_ = url()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
59 slot_name_ = name()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
60 slot_html_ = html_cb()->signal_toggled().connect(SigC::slot(*this, &GUrl::InputChanged));
64 void GUrl::disconnect_signals()
66 slot_url_.disconnect();
67 slot_name_.disconnect();
68 slot_html_.disconnect();
75 controller().params().setContents(url()->get_text());
76 controller().params().setOptions(name()->get_text());
78 string cmdname("url");
79 if (html_cb()->get_active())
82 controller().params().setCmdName(cmdname);
91 url()->set_text(controller().params().getContents());
92 name()->set_text(controller().params().getOptions());
94 html_cb()->set_active("url" != controller().params().getCmdName());
100 bool GUrl::validate() const
102 return !url()->get_text().empty() && !name()->get_text().empty();
105 Gtk::Button * GUrl::restore_btn() const
107 return getWidget<Gtk::Button>("r_restore_btn");
109 Gtk::Button * GUrl::ok_btn() const
111 return getWidget<Gtk::Button>("r_ok_btn");
113 Gtk::Button * GUrl::apply_btn() const
115 return getWidget<Gtk::Button>("r_apply_btn");
117 Gtk::Button * GUrl::cancel_btn() const
119 return getWidget<Gtk::Button>("r_cancel_btn");
121 Gtk::Entry * GUrl::url() const
123 return getWidget<Gtk::Entry>("r_url");
125 Gtk::Entry * GUrl::name() const
127 return getWidget<Gtk::Entry>("r_name");
129 Gtk::CheckButton * GUrl::html_cb() const
131 return getWidget<Gtk::CheckButton>("r_html_cb");