GUI: result table: when displaying content in the detail area, if the doc is a free-standing image, display it

This commit is contained in:
Jean-Francois Dockes
2021-07-04 17:19:38 +02:00
parent ae8fd0902a
commit e6055681d4
5 changed files with 147 additions and 131 deletions
+5 -63
View File
@@ -14,7 +14,7 @@
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef TEST_APPFORMIME
#include <conftree.h>
#include <fstreewalk.h>
@@ -33,9 +33,7 @@ static DesktopDb *theDb;
class FstCb : public FsTreeWalkerCB {
public:
FstCb(DesktopDb::AppMap *appdefs)
: m_appdefs(appdefs)
{
}
: m_appdefs(appdefs) {}
virtual FsTreeWalker::Status
processone(const string &, const struct PathStat *, FsTreeWalker::CbFlag);
DesktopDb::AppMap *m_appdefs;
@@ -173,64 +171,8 @@ const string& DesktopDb::getReason()
return m_reason;
}
#else // TEST_APPFORMIME
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <string>
#include <iostream>
#include <vector>
using namespace std;
#include "appformime.h"
static char *thisprog;
static char usage [] =
" appformime <mime type>\n\n"
;
static void
Usage(void)
bool mimeIsImage(const std::string& tp)
{
fprintf(stderr, "%s: usage:\n%s", thisprog, usage);
exit(1);
return !tp.compare(0, 6, "image/") &&
tp.compare("image/vnd.djvu") && tp.compare("image/svg+xml");
}
int main(int argc, char **argv)
{
thisprog = argv[0];
argc--; argv++;
if (argc != 1)
Usage();
string mime = *argv++;argc--;
string reason;
vector<DesktopDb::AppDef> appdefs;
DesktopDb *ddb = DesktopDb::getDb();
if (ddb == 0) {
cerr << "Could not create desktop db\n";
exit(1);
}
if (!ddb->appForMime(mime, &appdefs, &reason)) {
cerr << "appForMime failed: " << reason << endl;
exit(1);
}
if (appdefs.empty()) {
cerr << "No application found for [" << mime << "]" << endl;
exit(1);
}
cout << mime << " -> ";
for (vector<DesktopDb::AppDef>::const_iterator it = appdefs.begin();
it != appdefs.end(); it++) {
cout << "[" << it->name << ", " << it->command << "], ";
}
cout << endl;
exit(0);
}
#endif //TEST_APPFORMIME
+3
View File
@@ -88,4 +88,7 @@ private:
};
/** Helper function: is MIME type a simple image ? */
bool mimeIsImage(const std::string& tp);
#endif /* _APPFORMIME_H_INCLUDED_ */