1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-22 00:28:27 +02:00

Moved section directory delete code to Menu class

It is better to have all the file handling code for menu entry files
in the same place.
This commit is contained in:
Maarten ter Huurne 2015-04-25 23:46:28 +02:00
parent c2759f1263
commit f17fae79b6
2 changed files with 14 additions and 10 deletions

View File

@ -1026,11 +1026,6 @@ void GMenu2X::addSection() {
void GMenu2X::deleteSection()
{
string path = getHome() + "/sections/" + menu->selSection();
if (rmdir(path.c_str()) && errno != ENOENT) {
WARNING("Removal of section dir \"%s\" failed: %s\n",
path.c_str(), strerror(errno));
}
menu->deleteSelectedSection();
}

View File

@ -500,13 +500,22 @@ void Menu::deleteSelectedLink()
}
}
void Menu::deleteSelectedSection() {
INFO("Deleting section '%s'\n", selSection().c_str());
void Menu::deleteSelectedSection()
{
string const& sectionName = selSection();
INFO("Deleting section '%s'\n", sectionName.c_str());
gmenu2x.sc.del("sections/"+selSection()+".png");
links.erase( links.begin()+selSectionIndex() );
sections.erase( sections.begin()+selSectionIndex() );
gmenu2x.sc.del("sections/" + sectionName + ".png");
auto idx = selSectionIndex();
links.erase(links.begin() + idx);
sections.erase(sections.begin() + idx);
setSectionIndex(0); //reload sections
string path = GMenu2X::getHome() + "/sections/" + sectionName;
if (rmdir(path.c_str()) && errno != ENOENT) {
WARNING("Removal of section dir \"%s\" failed: %s\n",
path.c_str(), strerror(errno));
}
}
bool Menu::linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex) {