implement mime exceptions to "use desktop open" so that we can use evince and pass page and search string parameters for pdf,ps and dvi even when all other mime types are passed to xdg-open

This commit is contained in:
Jean-Francois Dockes 2012-10-04 09:51:29 +02:00
parent b873e5cff4
commit a732e429bb
12 changed files with 263 additions and 42 deletions

View file

@ -175,6 +175,8 @@ RclConfig::RclConfig(const string *argcnf)
m_reason = string("No/bad mimeconf in: ") + cnferrloc;
return;
}
mimeview = new ConfStack<ConfSimple>("mimeview", m_cdirs, false);
if (mimeview == 0)
mimeview = new ConfStack<ConfSimple>("mimeview", m_cdirs, true);
if (mimeview == 0 || !mimeview->ok()) {
m_reason = string("No/bad mimeview in: ") + cnferrloc;
@ -789,14 +791,49 @@ bool RclConfig::getFieldConfParam(const string &name, const string &sk,
return m_fields->get(name, value, sk);
}
string RclConfig::getMimeViewerAllEx()
{
string hs;
if (mimeview == 0)
return hs;
mimeview->get("xallexcepts", hs, "");
return hs;
}
string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag)
bool RclConfig::setMimeViewerAllEx(const string& allex)
{
if (mimeview == 0)
return false;
if (!mimeview->set("xallexcepts", allex, "")) {
m_reason = string("RclConfig:: cant set value. Readonly?");
return false;
}
return true;
}
string RclConfig::getMimeViewerDef(const string &mtype, const string& apptag,
bool useall)
{
LOGDEB2(("RclConfig::getMimeViewerDef: mtype [%s] apptag [%s]\n",
mtype.c_str(), apptag.c_str()));
string hs;
if (mimeview == 0)
return hs;
if (useall) {
// Check for exception
string excepts = getMimeViewerAllEx();
vector<string> vex;
stringToTokens(excepts, vex);
vector<string>::iterator it = find(vex.begin(), vex.end(), mtype);
if (it == vex.end()) {
mimeview->get("application/x-all", hs, "view");
return hs;
}
// Fallthrough to normal case.
}
if (apptag.empty() || !mimeview->get(mtype + string("|") + apptag,
hs, "view"))
mimeview->get(mtype, hs, "view");
@ -808,8 +845,9 @@ bool RclConfig::getMimeViewerDefs(vector<pair<string, string> >& defs)
if (mimeview == 0)
return false;
vector<string>tps = mimeview->getNames("view");
for (vector<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it, "")));
for (vector<string>::const_iterator it = tps.begin();
it != tps.end();it++) {
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it, "", 0)));
}
return true;
}
@ -818,24 +856,8 @@ bool RclConfig::setMimeViewerDef(const string& mt, const string& def)
{
if (mimeview == 0)
return false;
string pconfname = path_cat(getConfDir(), "mimeview");
// Make sure this exists
close(open(pconfname.c_str(), O_CREAT|O_WRONLY, 0600));
ConfTree tree(pconfname.c_str());
if (!tree.set(mt, def, "view")) {
m_reason = string("RclConfig::setMimeViewerDef: cant set value in ")
+ pconfname;
return false;
}
vector<string> cdirs;
cdirs.push_back(m_confdir);
cdirs.push_back(path_cat(m_datadir, "examples"));
delete mimeview;
mimeview = new ConfStack<ConfSimple>("mimeview", cdirs, true);
if (mimeview == 0 || !mimeview->ok()) {
m_reason = string("No/bad mimeview in: ") + m_confdir;
if (!mimeview->set(mt, def, "view")) {
m_reason = string("RclConfig:: cant set value. Readonly?");
return false;
}
return true;

View file

@ -226,7 +226,10 @@ class RclConfig {
bool getFieldConfParam(const string &name, const string &sk, string &value);
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
string getMimeViewerDef(const string &mimetype, const string& apptag);
string getMimeViewerDef(const string &mimetype, const string& apptag,
bool useall);
string getMimeViewerAllEx();
bool setMimeViewerAllEx(const string& allex);
bool getMimeViewerDefs(vector<pair<string, string> >&);
bool setMimeViewerDef(const string& mimetype, const string& cmd);
/** Check if mime type is designated as needing no uncompress before view

View file

@ -502,6 +502,20 @@ recoll
described in the <link linkend="rcl.install.external">external
packages section.</link></para>
<sect2 id="rcl.indexing.config.sens">
<title>Index case and diacritics sensitivity</title>
<para>Index case sensitivity
is controlled by the <i>indexStripChars</i> configuration
variable which can only be changed by editing the
configuration file. Any change implies an index reset (not
automated by recoll), and all indexes in a search must be set
in the same way (again, not checked by recoll). </para>
<sect2 id="rcl.indexing.config.gui">
<title>The indexing configuration GUI</title>
@ -4040,6 +4054,17 @@ skippedPaths = ~/somedir/&lowast;.txt
<variablelist>
<varlistentry><term><varname>indexStripChars</varname></term>
<listitem><para>Decide if we strip characters of diacritics and
convert them to lower-case before terms are indexed. If we
don't, searches sensitive to case and diacritics can be
performed, but the index will be bigger, and some marginal
weirdness may sometimes occur. The default is a stripped
index (<literal>indexStripChars = 1</literal> for
now.</para>
</listitem>
</varlistentry>
<varlistentry><term><varname>nonumbers</varname></term>
<listitem><para>If this set to true, no terms will be generated
for numbers. For example "123", "1.5e6", 192.168.1.4, would not
@ -4228,6 +4253,26 @@ unac_except_trans =
<variablelist>
<varlistentry><term><varname>autodiacsens</varname></term>
<listitem><para>IF the index is not stripped, decide if we
automatically trigger diacritics sensitivity if the search
term has accented characters (not in
<literal>unac_except_trans</literal>). Else you need to use
the query language and the <literal>D</literal> modifier to
specify diacritics sensitivity. Default is no.</para>
</listitem>
</varlistentry>
<varlistentry><term><varname>autocasesens</varname></term>
<listitem><para>IF the index is not stripped, decide if we
automatically trigger character case sensitivity if the
search term has upper-case characters in any but the first
position. Else you need to use the query language and the
<literal>C</literal> modifier to specify character-case
sensitivity. Default is yes.</para>
</listitem>
</varlistentry>
<varlistentry><term><varname>loglevel,daemloglevel</varname></term>
<listitem><para>Verbosity level for recoll and
recollindex. A value of 4 lists quite a lot of
@ -4246,7 +4291,6 @@ unac_except_trans =
</listitem>
</varlistentry>
<varlistentry><term><varname>mondelaypatterns</varname></term>
<listitem><para>This allows specify wildcard path patterns
(processed with fnmatch(3) with 0 flag), to match files which

View file

@ -398,7 +398,7 @@ void RclMain::initDbOpen()
}
// Start native viewer or preview for input Doc. This is used allow
// the using Recoll result docs with an ipath in another app. We act
// using Recoll result docs with an ipath in another app. We act
// as a proxy to extract the data and start a viewer.
// The Url are encoded as file://path#ipath
void RclMain::viewUrl()
@ -428,7 +428,8 @@ void RclMain::viewUrl()
// preview.
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
string viewer = theconfig->getMimeViewerDef(doc.mimetype, apptag);
string viewer = theconfig->getMimeViewerDef(doc.mimetype, apptag,
prefs.useDesktopOpen);
if (viewer.empty()) {
startPreview(doc);
} else {
@ -1502,14 +1503,10 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
{
LOGDEB(("RclMain::startNativeViewer: page %d\n", pagenum));
// Look for appropriate viewer
string cmdplusattr;
if (prefs.useDesktopOpen) {
cmdplusattr = theconfig->getMimeViewerDef("application/x-all", "");
} else {
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag);
}
string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag,
prefs.useDesktopOpen);
if (cmdplusattr.empty()) {
QMessageBox::warning(0, "Recoll",

View file

@ -920,7 +920,7 @@ void ResList::createPopupMenu(const QPoint& pos)
if (havedoc)
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
if (havedoc && !theconfig->getMimeViewerDef(doc.mimetype, apptag).empty()) {
if (havedoc && !theconfig->getMimeViewerDef(doc.mimetype, apptag, 0).empty()) {
popup->addAction(tr("&Open"), this, SLOT(menuEdit()));
}
popup->addAction(tr("Copy &File Name"), this, SLOT(menuCopyFN()));

View file

@ -177,6 +177,27 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="textLabelallex">
<property name="text">
<string>Exceptions</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="allExLE">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="viewActionPB">
<property name="text">

View file

@ -81,6 +81,8 @@ void UIPrefsDialog::init()
replAbsCB, SLOT(setEnabled(bool)));
connect(useDesktopOpenCB, SIGNAL(toggled(bool)),
viewActionPB, SLOT(setDisabled(bool)));
connect(useDesktopOpenCB, SIGNAL(toggled(bool)),
allExLE, SLOT(setEnabled(bool)));
setFromPrefs();
}
@ -102,6 +104,8 @@ void UIPrefsDialog::setFromPrefs()
// External editor. Can use desktop prefs or internal
useDesktopOpenCB->setChecked(prefs.useDesktopOpen);
viewActionPB->setEnabled(!prefs.useDesktopOpen);
allExLE->setEnabled(prefs.useDesktopOpen);
allExLE->setText(QString::fromUtf8(theconfig->getMimeViewerAllEx().c_str()));
keepSortCB->setChecked(prefs.keepSort);
previewHtmlCB->setChecked(prefs.previewHtml);
@ -242,6 +246,8 @@ void UIPrefsDialog::accept()
prefs.startWithAdvSearchOpen = initStartAdvCB->isChecked();
prefs.useDesktopOpen = useDesktopOpenCB->isChecked();
theconfig->setMimeViewerAllEx((const char*)allExLE->text().toUtf8());
prefs.keepSort = keepSortCB->isChecked();
prefs.previewHtml = previewHtmlCB->isChecked();

View file

@ -236,7 +236,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
if (!config->getMimeViewerDef(doc.mimetype, apptag).empty()) {
if (!config->getMimeViewerDef(doc.mimetype, apptag, false).empty()) {
linksbuf << "<a href=\"E" << docnumforlinks << "\">"
<< trans("Open") << "</a>";
}

View file

@ -9,6 +9,12 @@
# exceptions and the list is normally empty
#nouncompforviewmts =
# Exceptions when using the x-all entry: these types will use their local
# definition. This is useful, e.g. for pdf, where we can pass additional
# parameters like page to open and search string when using the local
# definition
xallexcepts = application/pdf application/postscript application/x-dvi
[view]
# Pseudo entry used if the 'use desktop' preference is set in the GUI
application/x-all = xdg-open %f
@ -16,9 +22,9 @@ application/x-all = xdg-open %f
application/x-kword = kword %f
application/x-abiword = abiword %f
application/pdf = okular %f
application/postscript = okular %f
application/x-dvi = okular %f
application/pdf = evince --page-index=%p --find=%s %f
application/postscript = evince --page-index=%p --find=%s %f
application/x-dvi = evince --page-index=%p --find=%s %f
application/x-lyx = lyx %f
application/x-scribus = scribus %f

View file

@ -276,7 +276,8 @@ int ConfSimple::set(const std::string &nm, const std::string &value,
{
if (status != STATUS_RW)
return 0;
LOGDEB2(("ConfSimple::set [%s]:[%s] -> [%s]\n", sk.c_str(),
nm.c_str(), value.c_str()));
if (!i_set(nm, value, sk))
return 0;
return write();

View file

@ -408,7 +408,8 @@ public:
{
if (!m_ok)
return 0;
//LOGDEB2(("ConfStack::set [%s]:[%s] -> [%s]\n", sk.c_str(),
//nm.c_str(), val.c_str()));
// Avoid adding unneeded entries: if the new value matches the
// one out from the deeper configs, erase or dont add it
// from/to the topmost file

120
website/release-1.18.html Normal file
View file

@ -0,0 +1,120 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Recoll 1.18 series release notes</title>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta name="Author" content="Jean-Francois Dockes">
<meta name="Description" content=
"recoll is a simple full-text search system for unix and linux
based on the powerful and mature xapian engine">
<meta name="Keywords" content=
"full text search, desktop search, unix, linux">
<meta http-equiv="Content-language" content="en">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="robots" content="All,Index,Follow">
<link type="text/css" rel="stylesheet" href="styles/style.css">
</head>
<body>
<div class="rightlinks">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="download.html">Downloads</a></li>
<li><a href="doc.html">Documentation</a></li>
</ul>
</div>
<div class="content">
<h1>Release notes for Recoll 1.18.x</h1>
<h2>Caveats</h2>
<p><em>Installing over an older version</em>: 1.18 introduces serious
index formats changes, and it will be advisable to reset the
index in most cases. IF the 1.18 index is not configured for
case and diacritics sensitivity, it is mostly compatible with
1.17 indexes though. Case/diacritics sensitivity can be turned
off either by a compile flag or a configuration variable, and
the default is still a stripped index (so, mostly compatible
with 1.17). If you activate case and diacritics sensitivity,
you must reset the index.</p>
<p>Always reset the index if installing over an older version (1.14
and older). The simplest way to do this is to quit all recoll
programs and just delete the index directory (<span
class="literal">rm&nbsp;-rf&nbsp;~/.recoll/xapiandb</span>), then
start recoll or recollindex. <span
class="literal">recollindex&nbsp;-z</span> will do the same in most
cases.</p>
<p>Some new, auxiliary, features do require a full reindex to work:</p>
<ul>
<li>The file size filtering functions (for an index created by
1.16 or older).</li>
<li>The anchored search feature if the index was created by
release 1.15 or older.</li>
</ul>
<h2>Changes</h2>
<p>Recoll 1.18 has some major changes 1.17, the most visible of
which is the ability to consider character case and diacritics
when searching.</p>
<p>Recoll 1.18.0 changes:</p>
<ul>
<li>The index can now be configured for case and diacritics
sensitivity. Raw terms are indexed, and query time expansions
are used when search insensitivity is designed (in a similar
manner to what is used for stemming). See the chapter
manual for details about controlling the feature.</li>
<li>More effort is put in choosing the terms used in
generating the snippets inside the result list.</li>
<li>Capacity to store page breaks and use them when opening a
document.</li>
<li>Capacity to pass a search string to the native app.</li>
<li>New "snippets" window for documents with page numbers, let
the user choose a snippet and open the document at the
appropriate page.</li>
<li>We now use the Xapian "synonyms" mechanism to store all
data about stemming, case, and diacritics expansion (this
replace the previous ad-hoc stemming expansion mechanism).</li>
<li>New script to start/stop recollindex according to mains
power status.</li>
<li>Add &lt;pre style="white-space: pre-wrap"&gt; to plain
text HTML display options.</li>
<li>Allow multiple directory specifications in the query
language, as in: <i>dir:/home/me -dir:tmp</i></li>
<li>Improved search in the preview window, allows selecting
one of the initial search clauses from a list.</li>
<li>Fixed bugs:
<ul>
<li>The unac_except_trans mechanism could be buggy in some
cases and generate wrong character translations.</li>
<li>Don't terminate monitor for permissions-related
addwatch error.</li>
<li>Fix handling of ODF documents exported by Google
docs.</li>
</ul>
</li>
</ul>
</div>
</body>
</html>