]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.cpp
typo
[lyx.git] / src / BufferView.cpp
index 076bff7af85021370adc4487d92167dd71ae189e..ca77d6969099011edb0d456d0451c750bed1d8bb 100644 (file)
@@ -993,8 +993,8 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
        // 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.
@@ -1008,10 +1008,14 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                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:
@@ -1239,9 +1243,17 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        }
 
        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]);
@@ -1250,7 +1262,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        // 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();
@@ -1262,10 +1274,19 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                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();
@@ -1318,7 +1339,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                                saveBookmark(0);
                        }
                }
-               if (!label.empty())
+               if (!label.empty())
                        gotoLabel(label);
                break;
        }
@@ -1544,8 +1565,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                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;
        }
@@ -1556,8 +1579,10 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                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;
        }
@@ -2165,8 +2190,8 @@ bool BufferView::setCursorFromInset(Inset const * inset)
 
 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;