Fix part of bug #5942:

- buffer-switch does open tabs even when open in tabs is disabled;
- buffer-switch open the document in a new tab even if it is already opened in another view.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34618 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Vincent van Ravesteijn 2010-06-07 21:57:37 +00:00
parent c43de0dd4b
commit 098f722a1f

View File

@ -2938,18 +2938,40 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
#endif
break;
}
case LFUN_BUFFER_SWITCH:
if (FileName::isAbsolute(to_utf8(cmd.argument()))) {
case LFUN_BUFFER_SWITCH: {
if (!FileName::isAbsolute(to_utf8(cmd.argument())))
break;
Buffer * buffer =
theBufferList().getBuffer(FileName(to_utf8(cmd.argument())));
if (buffer)
setBuffer(buffer);
else {
if (!buffer) {
dr.setError(true);
dr.setMessage(_("Document not loaded"));
break;
}
if (workArea(*buffer)) {
setBuffer(buffer);
break;
}
QList<int> const ids = guiApp->viewIds();
int i = 0;
for (; i != ids.size(); ++i) {
GuiView & gv = guiApp->view(ids[i]);
if (gv.workArea(*buffer)) {
gv.activateWindow();
gv.setBuffer(buffer);
break;
}
}
if (i == ids.size()) {
if (!lyxrc.open_buffers_in_tabs && documentBufferView() != 0) {
lyx::dispatch(FuncRequest(LFUN_WINDOW_NEW));
lyx::dispatch(cmd);
} else {
setBuffer(buffer);
}
}
break;
}
case LFUN_BUFFER_NEXT:
gotoNextOrPreviousBuffer(NEXTBUFFER);