Allow setting fields in fs subtree. Use for an application tag used for starting a specialized viewer

This commit is contained in:
dockes 2009-10-30 10:16:37 +00:00
parent e7dfd57d6e
commit 4d0e860a04
5 changed files with 25 additions and 10 deletions

View File

@ -386,7 +386,7 @@ bool RclConfig::inStopSuffixes(const string& fni)
}
}
string RclConfig::getMimeTypeFromSuffix(const string &suff)
string RclConfig::getMimeTypeFromSuffix(const string& suff)
{
string mtype;
mimemap->get(suff, mtype, m_keydir);
@ -611,10 +611,14 @@ string RclConfig::fieldCanon(const string& f)
return fld;
}
string RclConfig::getMimeViewerDef(const string &mtype)
string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag)
{
LOGDEB(("RclConfig::getMimeViewerDef: mtype %s apptag %s\n",
mtype.c_str(), apptag.c_str()));
string hs;
mimeview->get(mtype, hs, "view");
if (apptag.empty() || !mimeview->get(mtype + string("|") + apptag,
hs, "view"))
mimeview->get(mtype, hs, "view");
return hs;
}
@ -624,7 +628,7 @@ bool RclConfig::getMimeViewerDefs(vector<pair<string, string> >& defs)
return false;
list<string>tps = mimeview->getNames("view");
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it)));
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it, "")));
}
return true;
}

View File

@ -176,7 +176,7 @@ class RclConfig {
const map<string, string>& getXattrToField() {return m_xattrtofld;}
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
string getMimeViewerDef(const string &mimetype);
string getMimeViewerDef(const string &mimetype, const string& apptag);
bool getMimeViewerDefs(vector<pair<string, string> >&);
bool setMimeViewerDef(const string& mimetype, const string& cmd);

View File

@ -918,9 +918,13 @@ void RclMain::startNativeViewer(Rcl::Doc doc)
// Look for appropriate viewer
string cmd;
if (prefs.useDesktopOpen) {
cmd = rclconfig->getMimeViewerDef("application/x-all");
cmd = rclconfig->getMimeViewerDef("application/x-all", "");
} else {
cmd = rclconfig->getMimeViewerDef(doc.mimetype);
string apptag;
map<string,string>::const_iterator it;
if ((it = doc.meta.find("apptag")) != doc.meta.end())
apptag = it->second;
cmd = rclconfig->getMimeViewerDef(doc.mimetype, apptag);
}
if (cmd.length() == 0) {

View File

@ -217,7 +217,13 @@ void ResListPager::displayPage()
linksbuf += string("<a href=") + vlbuf + ">" + trans("Preview")
+ "</a>&nbsp;&nbsp;";
}
if (!RclConfig::getMainConfig()->getMimeViewerDef(doc.mimetype).empty()) {
string apptag;
map<string,string>::const_iterator it;
if ((it = doc.meta.find("apptag")) != doc.meta.end())
apptag = it->second;
if (!RclConfig::getMainConfig()->getMimeViewerDef(doc.mimetype, apptag).empty()) {
sprintf(vlbuf, "E%d", docnumforlinks);
linksbuf += string("<a href=") + vlbuf + ">" + trans("Open")
+ "</a>";

View File

@ -35,10 +35,11 @@ recipient = XTO
#
# Some fields are stored by default, don't add them here, else they will be
# stored twice: caption, keywords, abstract, filename, mimetype, url
# "author" used to be stored by default, now set here as optional
# Only canonical names should be used here, not aliases.
# "author" used to be stored by default, now set here as optional
# "apptag" is used for viewer specialization (depending on local config)
[stored]
stored = author
stored = author apptag
##########################
# This section defines field names aliases or synonyms. Any right hand side