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:
parent
c2759f1263
commit
f17fae79b6
@ -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();
|
||||
}
|
||||
|
||||
|
19
src/menu.cpp
19
src/menu.cpp
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user