1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-29 19:09:43 +02:00

Add function openPackagesFromDir() to simplify constructor of Menu

This commit is contained in:
Paul Cercueil 2013-07-19 12:01:25 -04:00
parent 36c4205e0e
commit 69b9657af4
2 changed files with 15 additions and 8 deletions

View File

@ -66,14 +66,8 @@ Menu::Menu(GMenu2X *gmenu2x, Touchscreen &ts)
if (!strcmp(dptr->d_name, ".") || !strcmp(dptr->d_name, "..")) if (!strcmp(dptr->d_name, ".") || !strcmp(dptr->d_name, ".."))
continue; continue;
string path = (string) CARD_ROOT + "/" + dptr->d_name + "/apps"; openPackagesFromDir((string) CARD_ROOT + "/" +
if (access(path.c_str(), F_OK)) dptr->d_name + "/apps");
continue;
readPackages(path);
#ifdef ENABLE_INOTIFY
monitors.push_back(new Monitor(path.c_str()));
#endif
} }
closedir(dirp); closedir(dirp);
} }
@ -452,6 +446,18 @@ void Menu::setLinkIndex(int i) {
} }
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
void Menu::openPackagesFromDir(std::string path)
{
if (access(path.c_str(), F_OK))
return;
DEBUG("Opening packages from directory: %s\n", path.c_str());
readPackages(path);
#ifdef ENABLE_INOTIFY
monitors.push_back(new Monitor(path.c_str()));
#endif
}
void Menu::openPackage(std::string path) void Menu::openPackage(std::string path)
{ {
/* First try to remove existing links of the same OPK /* First try to remove existing links of the same OPK

View File

@ -68,6 +68,7 @@ public:
#ifdef HAVE_LIBOPK #ifdef HAVE_LIBOPK
void openPackage(std::string path); void openPackage(std::string path);
void openPackagesFromDir(std::string path);
#ifdef ENABLE_INOTIFY #ifdef ENABLE_INOTIFY
void removePackageLink(std::string path); void removePackageLink(std::string path);
#endif #endif