src/gmenu2x.cpp |
855 | 855 | } |
856 | 856 | |
857 | 857 | void GMenu2X::editLink() { |
858 | | if (menu->selLinkApp()==NULL) return; |
| 858 | LinkApp *linkApp = menu->selLinkApp(); |
| 859 | if (!linkApp) return; |
859 | 860 | |
860 | 861 | vector<string> pathV; |
861 | | split(pathV,menu->selLinkApp()->getFile(),"/"); |
| 862 | split(pathV,linkApp->getFile(),"/"); |
862 | 863 | string oldSection = ""; |
863 | 864 | if (pathV.size()>1) |
864 | 865 | oldSection = pathV[pathV.size()-2]; |
865 | 866 | string newSection = oldSection; |
866 | 867 | |
867 | | string linkTitle = menu->selLinkApp()->getTitle(); |
868 | | string linkDescription = menu->selLinkApp()->getDescription(); |
869 | | string linkIcon = menu->selLinkApp()->getIcon(); |
870 | | string linkManual = menu->selLinkApp()->getManual(); |
871 | | string linkSelFilter = menu->selLinkApp()->getSelectorFilter(); |
872 | | string linkSelDir = menu->selLinkApp()->getSelectorDir(); |
873 | | bool linkSelBrowser = menu->selLinkApp()->getSelectorBrowser(); |
874 | | string linkSelScreens = menu->selLinkApp()->getSelectorScreens(); |
875 | | string linkSelAliases = menu->selLinkApp()->getAliasFile(); |
876 | | int linkClock = menu->selLinkApp()->clock(); |
| 868 | string linkTitle = linkApp->getTitle(); |
| 869 | string linkDescription = linkApp->getDescription(); |
| 870 | string linkIcon = linkApp->getIcon(); |
| 871 | string linkManual = linkApp->getManual(); |
| 872 | string linkSelFilter = linkApp->getSelectorFilter(); |
| 873 | string linkSelDir = linkApp->getSelectorDir(); |
| 874 | bool linkSelBrowser = linkApp->getSelectorBrowser(); |
| 875 | string linkSelScreens = linkApp->getSelectorScreens(); |
| 876 | string linkSelAliases = linkApp->getAliasFile(); |
| 877 | int linkClock = linkApp->clock(); |
877 | 878 | |
878 | 879 | string diagTitle = tr.translate("Edit link: $1",linkTitle.c_str(),NULL); |
879 | | string diagIcon = menu->selLinkApp()->getIconPath(); |
| 880 | string diagIcon = linkApp->getIconPath(); |
880 | 881 | |
881 | 882 | SettingsDialog sd(this, input, ts, diagTitle, diagIcon); |
882 | 883 | #ifdef HAVE_LIBOPK |
883 | | if (!menu->selLinkApp()->isOpk()) { |
| 884 | if (!linkApp->isOpk()) { |
884 | 885 | #endif |
885 | 886 | sd.addSetting(new MenuSettingString(this, ts, tr["Title"], tr["Link title"], &linkTitle, diagTitle, diagIcon)); |
886 | 887 | sd.addSetting(new MenuSettingString(this, ts, tr["Description"], tr["Link description"], &linkDescription, diagTitle, diagIcon)); |
... | ... | |
893 | 894 | &linkManual, "man.png,txt")); |
894 | 895 | #ifdef HAVE_LIBOPK |
895 | 896 | } |
896 | | if (!menu->selLinkApp()->isOpk() || |
897 | | !menu->selLinkApp()->getSelectorDir().empty()) { |
| 897 | if (!linkApp->isOpk() || !linkApp->getSelectorDir().empty()) { |
898 | 898 | #endif |
899 | 899 | sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Directory"], tr["Directory to scan for the selector"], &linkSelDir)); |
900 | 900 | sd.addSetting(new MenuSettingBool(this, ts, tr["Selector Browser"], tr["Allow the selector to change directory"], &linkSelBrowser)); |
... | ... | |
905 | 905 | sd.addSetting(new MenuSettingInt(this, ts, tr["Clock frequency"], tr["Cpu clock frequency to set when launching this link"], &linkClock, cpuFreqMin, confInt["maxClock"], cpuFreqMultiple)); |
906 | 906 | #endif |
907 | 907 | #ifdef HAVE_LIBOPK |
908 | | if (!menu->selLinkApp()->isOpk()) { |
| 908 | if (!linkApp->isOpk()) { |
909 | 909 | #endif |
910 | 910 | sd.addSetting(new MenuSettingString(this, ts, tr["Selector Filter"], tr["Selector filter (Separate values with a comma)"], &linkSelFilter, diagTitle, diagIcon)); |
911 | 911 | sd.addSetting(new MenuSettingDir(this, ts, tr["Selector Screenshots"], tr["Directory of the screenshots for the selector"], &linkSelScreens)); |
912 | 912 | sd.addSetting(new MenuSettingFile(this, ts, tr["Selector Aliases"], tr["File containing a list of aliases for the selector"], &linkSelAliases)); |
913 | | sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &menu->selLinkApp()->runsInBackgroundRef())); |
| 913 | sd.addSetting(new MenuSettingBool(this, ts, tr["Don't Leave"], tr["Don't quit GMenu2X when launching this link"], &linkApp->runsInBackgroundRef())); |
914 | 914 | #if defined(PLATFORM_A320) || defined(PLATFORM_GCW0) |
915 | | sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &menu->selLinkApp()->consoleApp)); |
| 915 | sd.addSetting(new MenuSettingBool(this, ts, tr["Display Console"], tr["Must be enabled for console-based applications"], &linkApp->consoleApp)); |
916 | 916 | #endif |
917 | 917 | #ifdef HAVE_LIBOPK |
918 | 918 | } |
919 | 919 | #endif |
920 | 920 | |
921 | 921 | if (sd.exec() && sd.edited()) { |
922 | | menu->selLinkApp()->setTitle(linkTitle); |
923 | | menu->selLinkApp()->setDescription(linkDescription); |
924 | | menu->selLinkApp()->setIcon(linkIcon); |
925 | | menu->selLinkApp()->setManual(linkManual); |
926 | | menu->selLinkApp()->setSelectorFilter(linkSelFilter); |
927 | | menu->selLinkApp()->setSelectorDir(linkSelDir); |
928 | | menu->selLinkApp()->setSelectorBrowser(linkSelBrowser); |
929 | | menu->selLinkApp()->setSelectorScreens(linkSelScreens); |
930 | | menu->selLinkApp()->setAliasFile(linkSelAliases); |
931 | | menu->selLinkApp()->setClock(linkClock); |
| 922 | linkApp->setTitle(linkTitle); |
| 923 | linkApp->setDescription(linkDescription); |
| 924 | linkApp->setIcon(linkIcon); |
| 925 | linkApp->setManual(linkManual); |
| 926 | linkApp->setSelectorFilter(linkSelFilter); |
| 927 | linkApp->setSelectorDir(linkSelDir); |
| 928 | linkApp->setSelectorBrowser(linkSelBrowser); |
| 929 | linkApp->setSelectorScreens(linkSelScreens); |
| 930 | linkApp->setAliasFile(linkSelAliases); |
| 931 | linkApp->setClock(linkClock); |
932 | 932 | |
933 | 933 | INFO("New Section: '%s'\n", newSection.c_str()); |
934 | 934 | |
... | ... | |
944 | 944 | newFileName = "sections/"+newSection+"/"+linkTitle+id; |
945 | 945 | x++; |
946 | 946 | } |
947 | | rename(menu->selLinkApp()->getFile().c_str(),newFileName.c_str()); |
948 | | menu->selLinkApp()->renameFile(newFileName); |
| 947 | rename(linkApp->getFile().c_str(),newFileName.c_str()); |
| 948 | linkApp->renameFile(newFileName); |
949 | 949 | |
950 | 950 | INFO("New section index: %i.\n", newSectionIndex - menu->getSections().begin()); |
951 | 951 | |
952 | 952 | menu->linkChangeSection(menu->selLinkIndex(), menu->selSectionIndex(), newSectionIndex - menu->getSections().begin()); |
953 | 953 | } |
954 | | menu->selLinkApp()->save(); |
| 954 | linkApp->save(); |
955 | 955 | sync(); |
956 | 956 | } |
957 | 957 | } |