]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormError.C
Implemented controller-view split for FormBibtex.
[lyx.git] / src / frontends / xforms / FormError.C
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "Dialogs.h"
19 #include "FormError.h"
20 #include "form_error.h"
21 #include "insets/inseterror.h"
22 #include "support/LAssert.h"
23
24 using SigC::slot;
25
26 FormError::FormError(LyXView * lv, Dialogs * d)
27         : FormInset( lv, d, _("LaTeX Error")),
28           inset_(0)
29 {
30         Assert(lv && d);
31         // let the dialog be shown
32         // This is a permanent connection so we won't bother
33         // storing a copy because we won't be disconnecting.
34         d->showError.connect(slot(this, &FormError::showInset));
35 }
36
37
38 FL_FORM * FormError::form() const
39 {
40         if (dialog_.get()) return dialog_->form;
41         return 0;
42 }
43
44
45 void FormError::disconnect()
46 {
47         inset_ = 0;
48         message_.erase();
49         FormInset::disconnect();
50 }
51
52
53 void FormError::showInset(InsetError * inset)
54 {
55         if (inset == 0) return; // Is this _really_ allowed? (Lgb)
56
57         // If connected to another inset, disconnect from it.
58         if (inset_)
59                 ih_.disconnect();
60
61         inset_ = inset;
62         message_ = inset->getContents();
63         ih_ = inset->hideDialog.connect(slot(this, &FormError::hide));
64         show();
65 }
66
67
68 void FormError::update()
69 {
70         fl_set_object_label(dialog_->message, message_.c_str());
71 }
72
73
74 void FormError::build()
75 {
76         dialog_.reset(build_error());
77
78         // Manage the cancel/close button
79         bc().setCancel(dialog_->button_cancel);
80         bc().refresh();
81 }