X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fxforms%2FFormBibtex.C;h=2f32c2434bc37f27c36f03256d26818d5cef7a28;hb=14c60d0aaeff364a78f77e163e6eae5fc3dab8c0;hp=13334e88b54d16244b9896e9b316612a9ee506e6;hpb=524a23ba3ad249e868b1012f00d0541f12a9a263;p=lyx.git diff --git a/src/frontends/xforms/FormBibtex.C b/src/frontends/xforms/FormBibtex.C index 13334e88b5..2f32c2434b 100644 --- a/src/frontends/xforms/FormBibtex.C +++ b/src/frontends/xforms/FormBibtex.C @@ -7,56 +7,26 @@ * \author John Levon */ -#include - -#include FORMS_H_LOCATION - #ifdef __GNUG__ #pragma implementation #endif - -#include "Dialogs.h" +#include +#include "ControlBibtex.h" #include "FormBibtex.h" -#include "LyXView.h" -#include "buffer.h" -#include "form_bibtex.h" -#include "lyxfunc.h" +#include "gettext.h" +#include "xformsBC.h" #include "debug.h" -using std::endl; -using SigC::slot; - -FormBibtex::FormBibtex(LyXView * lv, Dialogs * d) - : FormCommand(lv, d, _("BibTeX Database")) -{ - d->showBibtex.connect(slot(this, &FormBibtex::showInset)); -} - - -FL_FORM * FormBibtex::form() const -{ - if (dialog_.get()) - return dialog_->form; - return 0; -} - +FormBibtex::FormBibtex(ControlBibtex & c) + : FormBase2(c, _("BibTeX Database")) +{} -void FormBibtex::connect() -{ - fl_set_form_maxsize(form(), 2 * minw_, minh_); - FormCommand::connect(); -} - void FormBibtex::build() { dialog_.reset(build_bibtex()); - // Workaround dumb xforms sizing bug - minw_ = form()->w; - minh_ = form()->h; - fl_set_input_return(dialog_->database, FL_RETURN_CHANGED); fl_set_input_return(dialog_->style, FL_RETURN_CHANGED); @@ -70,50 +40,27 @@ void FormBibtex::build() } -bool FormBibtex::input(FL_OBJECT *, long) +ButtonPolicy::SMInput FormBibtex::input(FL_OBJECT *, long) { // minimal validation if (!compare(fl_get_input(dialog_->database),"")) - return false; + return ButtonPolicy::SMI_NOOP; - return true; + return ButtonPolicy::SMI_VALID; } void FormBibtex::update() { - fl_set_input(dialog_->database, params.getContents().c_str()); - fl_set_input(dialog_->style, params.getOptions().c_str()); - // Surely, this should reset the buttons to their original state? - // It doesn't. Instead "Restore" becomes a "Close" - //bc().refresh(); - bc().readOnly(lv_->buffer()->isReadonly()); + fl_set_input(dialog_->database, + controller().params().getContents().c_str()); + fl_set_input(dialog_->style, + controller().params().getOptions().c_str()); } void FormBibtex::apply() { - if (lv_->buffer()->isReadonly()) - return; - - params.setContents(fl_get_input(dialog_->database)); - params.setOptions(fl_get_input(dialog_->style)); - - if (inset_ != 0) { - // Only update if contents have changed - if (params != inset_->params()) { - if (params.getContents() != inset_->params().getContents()) - lv_->view()->ChangeCitationsIfUnique( - inset_->params().getContents(), params.getContents()); - - inset_->setParams(params); - lv_->view()->updateInset(inset_, true); - - // We need to do a redraw because the maximum - // InsetBibKey width could have changed - lv_->view()->redraw(); - lv_->view()->fitCursor(lv_->view()->getLyXText()); - } - } else - lyxerr[Debug::GUI] << "Editing non-existent bibtex inset !" << endl; + controller().params().setContents(fl_get_input(dialog_->database)); + controller().params().setOptions(fl_get_input(dialog_->style)); }