// FIXME: This is a bit problematic because we don't check if this is
// a document BufferView or not for these LFUNs. We probably have to
// dispatch both to currentBufferView() and, if that fails,
- // to documentBufferView(); same as we do know for current Buffer and
- // document Buffer. Ideally those LFUN should go to Buffer as they*
+ // to documentBufferView(); same as we do now for current Buffer and
+ // document Buffer. Ideally those LFUN should go to Buffer as they
// operate on the full Buffer and the cursor is only needed either for
// an Undo record or to restore a cursor position. But we don't know
// how to do that inside Buffer of course.
break;
case LFUN_UNDO:
- flag.setEnabled(buffer_.undo().hasUndoStack());
+ // We do not use the LyXAction flag for readonly because Undo sets the
+ // buffer clean/dirty status by itself.
+ flag.setEnabled(!buffer_.isReadonly() && buffer_.undo().hasUndoStack());
break;
case LFUN_REDO:
- flag.setEnabled(buffer_.undo().hasRedoStack());
+ // We do not use the LyXAction flag for readonly because Redo sets the
+ // buffer clean/dirty status by itself.
+ flag.setEnabled(!buffer_.isReadonly() && buffer_.undo().hasRedoStack());
break;
case LFUN_FILE_INSERT:
case LFUN_FILE_INSERT_PLAINTEXT_PARA:
}
case LFUN_TEXTCLASS_APPLY: {
- if (!LayoutFileList::get().load(argument, buffer_.temppath()) &&
- !LayoutFileList::get().load(argument, buffer_.filePath()))
+ // since this shortcircuits, the second call is made only if
+ // the first fails
+ bool const success =
+ LayoutFileList::get().load(argument, buffer_.temppath()) ||
+ LayoutFileList::get().load(argument, buffer_.filePath());
+ if (!success) {
+ docstring s = bformat(_("The document class `%1$s' "
+ "could not be loaded."), from_utf8(argument));
+ frontend::Alert::error(_("Could not load class"), s);
break;
+ }
LayoutFile const * old_layout = buffer_.params().baseClass();
LayoutFile const * new_layout = &(LayoutFileList::get()[argument]);
// nothing to do
break;
- //Save the old, possibly modular, layout for use in conversion.
+ // Save the old, possibly modular, layout for use in conversion.
DocumentClass const * const oldDocClass =
buffer_.params().documentClassPtr();
cur.recordUndoFullDocument();
break;
}
- case LFUN_TEXTCLASS_LOAD:
- LayoutFileList::get().load(argument, buffer_.temppath()) ||
- LayoutFileList::get().load(argument, buffer_.filePath());
+ case LFUN_TEXTCLASS_LOAD: {
+ // since this shortcircuits, the second call is made only if
+ // the first fails
+ bool const success =
+ LayoutFileList::get().load(argument, buffer_.temppath()) ||
+ LayoutFileList::get().load(argument, buffer_.filePath());
+ if (!success) {
+ docstring s = bformat(_("The document class `%1$s' "
+ "could not be loaded."), from_utf8(argument));
+ frontend::Alert::error(_("Could not load class"), s);
+ }
break;
+ }
case LFUN_LAYOUT_RELOAD: {
DocumentClass const * const oldClass = buffer_.params().documentClassPtr();
saveBookmark(0);
}
}
- if (!label.empty())
+ if (!label.empty())
gotoLabel(label);
break;
}
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
BIBTEX_CODE);
if (inset) {
- if (inset->addDatabase(cmd.argument()))
- buffer_.updateBibfilesCache();
+ if (inset->addDatabase(cmd.argument())) {
+ buffer_.invalidateBibfileCache();
+ dr.forceBufferUpdate();
+ }
}
break;
}
InsetBibtex * inset = getInsetByCode<InsetBibtex>(tmpcur,
BIBTEX_CODE);
if (inset) {
- if (inset->delDatabase(cmd.argument()))
- buffer_.updateBibfilesCache();
+ if (inset->delDatabase(cmd.argument())) {
+ buffer_.invalidateBibfileCache();
+ dr.forceBufferUpdate();
+ }
}
break;
}
void BufferView::gotoLabel(docstring const & label)
{
- std::vector<Buffer const *> bufs = buffer().allRelatives();
- std::vector<Buffer const *>::iterator it = bufs.begin();
+ ListOfBuffers bufs = buffer().allRelatives();
+ ListOfBuffers::iterator it = bufs.begin();
for (; it != bufs.end(); ++it) {
Buffer const * buf = *it;