2 /* This file is part of
3 * =================================================
5 * LyX, The Document Processor
6 * Copyright 1995-2000 The LyX Team.
8 * =================================================
14 #pragma implementation
22 #include <gnome--/dialog.h>
23 #include <gtk--/entry.h>
24 #include <gtk--/checkbutton.h>
26 FormUrl::FormUrl(ControlUrl & c)
27 : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
34 // Note that there is no need to destroy the class itself, it seems
35 // like everything is managed inside it. Deleting the class itself will
36 // a crash at the end of the program.
43 // Make sure the dialog is loaded.
46 // Connect the buttons.
47 ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked));
48 cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked));
49 apply_btn()->clicked.connect(SigC::slot(this, &FormUrl::ApplyClicked));
50 restore_btn()->clicked.connect(SigC::slot(this, &FormUrl::RestoreClicked));
52 // Manage the buttons state
54 bc().setCancel(cancel_btn());
55 bc().setApply(apply_btn());
56 bc().setUndoAll(restore_btn());
58 // Make sure everything is in the correct state.
61 // Manage the read-only aware widgets.
62 bc().addReadOnly(html());
63 bc().addReadOnly(name());
64 bc().addReadOnly(url());
68 void FormUrl::connect_signals()
70 // Get notifications on input change
71 slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
72 slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
73 slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
77 void FormUrl::disconnect_signals()
79 slot_url_.disconnect();
80 slot_name_.disconnect();
81 slot_html_.disconnect();
101 void FormUrl::apply()
103 controller().params().setContents(url()->get_text());
104 controller().params().setOptions(name()->get_text());
106 string cmdname("url");
107 if (html()->get_active())
110 controller().params().setCmdName(cmdname);
114 void FormUrl::update()
116 // Disconnect signals so we dont trigger the input changed state.
117 // This avoids the problem of having the buttons enabled when the dialog
119 disconnect_signals();
121 url()->set_text(controller().params().getContents());
122 name()->set_text(controller().params().getOptions());
124 html()->set_active("url" != controller().params().getCmdName());
126 // Reconnect the signals.
131 bool FormUrl::validate() const
133 // Always valid! (not really so, needs fixing).
138 Gnome::Dialog * FormUrl::dialog()
140 return getWidget<Gnome::Dialog>("DiaInsertUrl");
143 Gtk::Entry * FormUrl::url() const
145 return getWidget<Gtk::Entry>("url");
148 Gtk::Entry * FormUrl::name() const
150 return getWidget<Gtk::Entry>("name");
153 Gtk::CheckButton * FormUrl::html() const
155 return getWidget<Gtk::CheckButton>("html_type");
159 Gtk::Button * FormUrl::ok_btn() const
161 return getWidget<Gtk::Button>("button_ok");
165 Gtk::Button * FormUrl::cancel_btn() const
167 return getWidget<Gtk::Button>("button_cancel");
171 Gtk::Button * FormUrl::apply_btn() const
173 return getWidget<Gtk::Button>("button_apply");
177 Gtk::Button * FormUrl::restore_btn() const
179 return getWidget<Gtk::Button>("button_restore");