Date:2015-04-25 21:59:51 (8 years 7 months ago)
Author:Maarten ter Huurne
Commit:c2759f1263fef5da265db7c1af65b5c767cd4860
Message: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).
Files: data/translations/Basque (1 diff)
data/translations/Catalan (1 diff)
data/translations/Danish (1 diff)
data/translations/Dutch (1 diff)
data/translations/Finnish (2 diffs)
data/translations/German (1 diff)
data/translations/Italian (1 diff)
data/translations/Norwegian (1 diff)
data/translations/Polish (1 diff)
data/translations/Portuguese (Brazil) (1 diff)
data/translations/Portuguese (Portugal) (1 diff)
data/translations/Russian (1 diff)
data/translations/Slovak (1 diff)
data/translations/Spanish (1 diff)
data/translations/Swedish (1 diff)
data/translations/Turkish (1 diff)
src/contextmenu.cpp (1 diff)
src/gmenu2x.cpp (1 diff)
src/menu.h (2 diffs)
src/utilities.cpp (1 diff)
src/utilities.h (1 diff)

Change Details

data/translations/Basque
9595Insert a new name for this section=Sekzio honetarako izen berria sartu
9696Yes=Bai
9797No=Ez
98You will lose all the links in this section.=Sekzio honetako esteka guztiak galduko dira
9998Exit=Irten
10099Link Scanner=Esteka bilatzailea
101100Scanning SD filesystem...=SD txartela arakatzen...
data/translations/Catalan
9797Insert a new name for this section=Introduir nou nom per a la secció
9898Yes=Si
9999No=No
100You will lose all the links in this section.=Es perdran tots els enllaços d'aquesta secció.
101100Exit=Sortir
102101Link Scanner=Buscador d'enllaços
103102Scanning SD filesystem...=Explorant el sistema de fitxers de la SD...
data/translations/Danish
100100Insert a new name for this section=Angiv nyt navn for denne sektion
101101Yes=Ja
102102No=Nej
103You will lose all the links in this section.=Du vil miste alle genveje i denne sektion.
104103Exit=Afslut
105104Link Scanner=Skan genveje
106105Scanning SD filesystem...=Skanner SD filsystem...
data/translations/Dutch
9797Insert a new name for this section=Geef een nieuwe naam voor deze groep
9898Yes=Ja
9999No=Nee
100You will lose all the links in this section.=Alle snelkoppelingen in deze groep worden gewist.
101100Exit=Verlaat
102101Link Scanner=Snelkoppeling-Scanner
103102Scanning SD filesystem...=Scant het SD-bestandssysteem...
data/translations/Finnish
9797Insert a new name for this section=Anna uusi nimi t�lle v�lilehdelle
9898Yes=Kyll�
9999No=Ei
100You will lose all the links in this section.=Menet�t kaikki t�ss� v�lilehdess� olevat linkit.
101100Exit=Poistu
102101Link Scanner=Linkkiskanneri
103102Scanning SD filesystem...=Skannataan SD-tiedostoj�rjestelm��...
...... 
6969Insert a new name for this section=Saisir un nouveau nom pour cette section
7070Yes=Oui
7171No=Non
72You will lose all the links in this section.=Vous perdrez tous les liens dans cette section.
7372Exit=Quitter
7473Log Viewer=Journal
7574Displays last launched program's output=Afficher la sortie du dernier programme lancé
data/translations/German
9797Insert a new name for this section=Neuer Name für diese Sektion
9898Yes=Ja
9999No=Nein
100You will lose all the links in this section.=Alle Links in dieser Sektion gehen verloren.
101100Exit=Beenden
102101Link Scanner=Links suchen
103102Scanning SD filesystem...=SD-Karte wird durchsucht...
data/translations/Italian
9797Insert a new name for this section=Inserisci un nuovo nome per questa sezione
9898Yes=Si
9999No=No
100You will lose all the links in this section.=Perderai tutti i collegamenti in questa sezione.
101100Exit=Esci
102101Link Scanner=Scanner di collegamenti
103102Scanning SD filesystem...=Scansione del filesystem della SD...
data/translations/Norwegian
6969Insert a new name for this section=Sett inn et nytt navn for denne katalogen
7070Yes=Ja
7171No=Nei
72You will lose all the links in this section.=Du vil miste alle linker i denne katalogen
7372Exit=Utgang
7473Log Viewer=Logg leser
7574Displays last launched program's output=Viser det siste lanserte programmets utgang
data/translations/Polish
6969Insert a new name for this section=Wstaw nową nazwę dla tej sekcji
7070Yes=Tak
7171No=Nie
72You will lose all the links in this section.=Wszystkie odnośniki w tej sekcji zostaną utracone.
7372Exit=Wyjdź
7473Log Viewer=Dziennik zdarzeń
7574Displays last launched program's output=Wyświetla wyjście ostatnio uruchamianego programu
data/translations/Portuguese (Brazil)
7070Insert a new name for this section=Insira um novo nome para esta seção
7171Yes=Sim
7272No=Não
73You will lose all the links in this section.=Você perderá todos os atalho desta seção.
7473Exit=Sair
7574Log Viewer=Visualizador de Logs
7675Displays last launched program's output=Mostrar a saída do último programa executado
data/translations/Portuguese (Portugal)
9797Insert a new name for this section=Insira um novo nome para esta secção
9898Yes=Sim
9999No=Não
100You will lose all the links in this section.=Perderá todos os links desta secção.
101100Exit=Sair
102101Link Scanner=Pesquisador de links
103102Scanning SD filesystem...=A pesquisar o filesystem do SD...
data/translations/Russian
9797Insert a new name for this section=Впишите новое имя для этой секции
9898Yes=Да
9999No=Нет
100You will lose all the links in this section.=Вы потеряете все ссылки в этой секции
101100Exit=Выход
102101Link Scanner=Поиск ссылок
103102Scanning SD filesystem...=Сканирование SD...
data/translations/Slovak
9797Insert a new name for this section=Zadajte nový názov pre túto sekciu
9898Yes=Áno
9999No=Nie
100You will lose all the links in this section.=Stratíte všetky odkazy v tejto sekcii.
101100Exit=Ukončiť
102101Link Scanner=Vyhľadávač odkazov
103102Scanning SD filesystem...=Prehľadávam súborový systém na SD karte...
data/translations/Spanish
9595Insert a new name for this section=Insertar nuevo nombre para la sección
9696Yes=Si
9797No=No
98You will lose all the links in this section.=Se perderán todos los enlaces de esta sección.
9998Exit=Salir
10099Link Scanner=Buscador de enlaces
101100Scanning SD filesystem...=Explorando sistema de archivos de SD...
data/translations/Swedish
9797Insert a new name for this section=Skriv in namn för den här avdelningen
9898Yes=Ja
9999No=Nej
100You will lose all the links in this section.=Du kommer att förlora alla länkar i den här
101100avdelningen.
102101Exit=Avsluta
103102Link Scanner=Länkscanner
data/translations/Turkish
9797Insert a new name for this section=Bu bölüm için yeni isim girin
9898Yes=Evet
9999No=Hayir
100You will lose all the links in this section.=Bu bölümdeki tüm linkleri kaybedeceksiniz.
101100Exit=Çikis
102101Link Scanner=Link taramasi
103102Scanning SD filesystem...=SD karti taraniyor...
src/contextmenu.cpp
7171    options.push_back(std::make_shared<MenuOption>(
7272            tr["Add section"],
7373            std::bind(&GMenu2X::addSection, &gmenu2x)));
74    options.push_back(std::make_shared<MenuOption>(
75            tr["Delete section"],
76            std::bind(&GMenu2X::deleteSection, &gmenu2x)));
74    if (menu.sectionLinks()->empty()) {
75        options.push_back(std::make_shared<MenuOption>(
76                tr["Delete section"],
77                std::bind(&GMenu2X::deleteSection, &gmenu2x)));
78    }
7779
7880    // Compute bounding box.
7981    int w = 0;
src/gmenu2x.cpp
10241024    }
10251025}
10261026
1027void GMenu2X::deleteSection() {
1028    MessageBox mb(*this,tr["You will lose all the links in this section."]+"\n"+tr["Are you sure?"]);
1029    mb.setButton(InputManager::ACCEPT, tr["Yes"]);
1030    mb.setButton(InputManager::CANCEL, tr["No"]);
1031    if (mb.exec() == InputManager::ACCEPT) {
1032
1033        if (rmtree(getHome() + "/sections/" + menu->selSection()))
1034            menu->deleteSelectedSection();
1027void GMenu2X::deleteSection()
1028{
1029    string path = getHome() + "/sections/" + menu->selSection();
1030    if (rmdir(path.c_str()) && errno != ENOENT) {
1031        WARNING("Removal of section dir \"%s\" failed: %s\n",
1032                path.c_str(), strerror(errno));
10351033    }
1034    menu->deleteSelectedSection();
10361035}
10371036
10381037#ifdef ENABLE_CPUFREQ
src/menu.h
7171     */
7272    void calcSectionRange(int &leftSection, int &rightSection);
7373
74    std::vector<std::unique_ptr<Link>> *sectionLinks(int i = -1);
75
7674    void readLinks();
7775    void freeLinks();
7876
...... 
160158    void setLinkIndex(int i);
161159
162160    const std::vector<std::string> &getSections() { return sections; }
161    std::vector<std::unique_ptr<Link>> *sectionLinks(int i = -1);
163162};
164163
165164#endif // MENU_H
src/utilities.cpp
160160    return access(file.c_str(), F_OK) == 0;
161161}
162162
163bool rmtree(string path) {
164    DIR *dirp;
165    struct stat st;
166    struct dirent *dptr;
167    string filepath;
168
169    DEBUG("RMTREE: '%s'\n", path.c_str());
170
171    if ((dirp = opendir(path.c_str())) == NULL) return false;
172    if (path[path.length()-1]!='/') path += "/";
173
174    while ((dptr = readdir(dirp))) {
175        filepath = dptr->d_name;
176        if (filepath=="." || filepath=="..") continue;
177        filepath = path+filepath;
178        int statRet = stat(filepath.c_str(), &st);
179        if (statRet == -1) continue;
180        if (S_ISDIR(st.st_mode)) {
181            if (!rmtree(filepath)) return false;
182        } else {
183            if (unlink(filepath.c_str())!=0) return false;
184        }
185    }
186
187    closedir(dirp);
188    return rmdir(path.c_str())==0;
189}
190
191163int constrain(int x, int imin, int imax) {
192164    return min(imax, max(imin, x));
193165}
src/utilities.h
7979}
8080
8181bool fileExists(const std::string &file);
82bool rmtree(std::string path);
8382
8483int constrain(int x, int imin, int imax);
8584

Archive Download the corresponding diff file



interactive