-// -*- C++ -*-
/* This file is part of
* =================================================
- *
+ *
* LyX, The Document Processor
* Copyright 1995-2000 The LyX Team.
*
- * =================================================
+ * =================================================
*
* \author Baruch Even
*/
#include "gnomeBC.h"
#include "FormUrl.h"
-#include <gnome--/dialog.h>
#include <gtk--/entry.h>
#include <gtk--/checkbutton.h>
FormUrl::FormUrl(ControlUrl & c)
- : FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
- , dialog_(0)
+ : FormCB<ControlUrl>(c, "FormUrl")
{}
// Note that there is no need to destroy the class itself, it seems
// like everything is managed inside it. Deleting the class itself will
// a crash at the end of the program.
- dialog_->destroy();
+ //dialog_->destroy();
}
void FormUrl::build()
{
- // Make sure the dialog is loaded.
- dialog_ = dialog();
-
// Connect the buttons.
ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked));
cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked));
bc().setOK(ok_btn());
bc().setCancel(cancel_btn());
bc().setApply(apply_btn());
- bc().setUndoAll(restore_btn());
+ bc().setRestore(restore_btn());
// Make sure everything is in the correct state.
bc().refresh();
-
+
// Manage the read-only aware widgets.
- bc().addReadOnly(html());
+ bc().addReadOnly(html_cb());
bc().addReadOnly(name());
bc().addReadOnly(url());
}
// Get notifications on input change
slot_url_ = url()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
slot_name_ = name()->changed.connect(SigC::slot(this, &FormUrl::InputChanged));
- slot_html_ = html()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
+ slot_html_ = html_cb()->toggled.connect(SigC::slot(this, &FormUrl::InputChanged));
}
}
-void FormUrl::show()
-{
- if (!dialog_)
- build();
-
- update();
- dialog_->show();
-}
-
-
-void FormUrl::hide()
-{
- dialog_->hide();
-}
-
-
void FormUrl::apply()
{
+ disconnect_signals();
controller().params().setContents(url()->get_text());
controller().params().setOptions(name()->get_text());
string cmdname("url");
- if (html()->get_active())
+ if (html_cb()->get_active())
cmdname = "htmlurl";
controller().params().setCmdName(cmdname);
+ connect_signals();
}
// This avoids the problem of having the buttons enabled when the dialog
// starts.
disconnect_signals();
-
+
url()->set_text(controller().params().getContents());
name()->set_text(controller().params().getOptions());
- html()->set_active("url" != controller().params().getCmdName());
+ html_cb()->set_active("url" != controller().params().getCmdName());
// Reconnect the signals.
connect_signals();
bool FormUrl::validate() const
{
- // Always valid! (not really so, needs fixing).
- return true;
-}
-
-
-Gnome::Dialog * FormUrl::dialog()
-{
- return getWidget<Gnome::Dialog>("DiaInsertUrl");
+ return !url()->get_text().empty() && !name()->get_text().empty();
}
-Gtk::Entry * FormUrl::url() const
+Gtk::Button * FormUrl::restore_btn() const
{
- return getWidget<Gtk::Entry>("url");
+ return getWidget<Gtk::Button>("r_restore_btn");
}
-
-Gtk::Entry * FormUrl::name() const
+Gtk::Button * FormUrl::ok_btn() const
{
- return getWidget<Gtk::Entry>("name");
+ return getWidget<Gtk::Button>("r_ok_btn");
}
-
-Gtk::CheckButton * FormUrl::html() const
+Gtk::Button * FormUrl::apply_btn() const
{
- return getWidget<Gtk::CheckButton>("html_type");
+ return getWidget<Gtk::Button>("r_apply_btn");
}
-
-
-Gtk::Button * FormUrl::ok_btn() const
+Gtk::Button * FormUrl::cancel_btn() const
{
- return getWidget<Gtk::Button>("button_ok");
+ return getWidget<Gtk::Button>("r_cancel_btn");
}
-
-
-Gtk::Button * FormUrl::cancel_btn() const
+Gtk::Entry * FormUrl::url() const
{
- return getWidget<Gtk::Button>("button_cancel");
+ return getWidget<Gtk::Entry>("r_url");
}
-
-
-Gtk::Button * FormUrl::apply_btn() const
+Gtk::Entry * FormUrl::name() const
{
- return getWidget<Gtk::Button>("button_apply");
+ return getWidget<Gtk::Entry>("r_name");
}
-
-
-Gtk::Button * FormUrl::restore_btn() const
+Gtk::CheckButton * FormUrl::html_cb() const
{
- return getWidget<Gtk::Button>("button_restore");
+ return getWidget<Gtk::CheckButton>("r_html_cb");
}