From b42df0c26025613f41d60349ee973f52b55241b9 Mon Sep 17 00:00:00 2001 From: dockes Date: Wed, 29 Mar 2006 13:08:08 +0000 Subject: [PATCH] result list: show preview and edit links only when they can be used --- src/VERSION | 2 +- src/common/Makefile | 10 ++++++++- src/common/rclconfig.cpp | 39 +++++++++++++++++++++++++++++++++- src/common/rclconfig.h | 7 ++++-- src/internfile/mimehandler.cpp | 14 +++++++++++- src/internfile/mimehandler.h | 5 ++++- src/qtgui/rclreslist.cpp | 20 +++++++++++------ src/sampleconf/mimeconf | 4 +++- src/sampleconf/mimemap | 9 +++++--- 9 files changed, 93 insertions(+), 17 deletions(-) diff --git a/src/VERSION b/src/VERSION index 3a3cd8cc..2b47ded1 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -1.3.1 +1.3.1pre2 diff --git a/src/common/Makefile b/src/common/Makefile index 866dd828..45d22843 100644 --- a/src/common/Makefile +++ b/src/common/Makefile @@ -1,4 +1,4 @@ -# @(#$Id: Makefile,v 1.9 2006-01-19 12:01:42 dockes Exp $ (C) 2005 J.F.Dockes +# @(#$Id: Makefile,v 1.10 2006-03-29 13:08:08 dockes Exp $ (C) 2005 J.F.Dockes depth = .. include $(depth)/mk/sysconf @@ -32,6 +32,14 @@ trinternfile.o : internfile.cpp $(CXX) $(ALL_CXXFLAGS) -DTEST_INTERNFILE -c -o trinternfile.o \ internfile.cpp +RCLCONFIG_OBJS= trrclconfig.o $(BIGLIB) $(MIMELIB) +rclconfig : $(RCLCONFIG_OBJS) + $(CXX) $(ALL_CXXFLAGS) -o rclconfig $(RCLCONFIG_OBJS) \ + $(LIBICONV) $(LIBSYS) +trrclconfig.o : rclconfig.cpp + $(CXX) $(ALL_CXXFLAGS) -DTEST_RCLCONFIG -c -o trrclconfig.o \ + rclconfig.cpp + clean: rm -f *.o $(PROGS) diff --git a/src/common/rclconfig.cpp b/src/common/rclconfig.cpp index f19cf3b1..bf558022 100644 --- a/src/common/rclconfig.cpp +++ b/src/common/rclconfig.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.25 2006-03-29 11:18:14 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.26 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -17,6 +17,7 @@ static char rcsid[] = "@(#$Id: rclconfig.cpp,v 1.25 2006-03-29 11:18:14 dockes E * Free Software Foundation, Inc., * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifndef TEST_RCLCONFIG #include #include #include @@ -384,3 +385,39 @@ void RclConfig::initFrom(const RclConfig& r) defcharset = r.defcharset; guesscharset = r.guesscharset; } + +#else // -> Test + +#include +#include +#include + +#include +#include +#include + +using namespace std; + +#include "debuglog.h" +#include "rclinit.h" +#include "rclconfig.h" + +int main(int, const char **) +{ + string reason; + RclConfig *config = recollinit(0, 0, reason); + if (config == 0 || !config->ok()) { + cerr << "Configuration problem: " << reason << endl; + exit(1); + } + list names = config->getConfNames(""); + names.sort(); + names.unique(); + for (list::iterator it = names.begin(); it != names.end();it++) { + string value; + config->getConfParam(*it, value); + cout << *it << " -> [" << value << "]" << endl; + } +} + +#endif // TEST_RCLCONFIG diff --git a/src/common/rclconfig.h b/src/common/rclconfig.h index 2952023e..2b75cd5a 100644 --- a/src/common/rclconfig.h +++ b/src/common/rclconfig.h @@ -16,7 +16,7 @@ */ #ifndef _RCLCONFIG_H_INCLUDED_ #define _RCLCONFIG_H_INCLUDED_ -/* @(#$Id: rclconfig.h,v 1.18 2006-03-29 11:18:14 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: rclconfig.h,v 1.19 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes */ #include @@ -110,7 +110,10 @@ class RclConfig { } return *this; } - + std::list getConfNames(const string &sk) { + return m_conf->getNames(sk); + } + private: int m_ok; string m_reason; // Explanation for bad state diff --git a/src/internfile/mimehandler.cpp b/src/internfile/mimehandler.cpp index e17a1798..081c84e1 100644 --- a/src/internfile/mimehandler.cpp +++ b/src/internfile/mimehandler.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.17 2006-03-20 16:05:41 dockes Exp $ (C) 2004 J.F.Dockes"; +static char rcsid[] = "@(#$Id: mimehandler.cpp,v 1.18 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes"; #endif /* * This program is free software; you can redistribute it and/or modify @@ -98,3 +98,15 @@ MimeHandler *getMimeHandler(const string &mtype, RclConfig *cfg) return 0; } } + + +/// Can this mime type be interned (according to config) ? +bool canIntern(const std::string mtype, RclConfig *cfg) +{ + if (mtype.empty()) + return false; + string hs = cfg->getMimeHandlerDef(mtype); + if (hs.empty()) + return false; + return true; +} diff --git a/src/internfile/mimehandler.h b/src/internfile/mimehandler.h index 6024f8e0..032cd9f1 100644 --- a/src/internfile/mimehandler.h +++ b/src/internfile/mimehandler.h @@ -16,7 +16,7 @@ */ #ifndef _MIMEHANDLER_H_INCLUDED_ #define _MIMEHANDLER_H_INCLUDED_ -/* @(#$Id: mimehandler.h,v 1.11 2006-01-30 11:15:27 dockes Exp $ (C) 2004 J.F.Dockes */ +/* @(#$Id: mimehandler.h,v 1.12 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes */ #include #include @@ -71,4 +71,7 @@ class MimeHandler { */ extern MimeHandler *getMimeHandler(const std::string &mtyp, RclConfig *cfg); +/// Can this mime type be interned ? +extern bool canIntern(const std::string mimetype, RclConfig *cfg); + #endif /* _MIMEHANDLER_H_INCLUDED_ */ diff --git a/src/qtgui/rclreslist.cpp b/src/qtgui/rclreslist.cpp index 690087fe..671ed914 100644 --- a/src/qtgui/rclreslist.cpp +++ b/src/qtgui/rclreslist.cpp @@ -1,5 +1,5 @@ #ifndef lint -static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.6 2006-03-29 11:18:14 dockes Exp $ (C) 2005 J.F.Dockes"; +static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.7 2006-03-29 13:08:08 dockes Exp $ (C) 2005 J.F.Dockes"; #endif #include @@ -21,6 +21,7 @@ static char rcsid[] = "@(#$Id: rclreslist.cpp,v 1.6 2006-03-29 11:18:14 dockes E #include "docseq.h" #include "transcode.h" #include "pathut.h" +#include "mimehandler.h" #include "rclreslist.h" #include "moc_rclreslist.cpp" @@ -316,12 +317,19 @@ void RclResList::showResultPage() result += string(perbuf) + sizebuf + "" + doc.title + "
"; result += doc.mimetype + " "; result += string(datebuf) + "   "; + + + // Set up the preview and edit links char vlbuf[100]; - sprintf(vlbuf, "\"P%d\"", m_winfirst+i); - result += string("" + "Preview" + "" - + "  "; - sprintf(vlbuf, "E%d", m_winfirst+i); - result += string("" + "Edit" + ""; + if (canIntern(doc.mimetype, rclconfig)) { + sprintf(vlbuf, "\"P%d\"", m_winfirst+i); + result += string("" + "Preview" + "" + + "  "; + } + if (!rclconfig->getMimeViewerDef(doc.mimetype).empty()) { + sprintf(vlbuf, "E%d", m_winfirst+i); + result += string("" + "Edit" + ""; + } result += string("
"); if (!img_name.empty()) { diff --git a/src/sampleconf/mimeconf b/src/sampleconf/mimeconf index a1214598..5ef8cd10 100644 --- a/src/sampleconf/mimeconf +++ b/src/sampleconf/mimeconf @@ -1,4 +1,4 @@ -# @(#$Id: mimeconf,v 1.14 2006-03-28 09:38:12 dockes Exp $ (C) 2004 J.F.Dockes +# @(#$Id: mimeconf,v 1.15 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes # Recoll : associations of mime types to processing filters. # There are different sections for decompression, 'interning' for indexing @@ -75,6 +75,8 @@ image/vnd.djvu = djview %f application/x-dvi = xdvi %f audio/mpeg = xmms %f +image/png = xv %f +image/jpeg = xv %f # Icons to be used in the result list. [icons] diff --git a/src/sampleconf/mimemap b/src/sampleconf/mimemap index 4a4230c0..ee20a284 100644 --- a/src/sampleconf/mimemap +++ b/src/sampleconf/mimemap @@ -1,4 +1,4 @@ -# @(#$Id: mimemap,v 1.13 2006-03-28 09:38:13 dockes Exp $ (C) 2004 J.F.Dockes +# @(#$Id: mimemap,v 1.14 2006-03-29 13:08:08 dockes Exp $ (C) 2004 J.F.Dockes # Recoll: associations of file name extensions to mime types .txt = text/plain @@ -50,16 +50,19 @@ .rtf = text/rtf .mp3 = audio/mpeg +.png = image/png +.jpg = image/jpeg # A list of stuff that we don't want to touch at all (for now). Having the # suffixes listed in there speeds up things quite a lot by avoiding -# unneeded decompression or 'file' calls +# unneeded decompression or 'file' calls. File names still get indexed if +# indexallfilenames is set recoll_noindex = .tar.gz .tgz .tar.bz2 .tbz .log.gz .md5 .map \ .c .h .cpp .m4 .tcl .js .sh .pl .awk .php .php3 \ .o .lib .dll .a \ .dat .bak .rdf .log .db .ini .msf \ .gnm .gnumeric .tex \ - .jpg .gif .bmp .xpm .png \ + .gif .bmp .xpm \ ,v ~ # [~/.gaim]