X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FMenuBackend.cpp;h=0180e42271ec6bad779be2e6bef346effdad627a;hb=559c2f648239fff4fec769b34b30ccff23491e31;hp=dce50f52d11a7259bc08c0c5d71b5305401ae91a;hpb=36481c274467f5e64cdef6f735592c13da649a41;p=lyx.git diff --git a/src/MenuBackend.cpp b/src/MenuBackend.cpp index dce50f52d1..0180e42271 100644 --- a/src/MenuBackend.cpp +++ b/src/MenuBackend.cpp @@ -456,24 +456,27 @@ void expandLastfiles(Menu & tomenu) void expandDocuments(Menu & tomenu) { - typedef vector Strings; - Strings const names = theBufferList().getFileNames(); - - if (names.empty()) { - tomenu.add(MenuItem(MenuItem::Command, _("No Document Open!"), - FuncRequest(LFUN_NOACTION))); + Buffer * first = theBufferList().first(); + if (first) { + Buffer * b = first; + int ii = 1; + + // We cannot use a for loop as the buffer list cycles. + do { + docstring label = makeDisplayPath(b->fileName(), 20); + if (!b->isClean()) label = label + "*"; + if (ii < 10) + label = convert(ii) + ". " + label + '|' + convert(ii); + tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, b->fileName()))); + + b = theBufferList().next(b); + ++ii; + } while (b != first); + } else { + tomenu.add(MenuItem(MenuItem::Command, _("No Documents Open!"), + FuncRequest(LFUN_NOACTION))); return; } - - int ii = 1; - Strings::const_iterator docit = names.begin(); - Strings::const_iterator end = names.end(); - for (; docit != end; ++docit, ++ii) { - docstring label = makeDisplayPath(*docit, 20); - if (ii < 10) - label = convert(ii) + ". " + label + char_type('|') + convert(ii); - tomenu.add(MenuItem(MenuItem::Command, label, FuncRequest(LFUN_BUFFER_SWITCH, *docit))); - } } @@ -705,6 +708,10 @@ void expandToc(Menu & tomenu, Buffer const * buf) return; } + Buffer* cbuf = const_cast(buf); + cbuf->tocBackend().update(); + cbuf->structureChanged(); + // Add an entry for the master doc if this is a child doc Buffer const * const master = buf->getMasterBuffer(); if (buf != master) {