]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
Continue working on the embedding feature. An additional parameter updateFile is...
[lyx.git] / src / BufferView.cpp
index c2b0d588887ff9ed64e3b4a848aa3f37a7053bb5..eca22404b2de20d0b7ea5826e8f03c1ddb483b4e 100644 (file)
@@ -49,6 +49,7 @@
 #include "TextClass.h"
 #include "TextMetrics.h"
 #include "TexRow.h"
+#include "TocBackend.h"
 #include "VSpace.h"
 #include "WordLangTuple.h"
 
@@ -530,8 +531,7 @@ docstring BufferView::contextMenu(int x, int y) const
        if (covering_inset)
                return covering_inset->contextMenu(*this, x, y);
 
-       // FIXME: Do something more elaborate here.
-       return from_ascii("edit");
+       return buffer_.inset().contextMenu(*this, x, y);
 }
 
 
@@ -1249,7 +1249,7 @@ bool BufferView::dispatch(FuncRequest const & cmd)
        case LFUN_BUFFER_TOGGLE_EMBEDDING: {
                // turn embedding on/off
                try {
-                       buffer_.embeddedFiles().enable(!buffer_.params().embedded, buffer_);
+                       buffer_.embeddedFiles().enable(!buffer_.params().embedded, buffer_, true);
                } catch (ExceptionMessage const & message) {
                        Alert::error(message.title_, message.details_);
                }
@@ -1609,15 +1609,15 @@ void BufferView::setCursorFromRow(int row)
 
 void BufferView::gotoLabel(docstring const & label)
 {
-       for (InsetIterator it = inset_iterator_begin(buffer_.inset()); it; ++it) {
-               vector<docstring> labels;
-               it->getLabelList(labels);
-               if (std::find(labels.begin(), labels.end(), label) != labels.end()) {
-                       setCursor(it);
-                       showCursor();
-                       return;
-               }
+       Toc & toc = buffer().tocBackend().toc("label");
+       TocIterator toc_it = toc.begin();
+       TocIterator end = toc.end();
+       for (; toc_it != end; ++toc_it) {
+               if (label == toc_it->str())
+                       dispatch(toc_it->action());
        }
+       //FIXME: We could do a bit more searching thanks to this:
+       //InsetLabel const * inset = buffer_.insetLabel(label);
 }