]> git.lyx.org Git - lyx.git/blobdiff - src/buffer_funcs.cpp
[the "translation" patch series] Part 2: fixing document label translations
[lyx.git] / src / buffer_funcs.cpp
index 3d9cd80821a4a29379899de10ec387de7d8265ab..1f1cd7917c1c6c8490b875be1af000d27d1e990f 100644 (file)
@@ -49,6 +49,9 @@
 #include <boost/bind.hpp>
 #include <boost/filesystem/operations.hpp>
 
+using std::min;
+using std::string;
+
 
 namespace lyx {
 
@@ -63,9 +66,6 @@ using support::onlyFilename;
 using support::onlyPath;
 using support::unlink;
 
-using std::min;
-using std::string;
-
 namespace Alert = frontend::Alert;
 namespace fs = boost::filesystem;
 
@@ -181,20 +181,29 @@ bool loadLyXFile(Buffer * b, FileName const & s)
 }
 
 
+bool checkIfLoaded(FileName const & fn)
+{
+       return theBufferList().getBuffer(fn.absFilename());
+}
+
+
 Buffer * checkAndLoadLyXFile(FileName const & filename)
 {
        // File already open?
-       if (theBufferList().exists(filename.absFilename())) {
+       Buffer * checkBuffer = theBufferList().getBuffer(filename.absFilename());
+       if (checkBuffer) {
+               if (checkBuffer->isClean())
+                       return checkBuffer;
                docstring const file = makeDisplayPath(filename.absFilename(), 20);
-               docstring text = bformat(_("The document %1$s is already "
-                                                    "loaded.\n\nDo you want to revert "
-                                                    "to the saved version?"), file);
-               if (Alert::prompt(_("Revert to saved document?"),
-                               text, 0, 1,  _("&Revert"), _("&Switch to document")))
-                       return theBufferList().getBuffer(filename.absFilename());
+               docstring text = bformat(_(
+                               "The document %1$s is already loaded and has unsaved changes.\n"
+                               "Do you want to abandon your changes and reload the version on disk?"), file);
+               if (Alert::prompt(_("Reload saved document?"),
+                               text, 0, 1,  _("&Reload"), _("&Keep Changes")))
+                       return checkBuffer;
 
                // FIXME: should be LFUN_REVERT
-               if (theBufferList().close(theBufferList().getBuffer(filename.absFilename()), false))
+               if (theBufferList().close(checkBuffer, false))
                        // Load it again.
                        return checkAndLoadLyXFile(filename);
                else