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
13 #pragma implementation
21 #include <gtkmm/entry.h>
22 #include <gtkmm/checkbutton.h>
23 #include <gtkmm/button.h>
26 : GnomeCB<ControlUrl>("GUrl")
36 // Connect the buttons.
37 ok_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::OKClicked));
38 cancel_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::CancelClicked));
39 apply_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::ApplyClicked));
40 restore_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::RestoreClicked));
42 // Manage the buttons state
44 bc().setCancel(cancel_btn());
45 bc().setApply(apply_btn());
46 bc().setRestore(restore_btn());
48 // Manage the read-only aware widgets.
49 bc().addReadOnly(html_cb());
50 bc().addReadOnly(name());
51 bc().addReadOnly(url());
53 // Make sure everything is in the correct state.
58 void GUrl::connect_signals()
60 // Get notifications on input change
61 slot_url_ = url()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
62 slot_name_ = name()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
63 slot_html_ = html_cb()->signal_toggled().connect(SigC::slot(*this, &GUrl::InputChanged));
67 void GUrl::disconnect_signals()
69 slot_url_.disconnect();
70 slot_name_.disconnect();
71 slot_html_.disconnect();
78 controller().params().setContents(url()->get_text());
79 controller().params().setOptions(name()->get_text());
81 string cmdname("url");
82 if (html_cb()->get_active())
85 controller().params().setCmdName(cmdname);
94 url()->set_text(controller().params().getContents());
95 name()->set_text(controller().params().getOptions());
97 html_cb()->set_active("url" != controller().params().getCmdName());
103 bool GUrl::validate() const
105 return !url()->get_text().empty() && !name()->get_text().empty();
108 Gtk::Button * GUrl::restore_btn() const
110 return getWidget<Gtk::Button>("r_restore_btn");
112 Gtk::Button * GUrl::ok_btn() const
114 return getWidget<Gtk::Button>("r_ok_btn");
116 Gtk::Button * GUrl::apply_btn() const
118 return getWidget<Gtk::Button>("r_apply_btn");
120 Gtk::Button * GUrl::cancel_btn() const
122 return getWidget<Gtk::Button>("r_cancel_btn");
124 Gtk::Entry * GUrl::url() const
126 return getWidget<Gtk::Entry>("r_url");
128 Gtk::Entry * GUrl::name() const
130 return getWidget<Gtk::Entry>("r_name");
132 Gtk::CheckButton * GUrl::html_cb() const
134 return getWidget<Gtk::CheckButton>("r_html_cb");