1 /* This file is part of
2 * =================================================
4 * LyX, The Document Processor
5 * Copyright 1995-2000 The LyX Team.
7 * =================================================
13 #pragma implementation
21 #include <gtk--/entry.h>
22 #include <gtk--/checkbutton.h>
24 FormUrl::FormUrl(ControlUrl & c)
25 : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
31 // Note that there is no need to destroy the class itself, it seems
32 // like everything is managed inside it. Deleting the class itself will
33 // a crash at the end of the program.
40 // Connect the buttons.
41 ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked));
42 cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked));
43 apply_btn()->clicked.connect(SigC::slot(this, &FormUrl::ApplyClicked));
44 restore_btn()->clicked.connect(SigC::slot(this, &FormUrl::RestoreClicked));
46 // Manage the buttons state
48 bc().setCancel(cancel_btn());
49 bc().setApply(apply_btn());
50 bc().setRestore(restore_btn());
52 // Make sure everything is in the correct state.
55 // Manage the read-only aware widgets.
56 bc().addReadOnly(html());
57 bc().addReadOnly(name());
58 bc().addReadOnly(url());
62 void FormUrl::connect_signals()
64 // Get notifications on input change
65 slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
66 slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
67 slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
71 void FormUrl::disconnect_signals()
73 slot_url_.disconnect();
74 slot_name_.disconnect();
75 slot_html_.disconnect();
81 controller().params().setContents(url()->get_text());
82 controller().params().setOptions(name()->get_text());
84 string cmdname("url");
85 if (html()->get_active())
88 controller().params().setCmdName(cmdname);
92 void FormUrl::update()
94 // Disconnect signals so we dont trigger the input changed state.
95 // This avoids the problem of having the buttons enabled when the dialog
99 url()->set_text(controller().params().getContents());
100 name()->set_text(controller().params().getOptions());
102 html()->set_active("url" != controller().params().getCmdName());
104 // Reconnect the signals.
109 bool FormUrl::validate() const
111 // Always valid! (not really so, needs fixing).
116 Gtk::Entry * FormUrl::url() const
118 return getWidget<Gtk::Entry>("url");
121 Gtk::Entry * FormUrl::name() const
123 return getWidget<Gtk::Entry>("name");
126 Gtk::CheckButton * FormUrl::html() const
128 return getWidget<Gtk::CheckButton>("html_type");
132 Gtk::Button * FormUrl::ok_btn() const
134 return getWidget<Gtk::Button>("button_ok");
138 Gtk::Button * FormUrl::cancel_btn() const
140 return getWidget<Gtk::Button>("button_cancel");
144 Gtk::Button * FormUrl::apply_btn() const
146 return getWidget<Gtk::Button>("button_apply");
150 Gtk::Button * FormUrl::restore_btn() const
152 return getWidget<Gtk::Button>("button_restore");