1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-26 08:11:53 +02:00

Load the OPK in the section defined by their "Categories" parameter

This commit is contained in:
Paul Cercueil 2012-10-09 01:41:57 +02:00
parent c58c726954
commit 4a60aa000d
3 changed files with 23 additions and 4 deletions

View File

@ -88,9 +88,20 @@ LinkApp::LinkApp(GMenu2X *gmenu2x_, Touchscreen &ts, InputManager &inputMgr_,
pos = opkMount.rfind('.'); pos = opkMount.rfind('.');
opkMount = opkMount.substr(0, pos); opkMount = opkMount.substr(0, pos);
file = gmenu2x->getHome() + "/sections/" + opkMount; file = gmenu2x->getHome() + "/sections/";
opkMount = (string) "/mnt/" + opkMount + '/'; opkMount = (string) "/mnt/" + opkMount + '/';
param = opk_read_param(pdata, "Categories");
if (!param)
ERROR("Missing \"Categories\" parameter\n");
else {
category = param;
pos = category.find(';');
if (pos != category.npos)
category = category.substr(0, pos);
file += category + '/' + opkMount;
}
param = opk_read_param(pdata, "Name"); param = opk_read_param(pdata, "Name");
if (!param) if (!param)
ERROR("Missing \"Name\" parameter\n"); ERROR("Missing \"Name\" parameter\n");

View File

@ -49,7 +49,7 @@ private:
bool dontleave; bool dontleave;
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
bool isOPK; bool isOPK;
std::string opkMount, opkFile; std::string opkMount, opkFile, category;
#endif #endif
void start(); void start();
@ -59,6 +59,8 @@ private:
public: public:
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
const std::string &getCategory() { return category; }
LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr, LinkApp(GMenu2X *gmenu2x, Touchscreen &ts, InputManager &inputMgr,
const char* linkfile, bool opk = false); const char* linkfile, bool opk = false);
#else #else

View File

@ -448,6 +448,7 @@ void Menu::readPackages(std::string parentDir)
char *c; char *c;
LinkApp *link; LinkApp *link;
std::string path; std::string path;
unsigned int i;
if (dptr->d_type != DT_REG) if (dptr->d_type != DT_REG)
continue; continue;
@ -463,8 +464,13 @@ void Menu::readPackages(std::string parentDir)
link = new LinkApp(gmenu2x, ts, gmenu2x->input, path.c_str(), true); link = new LinkApp(gmenu2x, ts, gmenu2x->input, path.c_str(), true);
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]); link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
/* TODO: Read the category from the OPK. */ addSection(link->getCategory());
links[0].push_back(link); for (i = 0; i < sections.size(); i++) {
if (sections[i] == link->getCategory()) {
links[i].push_back(link);
break;
}
}
} }
closedir(dirp); closedir(dirp);