mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-11-24 12:54:59 +02:00
Only allow empty sections to be deleted
Since not all links can be deleted, an action that deletes a section and all the links it contains cannot be reliably implemented. Therefore, the action will only be offered if all links have already been deleted (or were never added in the first place).
This commit is contained in:
parent
aeb9c12f5d
commit
c2759f1263
@ -95,7 +95,6 @@ Insert a name for the new section=Sekzio berrirako izena sartu
|
|||||||
Insert a new name for this section=Sekzio honetarako izen berria sartu
|
Insert a new name for this section=Sekzio honetarako izen berria sartu
|
||||||
Yes=Bai
|
Yes=Bai
|
||||||
No=Ez
|
No=Ez
|
||||||
You will lose all the links in this section.=Sekzio honetako esteka guztiak galduko dira
|
|
||||||
Exit=Irten
|
Exit=Irten
|
||||||
Link Scanner=Esteka bilatzailea
|
Link Scanner=Esteka bilatzailea
|
||||||
Scanning SD filesystem...=SD txartela arakatzen...
|
Scanning SD filesystem...=SD txartela arakatzen...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Introduir nom per a la nova secció
|
|||||||
Insert a new name for this section=Introduir nou nom per a la secció
|
Insert a new name for this section=Introduir nou nom per a la secció
|
||||||
Yes=Si
|
Yes=Si
|
||||||
No=No
|
No=No
|
||||||
You will lose all the links in this section.=Es perdran tots els enllaços d'aquesta secció.
|
|
||||||
Exit=Sortir
|
Exit=Sortir
|
||||||
Link Scanner=Buscador d'enllaços
|
Link Scanner=Buscador d'enllaços
|
||||||
Scanning SD filesystem...=Explorant el sistema de fitxers de la SD...
|
Scanning SD filesystem...=Explorant el sistema de fitxers de la SD...
|
||||||
|
@ -100,7 +100,6 @@ Insert a name for the new section=Angiv navn for den nye sektion
|
|||||||
Insert a new name for this section=Angiv nyt navn for denne sektion
|
Insert a new name for this section=Angiv nyt navn for denne sektion
|
||||||
Yes=Ja
|
Yes=Ja
|
||||||
No=Nej
|
No=Nej
|
||||||
You will lose all the links in this section.=Du vil miste alle genveje i denne sektion.
|
|
||||||
Exit=Afslut
|
Exit=Afslut
|
||||||
Link Scanner=Skan genveje
|
Link Scanner=Skan genveje
|
||||||
Scanning SD filesystem...=Skanner SD filsystem...
|
Scanning SD filesystem...=Skanner SD filsystem...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Geef een naam voor de nieuwe groep
|
|||||||
Insert a new name for this section=Geef een nieuwe naam voor deze groep
|
Insert a new name for this section=Geef een nieuwe naam voor deze groep
|
||||||
Yes=Ja
|
Yes=Ja
|
||||||
No=Nee
|
No=Nee
|
||||||
You will lose all the links in this section.=Alle snelkoppelingen in deze groep worden gewist.
|
|
||||||
Exit=Verlaat
|
Exit=Verlaat
|
||||||
Link Scanner=Snelkoppeling-Scanner
|
Link Scanner=Snelkoppeling-Scanner
|
||||||
Scanning SD filesystem...=Scant het SD-bestandssysteem...
|
Scanning SD filesystem...=Scant het SD-bestandssysteem...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Anna uuden v<>lilehden nimi
|
|||||||
Insert a new name for this section=Anna uusi nimi t<>lle v<>lilehdelle
|
Insert a new name for this section=Anna uusi nimi t<>lle v<>lilehdelle
|
||||||
Yes=Kyll<6C>
|
Yes=Kyll<6C>
|
||||||
No=Ei
|
No=Ei
|
||||||
You will lose all the links in this section.=Menet<65>t kaikki t<>ss<73> v<>lilehdess<73> olevat linkit.
|
|
||||||
Exit=Poistu
|
Exit=Poistu
|
||||||
Link Scanner=Linkkiskanneri
|
Link Scanner=Linkkiskanneri
|
||||||
Scanning SD filesystem...=Skannataan SD-tiedostoj<6F>rjestelm<6C><6D>...
|
Scanning SD filesystem...=Skannataan SD-tiedostoj<6F>rjestelm<6C><6D>...
|
||||||
|
@ -69,7 +69,6 @@ Insert a name for the new section=Saisir un nom pour cette nouvelle section
|
|||||||
Insert a new name for this section=Saisir un nouveau nom pour cette section
|
Insert a new name for this section=Saisir un nouveau nom pour cette section
|
||||||
Yes=Oui
|
Yes=Oui
|
||||||
No=Non
|
No=Non
|
||||||
You will lose all the links in this section.=Vous perdrez tous les liens dans cette section.
|
|
||||||
Exit=Quitter
|
Exit=Quitter
|
||||||
Log Viewer=Journal
|
Log Viewer=Journal
|
||||||
Displays last launched program's output=Afficher la sortie du dernier programme lancé
|
Displays last launched program's output=Afficher la sortie du dernier programme lancé
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Name für die neue Sektion
|
|||||||
Insert a new name for this section=Neuer Name für diese Sektion
|
Insert a new name for this section=Neuer Name für diese Sektion
|
||||||
Yes=Ja
|
Yes=Ja
|
||||||
No=Nein
|
No=Nein
|
||||||
You will lose all the links in this section.=Alle Links in dieser Sektion gehen verloren.
|
|
||||||
Exit=Beenden
|
Exit=Beenden
|
||||||
Link Scanner=Links suchen
|
Link Scanner=Links suchen
|
||||||
Scanning SD filesystem...=SD-Karte wird durchsucht...
|
Scanning SD filesystem...=SD-Karte wird durchsucht...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Inserisci un nome per la nuova sezione
|
|||||||
Insert a new name for this section=Inserisci un nuovo nome per questa sezione
|
Insert a new name for this section=Inserisci un nuovo nome per questa sezione
|
||||||
Yes=Si
|
Yes=Si
|
||||||
No=No
|
No=No
|
||||||
You will lose all the links in this section.=Perderai tutti i collegamenti in questa sezione.
|
|
||||||
Exit=Esci
|
Exit=Esci
|
||||||
Link Scanner=Scanner di collegamenti
|
Link Scanner=Scanner di collegamenti
|
||||||
Scanning SD filesystem...=Scansione del filesystem della SD...
|
Scanning SD filesystem...=Scansione del filesystem della SD...
|
||||||
|
@ -69,7 +69,6 @@ Insert a name for the new section=Sett inn navn på den nye katalogen
|
|||||||
Insert a new name for this section=Sett inn et nytt navn for denne katalogen
|
Insert a new name for this section=Sett inn et nytt navn for denne katalogen
|
||||||
Yes=Ja
|
Yes=Ja
|
||||||
No=Nei
|
No=Nei
|
||||||
You will lose all the links in this section.=Du vil miste alle linker i denne katalogen
|
|
||||||
Exit=Utgang
|
Exit=Utgang
|
||||||
Log Viewer=Logg leser
|
Log Viewer=Logg leser
|
||||||
Displays last launched program's output=Viser det siste lanserte programmets utgang
|
Displays last launched program's output=Viser det siste lanserte programmets utgang
|
||||||
|
@ -69,7 +69,6 @@ Insert a name for the new section=Wstaw nazwę dla nowej sekcji
|
|||||||
Insert a new name for this section=Wstaw nową nazwę dla tej sekcji
|
Insert a new name for this section=Wstaw nową nazwę dla tej sekcji
|
||||||
Yes=Tak
|
Yes=Tak
|
||||||
No=Nie
|
No=Nie
|
||||||
You will lose all the links in this section.=Wszystkie odnośniki w tej sekcji zostaną utracone.
|
|
||||||
Exit=Wyjdź
|
Exit=Wyjdź
|
||||||
Log Viewer=Dziennik zdarzeń
|
Log Viewer=Dziennik zdarzeń
|
||||||
Displays last launched program's output=Wyświetla wyjście ostatnio uruchamianego programu
|
Displays last launched program's output=Wyświetla wyjście ostatnio uruchamianego programu
|
||||||
|
@ -70,7 +70,6 @@ Insert a name for the new section=Insira um nome para a nova seção
|
|||||||
Insert a new name for this section=Insira um novo nome para esta seção
|
Insert a new name for this section=Insira um novo nome para esta seção
|
||||||
Yes=Sim
|
Yes=Sim
|
||||||
No=Não
|
No=Não
|
||||||
You will lose all the links in this section.=Você perderá todos os atalho desta seção.
|
|
||||||
Exit=Sair
|
Exit=Sair
|
||||||
Log Viewer=Visualizador de Logs
|
Log Viewer=Visualizador de Logs
|
||||||
Displays last launched program's output=Mostrar a saída do último programa executado
|
Displays last launched program's output=Mostrar a saída do último programa executado
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Insira o nome da nova secção
|
|||||||
Insert a new name for this section=Insira um novo nome para esta secção
|
Insert a new name for this section=Insira um novo nome para esta secção
|
||||||
Yes=Sim
|
Yes=Sim
|
||||||
No=Não
|
No=Não
|
||||||
You will lose all the links in this section.=Perderá todos os links desta secção.
|
|
||||||
Exit=Sair
|
Exit=Sair
|
||||||
Link Scanner=Pesquisador de links
|
Link Scanner=Pesquisador de links
|
||||||
Scanning SD filesystem...=A pesquisar o filesystem do SD...
|
Scanning SD filesystem...=A pesquisar o filesystem do SD...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Впишите имя для новой сек
|
|||||||
Insert a new name for this section=Впишите новое имя для этой секции
|
Insert a new name for this section=Впишите новое имя для этой секции
|
||||||
Yes=Да
|
Yes=Да
|
||||||
No=Нет
|
No=Нет
|
||||||
You will lose all the links in this section.=Вы потеряете все ссылки в этой секции
|
|
||||||
Exit=Выход
|
Exit=Выход
|
||||||
Link Scanner=Поиск ссылок
|
Link Scanner=Поиск ссылок
|
||||||
Scanning SD filesystem...=Сканирование SD...
|
Scanning SD filesystem...=Сканирование SD...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Zadajte názov novej sekcie
|
|||||||
Insert a new name for this section=Zadajte nový názov pre túto sekciu
|
Insert a new name for this section=Zadajte nový názov pre túto sekciu
|
||||||
Yes=Áno
|
Yes=Áno
|
||||||
No=Nie
|
No=Nie
|
||||||
You will lose all the links in this section.=Stratíte všetky odkazy v tejto sekcii.
|
|
||||||
Exit=Ukončiť
|
Exit=Ukončiť
|
||||||
Link Scanner=Vyhľadávač odkazov
|
Link Scanner=Vyhľadávač odkazov
|
||||||
Scanning SD filesystem...=Prehľadávam súborový systém na SD karte...
|
Scanning SD filesystem...=Prehľadávam súborový systém na SD karte...
|
||||||
|
@ -95,7 +95,6 @@ Insert a name for the new section=Insertar nombre para la nueva sección
|
|||||||
Insert a new name for this section=Insertar nuevo nombre para la sección
|
Insert a new name for this section=Insertar nuevo nombre para la sección
|
||||||
Yes=Si
|
Yes=Si
|
||||||
No=No
|
No=No
|
||||||
You will lose all the links in this section.=Se perderán todos los enlaces de esta sección.
|
|
||||||
Exit=Salir
|
Exit=Salir
|
||||||
Link Scanner=Buscador de enlaces
|
Link Scanner=Buscador de enlaces
|
||||||
Scanning SD filesystem...=Explorando sistema de archivos de SD...
|
Scanning SD filesystem...=Explorando sistema de archivos de SD...
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Skriv in namn för den nya avdelningen
|
|||||||
Insert a new name for this section=Skriv in namn för den här avdelningen
|
Insert a new name for this section=Skriv in namn för den här avdelningen
|
||||||
Yes=Ja
|
Yes=Ja
|
||||||
No=Nej
|
No=Nej
|
||||||
You will lose all the links in this section.=Du kommer att förlora alla länkar i den här
|
|
||||||
avdelningen.
|
avdelningen.
|
||||||
Exit=Avsluta
|
Exit=Avsluta
|
||||||
Link Scanner=Länkscanner
|
Link Scanner=Länkscanner
|
||||||
|
@ -97,7 +97,6 @@ Insert a name for the new section=Yeni bölüm için bir isim girin
|
|||||||
Insert a new name for this section=Bu bölüm için yeni isim girin
|
Insert a new name for this section=Bu bölüm için yeni isim girin
|
||||||
Yes=Evet
|
Yes=Evet
|
||||||
No=Hayir
|
No=Hayir
|
||||||
You will lose all the links in this section.=Bu bölümdeki tüm linkleri kaybedeceksiniz.
|
|
||||||
Exit=Çikis
|
Exit=Çikis
|
||||||
Link Scanner=Link taramasi
|
Link Scanner=Link taramasi
|
||||||
Scanning SD filesystem...=SD karti taraniyor...
|
Scanning SD filesystem...=SD karti taraniyor...
|
||||||
|
@ -71,9 +71,11 @@ ContextMenu::ContextMenu(GMenu2X &gmenu2x, Menu &menu)
|
|||||||
options.push_back(std::make_shared<MenuOption>(
|
options.push_back(std::make_shared<MenuOption>(
|
||||||
tr["Add section"],
|
tr["Add section"],
|
||||||
std::bind(&GMenu2X::addSection, &gmenu2x)));
|
std::bind(&GMenu2X::addSection, &gmenu2x)));
|
||||||
|
if (menu.sectionLinks()->empty()) {
|
||||||
options.push_back(std::make_shared<MenuOption>(
|
options.push_back(std::make_shared<MenuOption>(
|
||||||
tr["Delete section"],
|
tr["Delete section"],
|
||||||
std::bind(&GMenu2X::deleteSection, &gmenu2x)));
|
std::bind(&GMenu2X::deleteSection, &gmenu2x)));
|
||||||
|
}
|
||||||
|
|
||||||
// Compute bounding box.
|
// Compute bounding box.
|
||||||
int w = 0;
|
int w = 0;
|
||||||
|
@ -1024,15 +1024,14 @@ void GMenu2X::addSection() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMenu2X::deleteSection() {
|
void GMenu2X::deleteSection()
|
||||||
MessageBox mb(*this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
|
{
|
||||||
mb.setButton(InputManager::ACCEPT, tr["Yes"]);
|
string path = getHome() + "/sections/" + menu->selSection();
|
||||||
mb.setButton(InputManager::CANCEL, tr["No"]);
|
if (rmdir(path.c_str()) && errno != ENOENT) {
|
||||||
if (mb.exec() == InputManager::ACCEPT) {
|
WARNING("Removal of section dir \"%s\" failed: %s\n",
|
||||||
|
path.c_str(), strerror(errno));
|
||||||
if (rmtree(getHome() + "/sections/" + menu->selSection()))
|
|
||||||
menu->deleteSelectedSection();
|
|
||||||
}
|
}
|
||||||
|
menu->deleteSelectedSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_CPUFREQ
|
#ifdef ENABLE_CPUFREQ
|
||||||
|
@ -71,8 +71,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
void calcSectionRange(int &leftSection, int &rightSection);
|
void calcSectionRange(int &leftSection, int &rightSection);
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Link>> *sectionLinks(int i = -1);
|
|
||||||
|
|
||||||
void readLinks();
|
void readLinks();
|
||||||
void freeLinks();
|
void freeLinks();
|
||||||
|
|
||||||
@ -160,6 +158,7 @@ public:
|
|||||||
void setLinkIndex(int i);
|
void setLinkIndex(int i);
|
||||||
|
|
||||||
const std::vector<std::string> &getSections() { return sections; }
|
const std::vector<std::string> &getSections() { return sections; }
|
||||||
|
std::vector<std::unique_ptr<Link>> *sectionLinks(int i = -1);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MENU_H
|
#endif // MENU_H
|
||||||
|
@ -160,34 +160,6 @@ bool fileExists(const string &file) {
|
|||||||
return access(file.c_str(), F_OK) == 0;
|
return access(file.c_str(), F_OK) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rmtree(string path) {
|
|
||||||
DIR *dirp;
|
|
||||||
struct stat st;
|
|
||||||
struct dirent *dptr;
|
|
||||||
string filepath;
|
|
||||||
|
|
||||||
DEBUG("RMTREE: '%s'\n", path.c_str());
|
|
||||||
|
|
||||||
if ((dirp = opendir(path.c_str())) == NULL) return false;
|
|
||||||
if (path[path.length()-1]!='/') path += "/";
|
|
||||||
|
|
||||||
while ((dptr = readdir(dirp))) {
|
|
||||||
filepath = dptr->d_name;
|
|
||||||
if (filepath=="." || filepath=="..") continue;
|
|
||||||
filepath = path+filepath;
|
|
||||||
int statRet = stat(filepath.c_str(), &st);
|
|
||||||
if (statRet == -1) continue;
|
|
||||||
if (S_ISDIR(st.st_mode)) {
|
|
||||||
if (!rmtree(filepath)) return false;
|
|
||||||
} else {
|
|
||||||
if (unlink(filepath.c_str())!=0) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
closedir(dirp);
|
|
||||||
return rmdir(path.c_str())==0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int constrain(int x, int imin, int imax) {
|
int constrain(int x, int imin, int imax) {
|
||||||
return min(imax, max(imin, x));
|
return min(imax, max(imin, x));
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,6 @@ inline std::string trimExtension(std::string const& filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool fileExists(const std::string &file);
|
bool fileExists(const std::string &file);
|
||||||
bool rmtree(std::string path);
|
|
||||||
|
|
||||||
int constrain(int x, int imin, int imax);
|
int constrain(int x, int imin, int imax);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user