*
* Full author contact details are available in file CREDITS
*/
-#include <config.h>
+#include <config.h>
#include "insetbibtex.h"
#include "buffer.h"
#include "BufferView.h"
#include "debug.h"
+#include "funcrequest.h"
#include "gettext.h"
-
-#include "frontends/LyXView.h"
-#include "frontends/Dialogs.h"
+#include "latexrunparams.h"
#include "support/filetools.h"
#include "support/path.h"
using std::pair;
-InsetBibtex::InsetBibtex(InsetCommandParams const & p, bool)
+InsetBibtex::InsetBibtex(InsetCommandParams const & p)
: InsetCommand(p)
{}
+InsetBibtex::~InsetBibtex()
+{
+ InsetCommandMailer("bibtex", *this).hideDialog();
+}
+
+
+dispatch_result InsetBibtex::localDispatch(FuncRequest const & cmd)
+{
+ switch (cmd.action) {
+
+ case LFUN_INSET_EDIT:
+ InsetCommandMailer("bibtex", *this).showDialog(cmd.view());
+ return DISPATCHED;
+
+ case LFUN_INSET_MODIFY: {
+ InsetCommandParams p;
+ InsetCommandMailer::string2params(cmd.argument, p);
+ if (p.getCmdName().empty())
+ return DISPATCHED;
+
+ if (view() && p.getContents() != params().getContents()) {
+ view()->ChangeCitationsIfUnique(params().getContents(),
+ p.getContents());
+ }
+
+ setParams(p);
+ cmd.view()->updateInset(this);
+ return DISPATCHED;
+ }
+
+ default:
+ return InsetCommand::localDispatch(cmd);
+ }
+
+}
+
string const InsetBibtex::getScreenLabel(Buffer const *) const
{
return _("BibTeX Generated References");
int InsetBibtex::latex(Buffer const * buffer, ostream & os,
- bool /*fragile*/, bool/*fs*/) const
+ LatexRunParams const & runparams) const
{
// changing the sequence of the commands
// 1. \bibliographystyle{style}
}
}
- if (!buffer->niceFile
+ if (!runparams.nice
&& IsFileReadable(MakeAbsPath(style, buffer->filePath()) + ".bst")) {
style = MakeAbsPath(style, buffer->filePath());
}
// have a comma-separated list of bibliographies
string db_out;
while (!adb.empty()) {
- if (!buffer->niceFile &&
+ if (!runparams.nice &&
IsFileReadable(MakeAbsPath(adb, buffer->filePath())+".bib"))
adb = os::external_path(MakeAbsPath(adb, buffer->filePath()));
db_out += adb;
}
-void InsetBibtex::edit(BufferView * bv, int, int, mouse_button::state)
-{
- bv->owner()->getDialogs().showBibtex(this);
-}
-
-
-void InsetBibtex::edit(BufferView * bv, bool)
-{
- edit(bv, 0, 0, mouse_button::none);
-}
-
-
bool InsetBibtex::addDatabase(string const & db)
{
string contents(getContents());