From: Richard Heck Date: Sat, 17 Apr 2010 13:24:32 +0000 (+0000) Subject: Simplify VC output from InsetInfo. X-Git-Tag: 2.0.0~3433 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=64840ec5efc42d3074d5373b1c96fded87115835;hp=49945d3fac0b580a24f328e3429103a158618a6a;p=features.git Simplify VC output from InsetInfo. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34187 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/LyXVC.h b/src/LyXVC.h index 8cd2d89298..fb561a39e2 100644 --- a/src/LyXVC.h +++ b/src/LyXVC.h @@ -144,6 +144,7 @@ public: // type of the revision information enum RevisionInfo { + Unknown = 0, File = 1, Tree = 2, Author = 3, diff --git a/src/insets/InsetInfo.cpp b/src/insets/InsetInfo.cpp index 62e2f663cd..45aae52519 100644 --- a/src/insets/InsetInfo.cpp +++ b/src/insets/InsetInfo.cpp @@ -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: