]> git.lyx.org Git - lyx.git/commitdiff
Simplify VC output from InsetInfo.
authorRichard Heck <rgheck@comcast.net>
Sat, 17 Apr 2010 13:24:32 +0000 (13:24 +0000)
committerRichard Heck <rgheck@comcast.net>
Sat, 17 Apr 2010 13:24:32 +0000 (13:24 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34187 a592a061-630c-0410-9148-cb99ea01b6c8

src/LyXVC.h
src/insets/InsetInfo.cpp

index 8cd2d8929827b63492cedbb86533d089af555a83..fb561a39e2c4220bd621df6ff7278daa34dd5097 100644 (file)
@@ -144,6 +144,7 @@ public:
 
        // type of the revision information
        enum RevisionInfo {
+               Unknown = 0,
                File = 1,
                Tree = 2,
                Author = 3,
index 62e2f663cd721a88f89440e3a89245a91f47790f..45aae5251954fa11074ad266960f277b0e50120d 100644 (file)
@@ -363,29 +363,41 @@ void InsetInfo::updateInfo()
                break;
        }
        case BUFFER_INFO: {
-               if (name_ == "name")
+               if (name_ == "name") {
                        setText(from_utf8(buffer().fileName().onlyFileName()));
-               else if (name_ == "path")
+                       break;
+               }
+               if (name_ == "path") {
                        setText(from_utf8(buffer().filePath()));
-               else if (name_ == "class")
+                       break;
+               }
+               if (name_ == "class") {
                        setText(from_utf8(bp.documentClass().name()));
-               else if (name_ == "vcs-revision" && buffer().lyxvc().inUse() &&
-                        !buffer().lyxvc().revisionInfo(LyXVC::File).empty())
-                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::File)));
-               else if (name_ == "vcs-tree-revision" && buffer().lyxvc().inUse() &&
-                        !buffer().lyxvc().revisionInfo(LyXVC::Tree).empty())
-                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Tree)));
-               else if (name_ == "vcs-author" && buffer().lyxvc().inUse() &&
-                        !buffer().lyxvc().revisionInfo(LyXVC::Author).empty())
-                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Author)));
-               else if (name_ == "vcs-time" && buffer().lyxvc().inUse() &&
-                        !buffer().lyxvc().revisionInfo(LyXVC::Time).empty())
-                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Time)));
-               else if (name_ == "vcs-date" && buffer().lyxvc().inUse() &&
-                        !buffer().lyxvc().revisionInfo(LyXVC::Date).empty())
-                       setText(from_utf8(buffer().lyxvc().revisionInfo(LyXVC::Date)));
+                       break;
+               }
+               
+               // everything that follows is for version control.
+               // nothing that isn't version control should go below this line.
+               if (!buffer().lyxvc().inUse()) {
+                       setText(_("No version control"));
+                       break;
+               }
+               LyXVC::RevisionInfo itype = LyXVC::Unknown;
+               if (name_ == "vcs-revision")
+                       itype = LyXVC::File;
+               else if (name_ == "vcs-tree-revision")
+                       itype = LyXVC::Tree;
+               else if (name_ == "vcs-author")
+                       itype = LyXVC::Author;
+               else if (name_ == "vcs-time")
+                       itype = LyXVC::Time;
+               else if (name_ == "vcs-date")
+                       itype = LyXVC::Date;
+               string binfo = buffer().lyxvc().revisionInfo(itype);
+               if (binfo.empty())
+                       setText(bformat(_("[[%1$s unknown]]"), name_));
                else
-                       setText(_("Unknown buffer info"));
+                       setText(from_utf8(binfo));
                break;
        }
        case LYX_INFO: