2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
15 #pragma implementation
20 #include "FormError.h"
25 #include <gtk--/label.h>
26 #include <gtk--/box.h>
27 #include <gtk--/button.h>
28 #include <gtk--/buttonbox.h>
29 #include <gnome--/stock.h>
30 #include <gtk--/separator.h>
31 #include <gtk--/alignment.h>
33 // temporary solution for LyXView
35 extern GLyxAppWin * mainAppWin;
38 FormError::FormError(LyXView * lv, Dialogs * d)
39 : lv_(lv), d_(d), inset_(0), u_(0), h_(0), ih_(0), dialog_(0)
41 // let the dialog be shown
42 // These are permanent connections so we won't bother
43 // storing a copy because we won't be disconnecting.
44 d->showError.connect(slot(this, &FormError::showInset));
48 FormError::~FormError()
53 void FormError::showInset( InsetError * const inset )
55 if( dialog_!=0 || inset == 0 ) return;
58 ih_ = inset_->hide.connect(slot(this, &FormError::hide));
63 void FormError::show()
67 using namespace Gtk::Box_Helpers;
69 Gtk::Label * label = manage( new Gtk::Label(inset_->getContents()) );
70 Gtk::Box * hbox = manage( new Gtk::HBox() );
71 Gtk::Button * b_close = Gtk::wrap( GTK_BUTTON( gnome_stock_button(GNOME_STOCK_BUTTON_CLOSE) ) );
72 Gtk::Alignment * alg1 = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) );
73 Gtk::Alignment * mbox = manage( new Gtk::Alignment(0.5, 0.5, 0, 0) );
81 hbox->children().push_back(Element(*label, false, false));
82 hbox->children().push_back(Element(*manage(new Gtk::VSeparator()), false, false));
83 hbox->children().push_back(Element(*alg1, false, false));
87 // packing dialog to main window
89 mainAppWin->add_action(*dialog_, _(" Error "));
92 GTK_WIDGET_SET_FLAGS (GTK_WIDGET(b_close->gtkobj()), GTK_CAN_DEFAULT);
93 gtk_widget_grab_focus (GTK_WIDGET(b_close->gtkobj()));
94 gtk_widget_grab_default (GTK_WIDGET(b_close->gtkobj()));
97 b_close->clicked.connect(slot(mainAppWin, &GLyxAppWin::remove_action));
98 dialog_->destroy.connect(slot(this, &FormError::free));
100 u_ = d_->updateBufferDependent.connect(slot(this, &FormError::updateSlot));
101 h_ = d_->hideBufferDependent.connect(slot(this, &FormError::hide));
105 void FormError::updateSlot(bool buffchanged)
107 if (buffchanged) hide();
110 void FormError::hide()
112 if (dialog_!=0) mainAppWin->remove_action();
115 void FormError::free()
127 void FormError::apply()