2000-08-14 09:44:53 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/* This file is part of
|
2001-03-28 11:14:05 +00:00
|
|
|
* =================================================
|
|
|
|
*
|
|
|
|
* LyX, The Document Processor
|
|
|
|
* Copyright 1995-2000 The LyX Team.
|
2000-08-14 09:44:53 +00:00
|
|
|
*
|
2001-03-28 11:14:05 +00:00
|
|
|
* =================================================
|
2000-08-14 09:44:53 +00:00
|
|
|
*
|
2001-03-28 11:14:05 +00:00
|
|
|
* \author Baruch Even
|
2000-08-14 09:44:53 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
#include <config.h>
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
#include "gnomeBC.h"
|
2000-08-14 09:44:53 +00:00
|
|
|
#include "FormUrl.h"
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
#include <gtk--/entry.h>
|
|
|
|
#include <gtk--/checkbutton.h>
|
2000-09-19 13:50:47 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
FormUrl::FormUrl(ControlUrl & c)
|
|
|
|
: FormCB<ControlUrl>(c, "diainserturl.glade", "DiaInsertUrl")
|
|
|
|
{}
|
2000-09-19 13:50:47 +00:00
|
|
|
|
2001-03-20 01:22:46 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
FormUrl::~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.
|
2001-03-29 14:47:17 +00:00
|
|
|
//dialog_->destroy();
|
2001-03-28 11:14:05 +00:00
|
|
|
}
|
2001-03-20 01:22:46 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
|
|
|
|
void FormUrl::build()
|
|
|
|
{
|
|
|
|
// Connect the buttons.
|
|
|
|
ok_btn()->clicked.connect(SigC::slot(this, &FormUrl::OKClicked));
|
|
|
|
cancel_btn()->clicked.connect(SigC::slot(this, &FormUrl::CancelClicked));
|
|
|
|
apply_btn()->clicked.connect(SigC::slot(this, &FormUrl::ApplyClicked));
|
|
|
|
restore_btn()->clicked.connect(SigC::slot(this, &FormUrl::RestoreClicked));
|
|
|
|
|
|
|
|
// Manage the buttons state
|
|
|
|
bc().setOK(ok_btn());
|
|
|
|
bc().setCancel(cancel_btn());
|
|
|
|
bc().setApply(apply_btn());
|
|
|
|
bc().setUndoAll(restore_btn());
|
|
|
|
|
|
|
|
// Make sure everything is in the correct state.
|
|
|
|
bc().refresh();
|
|
|
|
|
|
|
|
// Manage the read-only aware widgets.
|
|
|
|
bc().addReadOnly(html());
|
|
|
|
bc().addReadOnly(name());
|
|
|
|
bc().addReadOnly(url());
|
|
|
|
}
|
2001-03-20 01:22:46 +00:00
|
|
|
|
2000-08-14 09:44:53 +00:00
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
void FormUrl::connect_signals()
|
2000-08-14 09:44:53 +00:00
|
|
|
{
|
2001-03-28 11:14:05 +00:00
|
|
|
// 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));
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
void FormUrl::disconnect_signals()
|
2000-08-14 09:44:53 +00:00
|
|
|
{
|
2001-03-28 11:14:05 +00:00
|
|
|
slot_url_.disconnect();
|
|
|
|
slot_name_.disconnect();
|
|
|
|
slot_html_.disconnect();
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
|
|
|
|
void FormUrl::apply()
|
2000-08-14 09:44:53 +00:00
|
|
|
{
|
2001-03-28 11:14:05 +00:00
|
|
|
controller().params().setContents(url()->get_text());
|
|
|
|
controller().params().setOptions(name()->get_text());
|
|
|
|
|
|
|
|
string cmdname("url");
|
|
|
|
if (html()->get_active())
|
|
|
|
cmdname = "htmlurl";
|
|
|
|
|
|
|
|
controller().params().setCmdName(cmdname);
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
|
|
|
|
void FormUrl::update()
|
2000-08-14 09:44:53 +00:00
|
|
|
{
|
2001-03-28 11:14:05 +00:00
|
|
|
// Disconnect signals so we dont trigger the input changed state.
|
|
|
|
// 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());
|
|
|
|
|
|
|
|
// Reconnect the signals.
|
|
|
|
connect_signals();
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
|
|
|
|
bool FormUrl::validate() const
|
2000-08-14 09:44:53 +00:00
|
|
|
{
|
2001-03-28 11:14:05 +00:00
|
|
|
// Always valid! (not really so, needs fixing).
|
|
|
|
return true;
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|
|
|
|
|
2001-03-28 11:14:05 +00:00
|
|
|
|
|
|
|
Gtk::Entry * FormUrl::url() const
|
|
|
|
{
|
|
|
|
return getWidget<Gtk::Entry>("url");
|
|
|
|
}
|
|
|
|
|
|
|
|
Gtk::Entry * FormUrl::name() const
|
|
|
|
{
|
|
|
|
return getWidget<Gtk::Entry>("name");
|
|
|
|
}
|
|
|
|
|
|
|
|
Gtk::CheckButton * FormUrl::html() const
|
|
|
|
{
|
|
|
|
return getWidget<Gtk::CheckButton>("html_type");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Button * FormUrl::ok_btn() const
|
|
|
|
{
|
|
|
|
return getWidget<Gtk::Button>("button_ok");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Button * FormUrl::cancel_btn() const
|
|
|
|
{
|
|
|
|
return getWidget<Gtk::Button>("button_cancel");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Button * FormUrl::apply_btn() const
|
|
|
|
{
|
|
|
|
return getWidget<Gtk::Button>("button_apply");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Gtk::Button * FormUrl::restore_btn() const
|
2000-08-14 09:44:53 +00:00
|
|
|
{
|
2001-03-28 11:14:05 +00:00
|
|
|
return getWidget<Gtk::Button>("button_restore");
|
2000-08-14 09:44:53 +00:00
|
|
|
}
|