mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 18:05:20 +02:00
Add support for reading manuals located inside OPK archives
This commit is contained in:
parent
8d96f3c261
commit
77046f3553
@ -1011,7 +1011,7 @@ void GMenu2X::contextMenu() {
|
||||
|
||||
{
|
||||
LinkApp* app = menu->selLinkApp();
|
||||
if (app && fileExists(app->getManual())) {
|
||||
if (app && !app->getManual().empty()) {
|
||||
MenuOption opt = {tr.translate("Show manual of $1",menu->selLink()->getTitle().c_str(),NULL),
|
||||
MakeDelegate(this, &GMenu2X::showManual),
|
||||
};
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <signal.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
@ -381,7 +382,49 @@ void LinkApp::start() {
|
||||
}
|
||||
|
||||
void LinkApp::showManual() {
|
||||
if (manual=="" || !fileExists(manual)) return;
|
||||
if (manual.empty())
|
||||
return;
|
||||
|
||||
#ifdef HAVE_LIBOPK
|
||||
if (isOPK) {
|
||||
vector<string> readme;
|
||||
char *token, *buf, *ptr;
|
||||
struct ParserData *pdata;
|
||||
|
||||
pdata = opk_open(opkFile.c_str());
|
||||
if (!pdata) {
|
||||
WARNING("Unable to open OPK to read manual\n");
|
||||
return;
|
||||
}
|
||||
|
||||
buf = ptr = opk_extract_file(pdata, manual.c_str());
|
||||
opk_close(pdata);
|
||||
|
||||
if (!buf) {
|
||||
WARNING("Unable to read manual from OPK\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while((token = strchr(ptr, '\n'))) {
|
||||
*token = '\0';
|
||||
|
||||
string str(ptr);
|
||||
readme.push_back(str);
|
||||
ptr = token + 1;
|
||||
}
|
||||
|
||||
/* Add the last line */
|
||||
string str(ptr);
|
||||
readme.push_back(str);
|
||||
free(buf);
|
||||
|
||||
TextDialog td(gmenu2x, getTitle(), "ReadMe", getIconPath(), &readme);
|
||||
td.exec();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (!fileExists(manual))
|
||||
return;
|
||||
|
||||
// Png manuals
|
||||
string ext8 = manual.substr(manual.size()-8,8);
|
||||
|
Loading…
Reference in New Issue
Block a user