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:
+44
-22
@@ -175,7 +175,9 @@ RclConfig::RclConfig(const string *argcnf)
|
||||
m_reason = string("No/bad mimeconf in: ") + cnferrloc;
|
||||
return;
|
||||
}
|
||||
mimeview = new ConfStack<ConfSimple>("mimeview", m_cdirs, true);
|
||||
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;
|
||||
return;
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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/∗.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
|
||||
|
||||
+7
-10
@@ -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 apptag;
|
||||
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
|
||||
string cmdplusattr = theconfig->getMimeViewerDef(doc.mimetype, apptag,
|
||||
prefs.useDesktopOpen);
|
||||
|
||||
if (cmdplusattr.empty()) {
|
||||
QMessageBox::warning(0, "Recoll",
|
||||
|
||||
@@ -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()));
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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>";
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -246,7 +246,7 @@ int ConfSimple::get(const string &nm, string &value, const string &sk) const
|
||||
// Appropriately output a subkey (nm=="") or variable line.
|
||||
// Splits long lines
|
||||
static ConfSimple::WalkerCode varprinter(void *f, const string &nm,
|
||||
const string &value)
|
||||
const string &value)
|
||||
{
|
||||
ostream *output = (ostream *)f;
|
||||
if (nm.empty()) {
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user