]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlRef.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlRef.C
index b909d5bb88d4560f4692c1bd13c3ba76e6dde7fc..570f07fece1c46de728db7d94c15a02c14c06923 100644 (file)
@@ -1,55 +1,84 @@
-/* This file is part of
- * ====================================================== 
- *
- *           LyX, The Document Processor
- *
- *           Copyright 2001 The LyX Team.
+/**
+ * \file ControlRef.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * ======================================================
+ * \author Angus Leeming
  *
- * \file ControlRef.C
- * \author Angus Leeming <a.leeming@ic.ac.uk>
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
-#include "ViewBase.h"
-#include "ButtonControllerBase.h"
 #include "ControlRef.h"
-#include "Dialogs.h"
-#include "LyXView.h"
-#include "buffer.h"
 #include "lyxfunc.h"
+#include "buffer.h"
+#include "bufferlist.h"
+#include "funcrequest.h"
+
+#include "support/filetools.h" // MakeAbsPath, MakeDisplayPath
+
+using namespace lyx::support;
+
+using std::vector;
+
+extern BufferList bufferlist;
 
-using SigC::slot;
 
-ControlRef::ControlRef(LyXView & lv, Dialogs & d)
-       : ControlCommand(lv, d, LFUN_REF_INSERT)
+ControlRef::ControlRef(Dialog & d)
+       : ControlCommand(d, "ref")
+{}
+
+
+vector<string> const ControlRef::getLabelList(string const & name) const
 {
-       d_.showRef.connect(slot(this, &ControlRef::showInset));
-       d_.createRef.connect(slot(this, &ControlRef::createInset));
+       Buffer const * buf = bufferlist.getBuffer(MakeAbsPath(name));
+       if (!buf)
+               buf = kernel().buffer();
+       vector<string> list;
+       buf->getLabelList(list);
+       return list;
 }
 
 
-std::vector<string> const ControlRef::getLabelList() const
+void ControlRef::gotoRef(string const & ref)
 {
-       return lv_.buffer()->getLabelList();
+       kernel().dispatch(FuncRequest(LFUN_BOOKMARK_SAVE, "0"), false);
+       kernel().dispatch(FuncRequest(LFUN_REF_GOTO, ref));
 }
 
 
-void ControlRef::gotoRef(string const & ref) const
+void ControlRef::gotoBookmark()
 {
-       lv_.getLyXFunc()->Dispatch(LFUN_BOOKMARK_SAVE, "0");
-       lv_.getLyXFunc()->Dispatch(LFUN_REF_GOTO, ref);
+       kernel().dispatch(FuncRequest(LFUN_BOOKMARK_GOTO, "0"), false);
 }
 
 
-void ControlRef::gotoBookmark() const
+vector<string> const ControlRef::getBufferList() const
 {
-       lv_.getLyXFunc()->Dispatch(LFUN_BOOKMARK_GOTO, "0");
+       vector<string> buffers = bufferlist.getFileNames();
+       for (vector<string>::iterator it = buffers.begin();
+            it != buffers.end(); ++it) {
+               *it = MakeDisplayPath(*it);
+       }
+
+       return buffers;
 }
 
+
+int ControlRef::getBufferNum() const
+{
+       vector<string> buffers = bufferlist.getFileNames();
+       string const name = kernel().buffer()->fileName();
+       vector<string>::const_iterator cit =
+               find(buffers.begin(), buffers.end(), name);
+       if (cit == buffers.end())
+               return 0;
+       return int(cit - buffers.begin());
+}
+
+string const ControlRef::getBufferName(int num) const
+{
+       return bufferlist.getFileNames()[num];
+}