Date:2015-04-22 19:02:04 (5 years 1 month ago)
Author:Maarten ter Huurne
Commit:fad68bfb6ee5d5407e531cd4f23622e8c71f44d1
Message:Create sections for built-in action links if necessary

Previously, the built-in actions would only be added if their
respective sections already existed.

This also works around the fact that Menu::paint() crashes if there
are no sections present.
Files: src/gmenu2x.cpp (1 diff)

Change Details

src/gmenu2x.cpp
377377void GMenu2X::initMenu() {
378378    //Menu structure handler
379379    menu.reset(new Menu(*this, ts));
380    for (uint i=0; i<menu->getSections().size(); i++) {
381        //Add virtual links in the applications section
382        if (menu->getSections()[i]=="applications") {
383            menu->addActionLink(i, "Explorer",
384                    bind(&GMenu2X::explorer, this),
385                    tr["Launch an application"],
386                    "skin:icons/explorer.png");
387        }
388380
389        //Add virtual links in the setting section
390        else if (menu->getSections()[i]=="settings") {
391            menu->addActionLink(i, "GMenu2X",
392                    bind(&GMenu2X::showSettings, this),
393                    tr["Configure GMenu2X's options"],
394                    "skin:icons/configure.png");
395            menu->addActionLink(i, tr["Skin"],
396                    bind(&GMenu2X::skinMenu, this),
397                    tr["Configure skin"],
398                    "skin:icons/skin.png");
399            menu->addActionLink(i, tr["Wallpaper"],
400                    bind(&GMenu2X::changeWallpaper, this),
401                    tr["Change GMenu2X wallpaper"],
402                    "skin:icons/wallpaper.png");
403            if (fileExists(LOG_FILE)) {
404                menu->addActionLink(i, tr["Log Viewer"],
405                        bind(&GMenu2X::viewLog, this),
406                        tr["Displays last launched program's output"],
407                        "skin:icons/ebook.png");
408            }
409            menu->addActionLink(i, tr["About"],
410                    bind(&GMenu2X::about, this),
411                    tr["Info about GMenu2X"],
412                    "skin:icons/about.png");
413        }
381    // Add action links in the applications section.
382    auto appIdx = menu->sectionNamed("applications");
383    menu->addActionLink(appIdx, "Explorer",
384            bind(&GMenu2X::explorer, this),
385            tr["Launch an application"],
386            "skin:icons/explorer.png");
387
388    // Add action links in the settings section.
389    auto settingIdx = menu->sectionNamed("settings");
390    menu->addActionLink(settingIdx, "GMenu2X",
391            bind(&GMenu2X::showSettings, this),
392            tr["Configure GMenu2X's options"],
393            "skin:icons/configure.png");
394    menu->addActionLink(settingIdx, tr["Skin"],
395            bind(&GMenu2X::skinMenu, this),
396            tr["Configure skin"],
397            "skin:icons/skin.png");
398    menu->addActionLink(settingIdx, tr["Wallpaper"],
399            bind(&GMenu2X::changeWallpaper, this),
400            tr["Change GMenu2X wallpaper"],
401            "skin:icons/wallpaper.png");
402    if (fileExists(LOG_FILE)) {
403        menu->addActionLink(settingIdx, tr["Log Viewer"],
404                bind(&GMenu2X::viewLog, this),
405                tr["Displays last launched program's output"],
406                "skin:icons/ebook.png");
414407    }
408    menu->addActionLink(settingIdx, tr["About"],
409            bind(&GMenu2X::about, this),
410            tr["Info about GMenu2X"],
411            "skin:icons/about.png");
415412
416413    menu->skinUpdated();
417414    menu->orderLinks();

Archive Download the corresponding diff file



interactive