1 /* This file is part of
2 * =================================================
4 * LyX, The Document Processor
5 * Copyright 1995-2000 The LyX Team.
7 * =================================================
10 * \author Michael Koziarski
14 #pragma implementation
22 #include <gtkmm/entry.h>
23 #include <gtkmm/checkbutton.h>
24 #include <gtkmm/button.h>
26 GUrl::GUrl(ControlUrl & c)
27 : FormCB<ControlUrl>(c, "GUrl")
37 // Connect the buttons.
38 ok_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::OKClicked));
39 cancel_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::CancelClicked));
40 apply_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::ApplyClicked));
41 restore_btn()->signal_clicked().connect(SigC::slot(*this, &GUrl::RestoreClicked));
43 // Manage the buttons state
45 bc().setCancel(cancel_btn());
46 bc().setApply(apply_btn());
47 bc().setRestore(restore_btn());
49 // Manage the read-only aware widgets.
50 bc().addReadOnly(html_cb());
51 bc().addReadOnly(name());
52 bc().addReadOnly(url());
54 // Make sure everything is in the correct state.
59 void GUrl::connect_signals()
61 // Get notifications on input change
62 slot_url_ = url()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
63 slot_name_ = name()->signal_changed().connect(SigC::slot(*this, &GUrl::InputChanged));
64 slot_html_ = html_cb()->signal_toggled().connect(SigC::slot(*this, &GUrl::InputChanged));
68 void GUrl::disconnect_signals()
70 slot_url_.disconnect();
71 slot_name_.disconnect();
72 slot_html_.disconnect();
79 controller().params().setContents(url()->get_text());
80 controller().params().setOptions(name()->get_text());
82 string cmdname("url");
83 if (html_cb()->get_active())
86 controller().params().setCmdName(cmdname);
95 url()->set_text(controller().params().getContents());
96 name()->set_text(controller().params().getOptions());
98 html_cb()->set_active("url" != controller().params().getCmdName());
104 bool GUrl::validate() const
106 return !url()->get_text().empty() && !name()->get_text().empty();
109 Gtk::Button * GUrl::restore_btn() const
111 return getWidget<Gtk::Button>("r_restore_btn");
113 Gtk::Button * GUrl::ok_btn() const
115 return getWidget<Gtk::Button>("r_ok_btn");
117 Gtk::Button * GUrl::apply_btn() const
119 return getWidget<Gtk::Button>("r_apply_btn");
121 Gtk::Button * GUrl::cancel_btn() const
123 return getWidget<Gtk::Button>("r_cancel_btn");
125 Gtk::Entry * GUrl::url() const
127 return getWidget<Gtk::Entry>("r_url");
129 Gtk::Entry * GUrl::name() const
131 return getWidget<Gtk::Entry>("r_name");
133 Gtk::CheckButton * GUrl::html_cb() const
135 return getWidget<Gtk::CheckButton>("r_html_cb");