]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlBibtex.C
introduce namespace lyx::support
[lyx.git] / src / frontends / controllers / ControlBibtex.C
index 8614b105bbb9f4e76fd8b154dacfedbef83a0fdd..36d67785723bf00c04247f162e05a45d53761df6 100644 (file)
@@ -1,53 +1,87 @@
-// -*- 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 Voss
  *
- * \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"
+#include "Kernel.h"
+
+#include "buffer.h"
+#include "lyxrc.h"
+#include "helper_funcs.h"
+#include "tex_helpers.h"
+#include "gettext.h"
+
+#include "support/filetools.h"
+
+using namespace lyx::support;
+
+using std::pair;
+using std::vector;
+
 
-using SigC::slot;
+ControlBibtex::ControlBibtex(Dialog & d)
+       : ControlCommand(d, "bibtex")
+{}
 
-ControlBibtex::ControlBibtex(LyXView & lv, Dialogs & d)
-       : ControlCommand(lv, d)
+
+string const ControlBibtex::Browse(string const & in_name,
+                                  string const & title,
+                                  string const & pattern)
 {
-       d_.showBibtex.connect(slot(this, &ControlBibtex::showInset));
+       pair<string, string> dir1(_("Documents|#o#O"),
+                                 string(lyxrc.document_path));
+       return browseRelFile(in_name, kernel().buffer()->filePath(),
+                            title, pattern, false, dir1);
 }
 
-void ControlBibtex::apply()
+
+void ControlBibtex::getBibStyles(vector<string> & data) const
 {
-       view().apply();
+       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);
+       }
+}
 
-       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::getBibFiles(vector<string> & data) const
+{
+       data.clear();
 
-               // We need to do a redraw because the maximum
-               // InsetBibKey width could have changed
-               lv_.view()->redraw();
-               lv_.view()->fitCursor(lv_.view()->getLyXText());
+       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();
+}