-// -*- C++ -*-
-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 2000 The LyX Team.
+/**
+ * \file ControlBibtex.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ======================================================
+ * \author John Levon
+ * \author Angus Leeming
+ * \author Herbert Voß
*
- * \file ControlBibtex.C
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS.
*/
-#include <algorithm>
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include <config.h>
+
#include "ControlBibtex.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "BufferView.h"
-using SigC::slot;
+#include "buffer.h"
+#include "bufferparams.h"
+
+#include "lyxrc.h"
+#include "helper_funcs.h"
+#include "tex_helpers.h"
+#include "gettext.h"
+
+#include "support/filetools.h"
+#include "support/globbing.h"
+
+using std::pair;
+using std::string;
+using std::vector;
-ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
- : ControlCommand(lv, d)
+
+namespace lyx {
+
+using support::FileFilterList;
+using support::OnlyFilename;
+
+namespace frontend {
+
+
+ControlBibtex::ControlBibtex(Dialog & d)
+ : ControlCommand(d, "bibtex")
+{}
+
+
+string const ControlBibtex::browseBib(string const & in_name) const
{
- d_.showBibtex.connect(slot(this, &ControlBibtex::showInset));
+ pair<string, string> dir1(_("Documents|#o#O"),
+ string(lyxrc.document_path));
+ FileFilterList const filter(_("BibTeX Databases (*.bib)"));
+ return browseRelFile(in_name, kernel().bufferFilepath(),
+ _("Select a BibTeX database to add"),
+ filter, false, dir1);
}
-void ControlBibtex::apply()
+
+string const ControlBibtex::browseBst(string const & in_name) const
{
- view().apply();
+ pair<string, string> dir1(_("Documents|#o#O"),
+ string(lyxrc.document_path));
+ FileFilterList const filter(_("BibTeX Styles (*.bst)"));
+ return browseRelFile(in_name, kernel().bufferFilepath(),
+ _("Select a BibTeX style"), filter, false, dir1);
+}
- if (inset_ && 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);
+void ControlBibtex::getBibStyles(vector<string> & data) const
+{
+ data.clear();
+
+ getTexFileList("bstFiles.lst", data);
+ // test, if we have a valid list, otherwise run rescan
+ if (data.empty()) {
+ rescanBibStyles();
+ getTexFileList("bstFiles.lst", data);
+ }
+ vector<string>::iterator it = data.begin();
+ vector<string>::iterator end = data.end();
+ for (; it != end; ++it) {
+ *it = OnlyFilename(*it);
+ }
+}
- // We need to do a redraw because the maximum
- // InsetBibKey width could have changed
- lv_.view()->redraw();
- lv_.view()->fitCursor(lv_.view()->getLyXText());
+
+void ControlBibtex::getBibFiles(vector<string> & data) const
+{
+ data.clear();
+
+ getTexFileList("bibFiles.lst", data);
+ // test, if we have a valid list, otherwise run rescan
+ if (data.empty()) {
+ rescanBibStyles();
+ getTexFileList("bibFiles.lst", data);
+ }
+ vector<string>::iterator it = data.begin();
+ vector<string>::iterator end = data.end();
+ for (; it != end; ++it) {
+ *it = OnlyFilename(*it);
}
}
+
+
+void ControlBibtex::rescanBibStyles() const
+{
+ rescanTexStyles();
+}
+
+
+bool ControlBibtex::usingBibtopic() const
+{
+ return kernel().buffer().params().use_bibtopic;
+}
+
+} // namespace frontend
+} // namespace lyx