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 <gtk--/entry.h>
23 #include <gtk--/checkbutton.h>
25 FormUrl::FormUrl(ControlUrl & c)
26 : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
32 // Note that there is no need to destroy the class itself, it seems
33 // like everything is managed inside it. Deleting the class itself will
34 // a crash at the end of the program.
41 // Connect the buttons.
42 ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked));
43 cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked));
44 apply_btn()->clicked.connect(SigC::slot(this, &FormUrl::ApplyClicked));
45 restore_btn()->clicked.connect(SigC::slot(this, &FormUrl::RestoreClicked));
47 // Manage the buttons state
49 bc().setCancel(cancel_btn());
50 bc().setApply(apply_btn());
51 bc().setRestore(restore_btn());
53 // Make sure everything is in the correct state.
56 // Manage the read-only aware widgets.
57 bc().addReadOnly(html());
58 bc().addReadOnly(name());
59 bc().addReadOnly(url());
63 void FormUrl::connect_signals()
65 // Get notifications on input change
66 slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
67 slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
68 slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
72 void FormUrl::disconnect_signals()
74 slot_url_.disconnect();
75 slot_name_.disconnect();
76 slot_html_.disconnect();
82 controller().params().setContents(url()->get_text());
83 controller().params().setOptions(name()->get_text());
85 string cmdname("url");
86 if (html()->get_active())
89 controller().params().setCmdName(cmdname);
93 void FormUrl::update()
95 // Disconnect signals so we dont trigger the input changed state.
96 // This avoids the problem of having the buttons enabled when the dialog
100 url()->set_text(controller().params().getContents());
101 name()->set_text(controller().params().getOptions());
103 html()->set_active("url" != controller().params().getCmdName());
105 // Reconnect the signals.
110 bool FormUrl::validate() const
112 // Always valid! (not really so, needs fixing).
117 Gtk::Entry * FormUrl::url() const
119 return getWidget<Gtk::Entry>("url");
122 Gtk::Entry * FormUrl::name() const
124 return getWidget<Gtk::Entry>("name");
127 Gtk::CheckButton * FormUrl::html() const
129 return getWidget<Gtk::CheckButton>("html_type");
133 Gtk::Button * FormUrl::ok_btn() const
135 return getWidget<Gtk::Button>("button_ok");
139 Gtk::Button * FormUrl::cancel_btn() const
141 return getWidget<Gtk::Button>("button_cancel");
145 Gtk::Button * FormUrl::apply_btn() const
147 return getWidget<Gtk::Button>("button_apply");
151 Gtk::Button * FormUrl::restore_btn() const
153 return getWidget<Gtk::Button>("button_restore");