| 999 | |
| 1000 | /// |
| 1001 | void MacrosWindow::OnAdd(wxCommandEvent & WXUNUSED(event)) |
| 1002 | { |
| 1003 | // Similar to Bug 2284 we may need to save a changed macro. |
| 1004 | if (!ChangeOK()) { |
| 1005 | return; |
| 1006 | } |
| 1007 | |
| 1008 | while (true) { |
| 1009 | AudacityTextEntryDialog d(this, |
| 1010 | XO("Enter name of new macro"), |
| 1011 | XO("Name of new macro")); |
| 1012 | d.SetName(d.GetTitle()); |
| 1013 | wxString name; |
| 1014 | |
| 1015 | if (d.ShowModal() == wxID_CANCEL) { |
| 1016 | Raise(); |
| 1017 | return; |
| 1018 | } |
| 1019 | Raise(); |
| 1020 | |
| 1021 | name = d.GetValue().Strip(wxString::both); |
| 1022 | |
| 1023 | if (name.length() == 0) { |
| 1024 | AudacityMessageBox( |
| 1025 | XO("Name must not be blank"), |
| 1026 | WindowTitle(), |
| 1027 | wxOK | wxICON_ERROR, |
| 1028 | this); |
| 1029 | continue; |
| 1030 | } |
| 1031 | |
| 1032 | if (name.Contains(wxFILE_SEP_PATH) || |
| 1033 | name.Contains(wxFILE_SEP_PATH_UNIX)) { |
| 1034 | AudacityMessageBox( |
| 1035 | /*i18n-hint: The %c will be replaced with 'forbidden characters', like '/' and '\'.*/ |
| 1036 | XO("Names may not contain '%c' and '%c'") |
| 1037 | .Format(wxFILE_SEP_PATH, wxFILE_SEP_PATH_UNIX), |
| 1038 | WindowTitle(), |
| 1039 | wxOK | wxICON_ERROR, |
| 1040 | this); |
| 1041 | continue; |
| 1042 | } |
| 1043 | |
| 1044 | mMacroCommands.AddMacro(name); |
| 1045 | |
| 1046 | mActiveMacro = name; |
| 1047 | |
| 1048 | PopulateMacros(); |
| 1049 | UpdateMenus(); |
| 1050 | |
| 1051 | break; |
| 1052 | } |
| 1053 | } |
| 1054 | |
| 1055 | /// |
| 1056 | void MacrosWindow::OnRemove(wxCommandEvent & WXUNUSED(event)) |