]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
ws changes mostly
[lyx.git] / src / lyxfunc.C
index 3420f6443de1ae4c88ea88866fe2ae280e685638..72045640197b3543cfa7c2fd8c8ba1a7e8bc923e 100644 (file)
@@ -79,9 +79,9 @@
 #include "frontends/Toolbars.h"
 
 #include "support/filefilterlist.h"
-#include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/forkedcontr.h"
+#include "support/fs_extras.h"
 #include "support/lstrings.h"
 #include "support/path.h"
 #include "support/package.h"
 #include "support/convert.h"
 #include "support/os.h"
 
+#include <boost/filesystem/operations.hpp>
+
 #include <sstream>
 
 using bv_funcs::freefont2string;
 
+using lyx::support::AbsolutePath;
 using lyx::support::AddName;
 using lyx::support::AddPath;
 using lyx::support::bformat;
 using lyx::support::ChangeExtension;
 using lyx::support::contains;
 using lyx::support::FileFilterList;
-using lyx::support::FileInfo;
 using lyx::support::FileSearch;
 using lyx::support::ForkedcallsController;
 using lyx::support::i18nLibFileSearch;
@@ -113,8 +115,6 @@ using lyx::support::Path;
 using lyx::support::QuoteName;
 using lyx::support::rtrim;
 using lyx::support::split;
-using lyx::support::strToInt;
-using lyx::support::strToUnsignedInt;
 using lyx::support::subst;
 using lyx::support::Systemcall;
 using lyx::support::token;
@@ -128,6 +128,7 @@ using std::string;
 using std::istringstream;
 
 namespace biblio = lyx::biblio;
+namespace fs = boost::filesystem;
 
 
 extern BufferList bufferlist;
@@ -487,7 +488,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                else if (name == "print")
                        enable = Exporter::IsExportable(*buf, "dvi")
                                && lyxrc.print_command != "none";
-               else if (name == "character")
+               else if (name == "character" || name == "mathpanel")
                        enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
                else if (name == "vclog")
                        enable = buf->lyxvc().inUse();
@@ -496,6 +497,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
                break;
        }
 
+       case LFUN_DIALOG_SHOW_NEW_INSET:
+               enable = cur.inset().lyxCode() != InsetBase::ERT_CODE;
+               break;
+
        case LFUN_DIALOG_UPDATE: {
                string const name = cmd.getArg(0);
                if (!buf)
@@ -540,7 +545,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const
        case LFUN_NOTIFY:
        case LFUN_GOTOFILEROW:
        case LFUN_GOTO_PARAGRAPH:
-       case LFUN_DIALOG_SHOW_NEW_INSET:
        case LFUN_DIALOG_SHOW_NEXT_INSET:
        case LFUN_DIALOG_HIDE:
        case LFUN_DIALOG_DISCONNECT_INSET:
@@ -1612,13 +1616,11 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
        if (filename.empty()) {
                filename = AddName(lyxrc.document_path,
                            "newfile" + convert<string>(++newfile_number) + ".lyx");
-               FileInfo fi(filename);
-               while (bufferlist.exists(filename) || fi.readable()) {
+               while (bufferlist.exists(filename) || fs::is_readable(filename)) {
                        ++newfile_number;
                        filename = AddName(lyxrc.document_path,
                                           "newfile" +  convert<string>(newfile_number) +
                                    ".lyx");
-                       fi.newFile(filename);
                }
        }
 
@@ -1697,8 +1699,7 @@ void LyXFunc::open(string const & fname)
        string const disp_fn(MakeDisplayPath(filename));
 
        // if the file doesn't exist, let the user create one
-       FileInfo const f(filename, true);
-       if (!f.exist()) {
+       if (!fs::exists(filename)) {
                // the user specifically chose this name. Believe them.
                view()->newFile(filename, "", true);
                return;
@@ -1781,7 +1782,7 @@ void LyXFunc::doImport(string const & argument)
 
        // if the file exists already, and we didn't do
        // -i lyx thefile.lyx, warn
-       if (FileInfo(lyxfile, true).exist() && filename != lyxfile) {
+       if (fs::exists(lyxfile) && filename != lyxfile) {
                string const file = MakeDisplayPath(lyxfile, 30);
 
                string text = bformat(_("The document %1$s already exists.\n\n"
@@ -1905,8 +1906,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_DISPLAY_GRAPHICS:
        case LyXRC::RC_DOCUMENTPATH:
                if (lyxrc_orig.document_path != lyxrc_new.document_path) {
-                       FileInfo fi(lyxrc_new.document_path);
-                       if (fi.isOK() && fi.isDir()) {
+                       if (fs::exists(lyxrc_new.document_path) &&
+                           fs::is_directory(lyxrc_new.document_path)) {
                                using lyx::support::package;
                                package().document_dir() = lyxrc.document_path;
                        }