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, "FormUrl")
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_cb());
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_cb()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
71 void FormUrl::disconnect_signals()
73 slot_url_.disconnect();
74 slot_name_.disconnect();
75 slot_html_.disconnect();
82 controller().params().setContents(url()->get_text());
83 controller().params().setOptions(name()->get_text());
85 string cmdname("url");
86 if (html_cb()->get_active())
89 controller().params().setCmdName(cmdname);
94 void FormUrl::update()
96 // Disconnect signals so we dont trigger the input changed state.
97 // This avoids the problem of having the buttons enabled when the dialog
101 url()->set_text(controller().params().getContents());
102 name()->set_text(controller().params().getOptions());
104 html_cb()->set_active("url" != controller().params().getCmdName());
106 // Reconnect the signals.
111 bool FormUrl::validate() const
113 return !url()->get_text().empty() && !name()->get_text().empty();
116 Gtk::Button * FormUrl::restore_btn() const
118 return getWidget<Gtk::Button>("r_restore_btn");
120 Gtk::Button * FormUrl::ok_btn() const
122 return getWidget<Gtk::Button>("r_ok_btn");
124 Gtk::Button * FormUrl::apply_btn() const
126 return getWidget<Gtk::Button>("r_apply_btn");
128 Gtk::Button * FormUrl::cancel_btn() const
130 return getWidget<Gtk::Button>("r_cancel_btn");
132 Gtk::Entry * FormUrl::url() const
134 return getWidget<Gtk::Entry>("r_url");
136 Gtk::Entry * FormUrl::name() const
138 return getWidget<Gtk::Entry>("r_name");
140 Gtk::CheckButton * FormUrl::html_cb() const
142 return getWidget<Gtk::CheckButton>("r_html_cb");