mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-26 14:59:42 +02:00
During init, load all packages in CARD_ROOT/*/apps
This commit is contained in:
parent
61d22e26e6
commit
cd4809343b
53
src/menu.cpp
53
src/menu.cpp
@ -48,6 +48,21 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
|
|||||||
sort(sections.begin(),sections.end(),case_less());
|
sort(sections.begin(),sections.end(),case_less());
|
||||||
setSectionIndex(0);
|
setSectionIndex(0);
|
||||||
readLinks();
|
readLinks();
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
{
|
||||||
|
struct dirent *dptr;
|
||||||
|
DIR *dirp = opendir(CARD_ROOT);
|
||||||
|
if (dirp) {
|
||||||
|
while ((dptr = readdir(dirp))) {
|
||||||
|
if (dptr->d_type != DT_DIR)
|
||||||
|
continue;
|
||||||
|
readPackages((string) CARD_ROOT + dptr->d_name + "/apps");
|
||||||
|
}
|
||||||
|
closedir(dirp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu::~Menu() {
|
Menu::~Menu() {
|
||||||
@ -418,6 +433,44 @@ void Menu::setLinkIndex(int i) {
|
|||||||
iLink = i;
|
iLink = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
void Menu::readPackages(std::string parentDir)
|
||||||
|
{
|
||||||
|
DIR *dirp;
|
||||||
|
struct dirent *dptr;
|
||||||
|
vector<string> linkfiles;
|
||||||
|
|
||||||
|
dirp = opendir(parentDir.c_str());
|
||||||
|
if (!dirp)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while ((dptr = readdir(dirp))) {
|
||||||
|
char *c;
|
||||||
|
LinkApp *link;
|
||||||
|
std::string path;
|
||||||
|
|
||||||
|
if (dptr->d_type != DT_REG)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
c = strrchr(dptr->d_name, '.');
|
||||||
|
if (!c) /* File without extension */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (strcasecmp(c + 1, "opk"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
path = parentDir + '/' + dptr->d_name;
|
||||||
|
link = new LinkApp(gmenu2x, ts, gmenu2x->input, path.c_str(), true);
|
||||||
|
link->setSize(gmenu2x->skinConfInt["linkWidth"], gmenu2x->skinConfInt["linkHeight"]);
|
||||||
|
|
||||||
|
/* TODO: Read the category from the OPK. */
|
||||||
|
links[0].push_back(link);
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dirp);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void Menu::readLinksOfSection(std::string path, std::vector<std::string> &linkfiles)
|
void Menu::readLinksOfSection(std::string path, std::vector<std::string> &linkfiles)
|
||||||
{
|
{
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
|
@ -49,6 +49,11 @@ private:
|
|||||||
// Load all the sections of the given "sections" directory.
|
// Load all the sections of the given "sections" directory.
|
||||||
void readSections(std::string parentDir);
|
void readSections(std::string parentDir);
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBOPK
|
||||||
|
// Load all the .opk packages of the given directory
|
||||||
|
void readPackages(std::string parentDir);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Load all the links on the given section directory.
|
// Load all the links on the given section directory.
|
||||||
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);
|
void readLinksOfSection(std::string path, std::vector<std::string> &linkfiles);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user