diff --git a/src/AboutDialog.cpp b/src/AboutDialog.cpp index 081da3899..4c8e3874c 100644 --- a/src/AboutDialog.cpp +++ b/src/AboutDialog.cpp @@ -411,7 +411,7 @@ visit our [[https://forum.audacityteam.org/|forum]]."); wxT("") ); - auto pPage = S.StartNotebookPage( _("Audacity") ); + auto pPage = S.StartNotebookPage( XO("Audacity") ); S.StartVerticalLay(1); { //v For now, change to AudacityLogoWithName via old-fashioned way, not Theme. @@ -464,7 +464,7 @@ visit our [[https://forum.audacityteam.org/|forum]]."); void AboutDialog::PopulateInformationPage( ShuttleGui & S ) { wxString informationStr; // string to build up list of information in - S.StartNotebookPage( _("Build Information") ); // start the tab + S.StartNotebookPage( XO("Build Information") ); // start the tab S.StartVerticalLay(2); // create the window HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, wxSize(ABOUT_DIALOG_WIDTH, 264), @@ -718,7 +718,7 @@ void AboutDialog::PopulateInformationPage( ShuttleGui & S ) void AboutDialog::PopulateLicensePage( ShuttleGui & S ) { - S.StartNotebookPage( _("GPL License") ); + S.StartNotebookPage( XO("GPL License") ); S.StartVerticalLay(1); HtmlWindow *html = safenew LinkingHtmlWindow(S.GetParent(), -1, wxDefaultPosition, diff --git a/src/ShuttleGui.cpp b/src/ShuttleGui.cpp index 4c60e4a97..7d57375e6 100644 --- a/src/ShuttleGui.cpp +++ b/src/ShuttleGui.cpp @@ -1047,18 +1047,20 @@ void ShuttleGuiBase::EndSimplebook() } -wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name ) +wxNotebookPage * ShuttleGuiBase::StartNotebookPage( + const TranslatableString & Name ) { if( mShuttleMode != eIsCreating ) return NULL; // return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent ); wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent()); - pPage->SetName(Name); + const auto translated = Name.Translation(); + pPage->SetName(translated); pNotebook->AddPage( pPage, - Name); + translated); SetProportions( 1 ); mpParent = pPage; @@ -1068,27 +1070,6 @@ wxNotebookPage * ShuttleGuiBase::StartNotebookPage( const wxString & Name ) return pPage; } -void ShuttleGuiBase::StartNotebookPage( const wxString & Name, wxNotebookPage * pPage ) -{ - if( mShuttleMode != eIsCreating ) - return; -// return wxDynamicCast(wxWindow::FindWindowById( miId, mpDlg), wx); - auto pNotebook = static_cast< wxBookCtrlBase* >( mpParent ); -// wxNotebookPage * pPage = safenew wxPanelWrapper(GetParent()); - pPage->Create( mpParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, wxT("panel")); - pPage->SetName(Name); - - pNotebook->AddPage( - pPage, - Name); - - SetProportions( 1 ); - mpParent = pPage; - pPage->SetSizer(mpSizer = safenew wxBoxSizer(wxVERTICAL)); - PushSizer(); - // UpdateSizers(); -} - void ShuttleGuiBase::EndNotebookPage() { if( mShuttleMode != eIsCreating ) @@ -1468,9 +1449,9 @@ wxSlider * ShuttleGuiBase::DoTieSlider( } -wxChoice * ShuttleGuiBase::DoTieChoice( +wxChoice * ShuttleGuiBase::TieChoice( const TranslatableString &Prompt, - WrappedType &WrappedRef, + int &Selected, const TranslatableStrings &choices ) { HandleOptionality( Prompt ); @@ -1484,17 +1465,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice( { case eIsCreating: { - if( WrappedRef.IsString() ) { - auto str = WrappedRef.ReadAsString(); - auto begin = choices.begin(); - auto iter = std::find_if( begin, choices.end(), - [&str]( const TranslatableString &choice ){ - return str == choice.Translation(); } ); - int Selected = std::distance( begin, iter ); - pChoice = AddChoice( Prompt, choices, Selected ); - } - else - pChoice = AddChoice( Prompt, choices, WrappedRef.ReadAsInt() ); + pChoice = AddChoice( Prompt, choices, Selected ); ShuttleGui::SetMinSize(pChoice, choices); } break; @@ -1506,10 +1477,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice( wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg); pChoice = wxDynamicCast(pWnd, wxChoice); wxASSERT( pChoice ); - if( WrappedRef.IsString()) - WrappedRef.WriteToAsString( pChoice->GetStringSelection()); - else - WrappedRef.WriteToAsInt( pChoice->GetSelection() ); + Selected = pChoice->GetSelection(); } break; case eIsSettingToDialog: @@ -1517,10 +1485,7 @@ wxChoice * ShuttleGuiBase::DoTieChoice( wxWindow * pWnd = wxWindow::FindWindowById( miId, mpDlg); pChoice = wxDynamicCast(pWnd, wxChoice); wxASSERT( pChoice ); - if( WrappedRef.IsString() ) - pChoice->SetStringSelection( WrappedRef.ReadAsString() ); - else - pChoice->SetSelection( WrappedRef.ReadAsInt() ); + pChoice->SetSelection( Selected ); } break; default: @@ -1724,20 +1689,16 @@ wxSlider * ShuttleGuiBase::TieVSlider( wxChoice * ShuttleGuiBase::TieChoice( const TranslatableString &Prompt, - wxString &Selected, + TranslatableString &Selected, const TranslatableStrings &choices ) { - WrappedType WrappedRef( Selected ); - return DoTieChoice( Prompt, WrappedRef, choices ); -} - -wxChoice * ShuttleGuiBase::TieChoice( - const TranslatableString &Prompt, - int &Selected, - const TranslatableStrings &choices ) -{ - WrappedType WrappedRef( Selected ); - return DoTieChoice( Prompt, WrappedRef, choices ); + int Index = make_iterator_range( choices ).index( Selected ); + auto result = TieChoice( Prompt, Index, choices ); + if ( Index >= 0 && Index < choices.size() ) + Selected = choices[ Index ]; + else + Selected = {}; + return result; } //-----------------------------------------------------------------------// diff --git a/src/ShuttleGui.h b/src/ShuttleGui.h index e17d9a0a6..db6ffeb8a 100644 --- a/src/ShuttleGui.h +++ b/src/ShuttleGui.h @@ -343,7 +343,6 @@ public: wxMenuBar * AddMenuBar( ); wxMenu * AddMenu( const TranslatableString & Title ); void AddIcon( wxBitmap * pBmp); - void AddIconButton( const wxString & Command, const wxString & Params,wxBitmap * pBmp ); void AddFixedText( const TranslatableString & Str, bool bCenter = false, int wrapWidth = 0 ); void AddConstTextBox( @@ -380,8 +379,7 @@ public: // Use within any kind of book control: // IDs of notebook pages cannot be chosen by the caller - wxNotebookPage * StartNotebookPage( const wxString & Name ); - void StartNotebookPage( const wxString & Name, wxNotebookPage * pPage ); + wxNotebookPage * StartNotebookPage( const TranslatableString & Name ); void EndNotebookPage(); @@ -412,7 +410,8 @@ public: wxCheckBox * TieCheckBoxOnRight( const TranslatableString & Prompt, bool & Var ); wxChoice * TieChoice( - const TranslatableString &Prompt, wxString &Selected, const TranslatableStrings &choices ); + const TranslatableString &Prompt, + TranslatableString &Selected, const TranslatableStrings &choices ); wxChoice * TieChoice( const TranslatableString &Prompt, int &Selected, const TranslatableStrings &choices ); @@ -563,9 +562,6 @@ private: wxTextCtrl * DoTieNumericTextBox( const TranslatableString &Prompt, WrappedType & WrappedRef, const int nChars); wxCheckBox * DoTieCheckBox( const TranslatableString &Prompt, WrappedType & WrappedRef ); - wxChoice * DoTieChoice( - const TranslatableString &Prompt, WrappedType & WrappedRef, - const TranslatableStrings & choices ); wxSlider * DoTieSlider( const TranslatableString &Prompt, WrappedType & WrappedRef, const int max, const int min = 0 ); diff --git a/src/effects/audiounits/AudioUnitEffect.cpp b/src/effects/audiounits/AudioUnitEffect.cpp index ade26d7da..ebbf4219f 100644 --- a/src/effects/audiounits/AudioUnitEffect.cpp +++ b/src/effects/audiounits/AudioUnitEffect.cpp @@ -344,7 +344,7 @@ private: EffectHostInterface *mHost; bool mUseLatency; - wxString mUIType; + TranslatableString mUIType; DECLARE_EVENT_TABLE() }; @@ -359,9 +359,13 @@ AudioUnitEffectOptionsDialog::AudioUnitEffectOptionsDialog(wxWindow * parent, Ef mHost = host; mHost->GetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency, true); - mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), mUIType, wxT("Full")); - mUIType = wxGetTranslation(mUIType); + // Expect one of three string values from the config file + wxString uiType; + mHost->GetSharedConfig(wxT("Options"), wxT("UIType"), uiType, wxT("Full")); + + // Get the localization of the string for display to the user + mUIType = TranslatableString{ uiType, {} }; ShuttleGui S(this, eIsCreating); PopulateOrExchange(S); @@ -410,8 +414,8 @@ void AudioUnitEffectOptionsDialog::PopulateOrExchange(ShuttleGui & S) S.StartHorizontalLay(wxALIGN_LEFT); { S.TieChoice(XO("Select &interface"), - mUIType, - { XO("Full"), XO("Generic"), XO("Basic") }); + mUIType, + { XO("Full"), XO("Generic"), XO("Basic") }); } S.EndHorizontalLay(); } @@ -438,21 +442,11 @@ void AudioUnitEffectOptionsDialog::OnOk(wxCommandEvent & WXUNUSED(evt)) ShuttleGui S(this, eIsGettingFromDialog); PopulateOrExchange(S); - if (mUIType == _("Full")) - { - mUIType = wxT("Full"); - } - else if (mUIType == _("Generic")) - { - mUIType = wxT("Generic"); - } - else if (mUIType == _("Basic")) - { - mUIType = wxT("Basic"); - } + // un-translate the type + auto uiType = mUIType.MSGID().GET(); mHost->SetSharedConfig(wxT("Options"), wxT("UseLatency"), mUseLatency); - mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), mUIType); + mHost->SetSharedConfig(wxT("Options"), wxT("UIType"), uiType); EndModal(wxID_OK); } diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 91cedfcf3..d2ecf23f6 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -998,7 +998,7 @@ void Exporter::CreateUserPane(wxWindow *parent) for (int j = 0; j < pPlugin->GetFormatCount(); j++) { // Name of simple book page is not displayed - S.StartNotebookPage( wxEmptyString ); + S.StartNotebookPage( {} ); pPlugin->OptionsCreate(S, j); S.EndNotebookPage(); } diff --git a/src/export/ExportMultiple.cpp b/src/export/ExportMultiple.cpp index 3b14ce9e9..8e9c3e213 100644 --- a/src/export/ExportMultiple.cpp +++ b/src/export/ExportMultiple.cpp @@ -309,7 +309,7 @@ void ExportMultipleDialog::PopulateOrExchange(ShuttleGui& S) for (int j = 0; j < pPlugin->GetFormatCount(); j++) { // Name of simple book page is not displayed - S.StartNotebookPage( wxEmptyString ); + S.StartNotebookPage( {} ); pPlugin->OptionsCreate(S, j); S.EndNotebookPage(); }