lyx_mirror/src/frontends/xforms/FormError.C

82 lines
1.5 KiB
C++
Raw Normal View History

// -*- C++ -*-
/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2000 The LyX Team.
*
* ======================================================
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "Dialogs.h"
#include "FormError.h"
#include "form_error.h"
#include "insets/inseterror.h"
#include "support/LAssert.h"
using SigC::slot;
FormError::FormError(LyXView * lv, Dialogs * d)
: FormInset( lv, d, _("LaTeX Error")),
inset_(0)
{
Assert(lv && d);
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
d->showError.connect(slot(this, &FormError::showInset));
}
FL_FORM * FormError::form() const
{
if (dialog_.get()) return dialog_->form;
return 0;
}
void FormError::disconnect()
{
inset_ = 0;
message_.erase();
FormInset::disconnect();
}
void FormError::showInset(InsetError * inset)
{
if (inset == 0) return; // Is this _really_ allowed? (Lgb)
// If connected to another inset, disconnect from it.
if (inset_)
ih_.disconnect();
inset_ = inset;
message_ = inset->getContents();
ih_ = inset->hideDialog.connect(slot(this, &FormError::hide));
show();
}
void FormError::update()
{
fl_set_object_label(dialog_->message, message_.c_str());
}
void FormError::build()
{
dialog_.reset(build_error());
// Manage the cancel/close button
bc().setCancel(dialog_->button_cancel);
bc().refresh();
}