translator.addPair(InsetInfo::MENU_INFO, "menu");
translator.addPair(InsetInfo::ICON_INFO, "icon");
translator.addPair(InsetInfo::BUFFER_INFO, "buffer");
+ translator.addPair(InsetInfo::LYX_INFO, "lyxinfo");
return translator;
}
case MENU_INFO:
case ICON_INFO: {
FuncRequest func = lyxaction.lookupFunc(name);
- return func.action_ != LFUN_UNKNOWN_ACTION;
+ return func.action() != LFUN_UNKNOWN_ACTION;
}
case LYXRC_INFO: {
ostringstream oss;
return name == "name" || name == "path" || name == "class" ||
name == "vcs-revision" || name == "vcs-tree-revision" ||
name == "vcs-author" || name == "vcs-date" || name == "vcs-time";
+ case LYX_INFO:
+ return name == "version";
}
return false;
}
bool InsetInfo::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & flag) const
{
- switch (cmd.action_) {
+ switch (cmd.action()) {
case LFUN_INSET_SETTINGS:
return InsetCollapsable::getStatus(cur, cmd, flag);
void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
{
// allow selection, copy but not cut, delete etc
- switch (cmd.action_) {
+ switch (cmd.action()) {
case LFUN_INSET_SETTINGS:
InsetCollapsable::doDispatch(cur, cmd);
break;
break;
case SHORTCUT_INFO:
case SHORTCUTS_INFO: {
- FuncRequest func = lyxaction.lookupFunc(name_);
- if (func.action_ == LFUN_UNKNOWN_ACTION) {
+ FuncRequest const func = lyxaction.lookupFunc(name_);
+ if (func.action() == LFUN_UNKNOWN_ACTION) {
error("Unknown action %1$s");
break;
}
}
case MENU_INFO: {
docstring_list names;
- FuncRequest func = lyxaction.lookupFunc(name_);
- if (func.action_ == LFUN_UNKNOWN_ACTION) {
+ FuncRequest const func = lyxaction.lookupFunc(name_);
+ if (func.action() == LFUN_UNKNOWN_ACTION) {
error("Unknown action %1$s");
break;
}
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:
+ if (name_ == "version")
+ setText(from_ascii(PACKAGE_VERSION));
}
}