mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-25 15:56:15 +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:
parent
c2759f1263
commit
f17fae79b6
@ -1026,11 +1026,6 @@ void GMenu2X::addSection() {
|
|||||||
|
|
||||||
void GMenu2X::deleteSection()
|
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();
|
menu->deleteSelectedSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
src/menu.cpp
19
src/menu.cpp
@ -500,13 +500,22 @@ void Menu::deleteSelectedLink()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Menu::deleteSelectedSection() {
|
void Menu::deleteSelectedSection()
|
||||||
INFO("Deleting section '%s'\n", selSection().c_str());
|
{
|
||||||
|
string const& sectionName = selSection();
|
||||||
|
INFO("Deleting section '%s'\n", sectionName.c_str());
|
||||||
|
|
||||||
gmenu2x.sc.del("sections/"+selSection()+".png");
|
gmenu2x.sc.del("sections/" + sectionName + ".png");
|
||||||
links.erase( links.begin()+selSectionIndex() );
|
auto idx = selSectionIndex();
|
||||||
sections.erase( sections.begin()+selSectionIndex() );
|
links.erase(links.begin() + idx);
|
||||||
|
sections.erase(sections.begin() + idx);
|
||||||
setSectionIndex(0); //reload sections
|
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) {
|
bool Menu::linkChangeSection(uint linkIndex, uint oldSectionIndex, uint newSectionIndex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user