From e3c54a769e0d507a8d9c8849c02e657b81fc864c Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Fri, 9 Mar 2018 04:52:18 -0500 Subject: [PATCH] Use IdentInterfaceSymbol in PluginDescriptor --- src/BatchCommands.cpp | 2 +- src/Menus.cpp | 28 +++++++-------- src/PluginManager.cpp | 68 +++++++++++++---------------------- src/PluginManager.h | 16 +++------ src/effects/EffectManager.cpp | 9 +++-- src/effects/EffectManager.h | 1 + 6 files changed, 51 insertions(+), 73 deletions(-) diff --git a/src/BatchCommands.cpp b/src/BatchCommands.cpp index 2077b646f..ba7997ab9 100644 --- a/src/BatchCommands.cpp +++ b/src/BatchCommands.cpp @@ -310,7 +310,7 @@ MacroCommandsCatalog::MacroCommandsCatalog( const AudacityProject *project ) auto command = em.GetCommandIdentifier(plug->GetID()); if (!command.IsEmpty()) commands.push_back( { - { command, plug->GetTranslatedName() }, + { command, plug->GetSymbol().Translation() }, plug->GetPluginType() == PluginTypeEffect ? _("Effect") : _("Menu Command (With Parameters)") } ); diff --git a/src/Menus.cpp b/src/Menus.cpp index 3fcb8b7f1..ea569192c 100644 --- a/src/Menus.cpp +++ b/src/Menus.cpp @@ -176,8 +176,8 @@ enum { // static bool SortEffectsByName(const PluginDescriptor *a, const PluginDescriptor *b) { - wxString akey = a->GetTranslatedName(); - wxString bkey = b->GetTranslatedName(); + auto akey = a->GetSymbol().Translation(); + auto bkey = b->GetSymbol().Translation(); akey += a->GetPath(); bkey += b->GetPath(); @@ -199,8 +199,8 @@ static bool SortEffectsByPublisher(const PluginDescriptor *a, const PluginDescri bkey = _("Uncategorized"); } - akey += a->GetTranslatedName(); - bkey += b->GetTranslatedName(); + akey += a->GetSymbol().Translation(); + bkey += b->GetSymbol().Translation(); akey += a->GetPath(); bkey += b->GetPath(); @@ -222,8 +222,8 @@ static bool SortEffectsByPublisherAndName(const PluginDescriptor *a, const Plugi bkey = wxEmptyString; } - akey += a->GetTranslatedName(); - bkey += b->GetTranslatedName(); + akey += a->GetSymbol().Translation(); + bkey += b->GetSymbol().Translation(); akey += a->GetPath(); bkey += b->GetPath(); @@ -255,8 +255,8 @@ static bool SortEffectsByTypeAndName(const PluginDescriptor *a, const PluginDesc bkey = wxEmptyString; } - akey += a->GetTranslatedName(); - bkey += b->GetTranslatedName(); + akey += a->GetSymbol().Translation(); + bkey += b->GetSymbol().Translation(); akey += a->GetPath(); bkey += b->GetPath(); @@ -279,8 +279,8 @@ static bool SortEffectsByType(const PluginDescriptor *a, const PluginDescriptor bkey = _("Uncategorized"); } - akey += a->GetTranslatedName(); - bkey += b->GetTranslatedName(); + akey += a->GetSymbol().Translation(); + bkey += b->GetSymbol().Translation(); akey += a->GetPath(); bkey += b->GetPath(); @@ -1834,8 +1834,8 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, { const PluginDescriptor *plug = plugs[i]; - bool hasDialog = plug->GetUntranslatedName().Contains("..."); - wxString name = plug->GetTranslatedName(); + bool hasDialog = plug->GetSymbol().Msgid().Contains("..."); + auto name = plug->GetSymbol().Translation(); if (plug->IsEffectInteractive()) { @@ -1902,8 +1902,8 @@ void AudacityProject::AddEffectMenuItems(CommandManager *c, { const PluginDescriptor *plug = plugs[i]; - bool hasDialog = plug->GetUntranslatedName().Contains("..."); - wxString name = plug->GetTranslatedName(); + bool hasDialog = plug->GetSymbol().Msgid().Contains("..."); + auto name = plug->GetSymbol().Translation(); if (plug->IsEffectInteractive()) { diff --git a/src/PluginManager.cpp b/src/PluginManager.cpp index 670416875..dfdd75733 100644 --- a/src/PluginManager.cpp +++ b/src/PluginManager.cpp @@ -643,7 +643,7 @@ void PluginRegistrationDialog::PopulateOrExchange(ShuttleGui &S) if (plugType == PluginTypeEffect) { - item.name = plug.GetTranslatedName(); + item.name = plug.GetSymbol().Translation(); } // This is not right and will not work when other plugin types are added. // But it's presumed that the plugin manager dialog will be fully developed @@ -1151,31 +1151,16 @@ const wxString & PluginDescriptor::GetPath() const return mPath; } -const wxString & PluginDescriptor::GetSymbol() const +const IdentInterfaceSymbol & PluginDescriptor::GetSymbol() const { - if (mSymbol.IsEmpty()) - { - return mName; - } - return mSymbol; } -wxString PluginDescriptor::GetUntranslatedName() const -{ - return mName; -} - wxString PluginDescriptor::GetUntranslatedVersion() const { return mVersion; } -wxString PluginDescriptor::GetTranslatedName() const -{ - return wxGetTranslation(mName); -} - wxString PluginDescriptor::GetUntranslatedVendor() const { return mVendor; @@ -1216,16 +1201,11 @@ void PluginDescriptor::SetPath(const wxString & path) mPath = path; } -void PluginDescriptor::SetSymbol(const wxString & symbol) +void PluginDescriptor::SetSymbol(const IdentInterfaceSymbol & symbol) { mSymbol = symbol; } -void PluginDescriptor::SetName(const wxString & name) -{ - mName = name; -} - void PluginDescriptor::SetVersion(const wxString & version) { mVersion = version; @@ -2035,18 +2015,25 @@ void PluginManager::LoadGroup(wxFileConfig *pRegistry, PluginType type) continue; plug.SetPath(strVal); + /* + // PRL: Ignore names written in configs before 2.3.0! + // use Internal string only! Let the present version of Audacity map + // that to a user-visible string. // Get the name and bypass group if not found if (!pRegistry->Read(KEY_NAME, &strVal)) { continue; } plug.SetName(strVal); + */ - // Get the symbol...use name if not found + // Get the symbol...Audacity 2.3.0 or later requires it + // bypass group if not found + // Note, KEY_SYMBOL started getting written to config files in 2.1.0. + // KEY_NAME (now ignored) was written before that, but only for VST + // effects. if (!pRegistry->Read(KEY_SYMBOL, &strVal)) - { - strVal = plug.GetTranslatedName(); - } + continue; plug.SetSymbol(strVal); // Get the version and bypass group if not found @@ -2251,8 +2238,12 @@ void PluginManager::SaveGroup(wxFileConfig *pRegistry, PluginType type) pRegistry->SetPath(REGROOT + group + wxCONFIG_PATH_SEPARATOR + ConvertID(plug.GetID())); pRegistry->Write(KEY_PATH, plug.GetPath()); - pRegistry->Write(KEY_SYMBOL, plug.GetSymbol()); - pRegistry->Write(KEY_NAME, plug.GetUntranslatedName()); + pRegistry->Write(KEY_SYMBOL, plug.GetSymbol().Internal()); + + // PRL: Writing KEY_NAME which is no longer read, but older Audacity + // versions expect to find it. + pRegistry->Write(KEY_NAME, plug.GetSymbol().Msgid()); + pRegistry->Write(KEY_VERSION, plug.GetUntranslatedVersion()); pRegistry->Write(KEY_VENDOR, plug.GetUntranslatedVendor()); // Write a blank -- see comments in LoadGroup: @@ -2583,27 +2574,17 @@ void PluginManager::EnablePlugin(const PluginID & ID, bool enable) return mPlugins[ID].SetEnabled(enable); } -const wxString & PluginManager::GetSymbol(const PluginID & ID) +const IdentInterfaceSymbol & PluginManager::GetSymbol(const PluginID & ID) { if (mPlugins.find(ID) == mPlugins.end()) { - static wxString empty; + static IdentInterfaceSymbol empty; return empty; } return mPlugins[ID].GetSymbol(); } -wxString PluginManager::GetName(const PluginID & ID) -{ - if (mPlugins.find(ID) == mPlugins.end()) - { - return wxEmptyString; - } - - return mPlugins[ID].GetTranslatedName(); -} - IdentInterface *PluginManager::GetInstance(const PluginID & ID) { if (mPlugins.find(ID) == mPlugins.end()) @@ -2713,8 +2694,7 @@ PluginDescriptor & PluginManager::CreatePlugin(const PluginID & id, plug.SetID(id); plug.SetPath(ident->GetPath()); - plug.SetSymbol(ident->GetSymbol()); - plug.SetName(ident->GetName()); + plug.SetSymbol( { ident->GetSymbol(), ident->GetName() } ); plug.SetVendor(ident->GetVendor()); plug.SetVersion(ident->GetVersion()); @@ -2963,7 +2943,7 @@ wxString PluginManager::SettingsPath(const PluginID & ID, bool shared) wxT("_") + plug.GetUntranslatedVendor() + wxT("_") + - (shared ? wxT("") : plug.GetSymbol()); + (shared ? wxT("") : plug.GetSymbol().Internal()); return SETROOT + ConvertID(id) + diff --git a/src/PluginManager.h b/src/PluginManager.h index ad9970751..2e649f81a 100644 --- a/src/PluginManager.h +++ b/src/PluginManager.h @@ -60,14 +60,11 @@ public: const wxString & GetID() const; const wxString & GetProviderID() const; const wxString & GetPath() const; - const wxString & GetSymbol() const; + const IdentInterfaceSymbol & GetSymbol() const; wxString GetUntranslatedVersion() const; // There is no translated version - wxString GetUntranslatedName() const; - wxString GetTranslatedName() const; - wxString GetUntranslatedVendor() const; wxString GetTranslatedVendor() const; bool IsEnabled() const; @@ -77,11 +74,10 @@ public: void SetID(const PluginID & ID); void SetProviderID(const PluginID & providerID); void SetPath(const wxString & path); - void SetSymbol(const wxString & symbol); + void SetSymbol(const IdentInterfaceSymbol & symbol); // These should be passed an untranslated value wrapped in XO() so // the value will still be extracted for translation - void SetName(const wxString & name); void SetVersion(const wxString & version); void SetVendor(const wxString & vendor); @@ -137,8 +133,7 @@ private: wxString mID; wxString mPath; - wxString mSymbol; - wxString mName; + IdentInterfaceSymbol mSymbol; wxString mVersion; wxString mVendor; wxString mProviderID; @@ -258,10 +253,7 @@ public: bool IsPluginEnabled(const PluginID & ID); void EnablePlugin(const PluginID & ID, bool enable); - // Returns untranslated string - const wxString & GetSymbol(const PluginID & ID); - // Returns translated string - wxString GetName(const PluginID & ID); + const IdentInterfaceSymbol & GetSymbol(const PluginID & ID); IdentInterface *GetInstance(const PluginID & ID); void CheckForUpdates(bool bFast = false); diff --git a/src/effects/EffectManager.cpp b/src/effects/EffectManager.cpp index dc1797e55..c73638096 100644 --- a/src/effects/EffectManager.cpp +++ b/src/effects/EffectManager.cpp @@ -142,9 +142,14 @@ bool EffectManager::DoAudacityCommand(const PluginID & ID, return res; } +IdentInterfaceSymbol EffectManager::GetCommandSymbol(const PluginID & ID) +{ + return PluginManager::Get().GetSymbol(ID); +} + wxString EffectManager::GetCommandName(const PluginID & ID) { - return GetCustomTranslation( PluginManager::Get().GetName(ID) ); + return GetCommandSymbol(ID).Translation(); } wxString EffectManager::GetEffectFamilyName(const PluginID & ID) @@ -157,7 +162,7 @@ wxString EffectManager::GetEffectFamilyName(const PluginID & ID) wxString EffectManager::GetCommandIdentifier(const PluginID & ID) { - wxString name = (PluginManager::Get().GetSymbol(ID)); + wxString name = PluginManager::Get().GetSymbol(ID).Internal(); // Get rid of leading and trailing white space name.Trim(true).Trim(false); diff --git a/src/effects/EffectManager.h b/src/effects/EffectManager.h index 2b964c83f..351d8666e 100644 --- a/src/effects/EffectManager.h +++ b/src/effects/EffectManager.h @@ -90,6 +90,7 @@ public: bool shouldPrompt = true ); // Renamed from 'Effect' to 'Command' prior to moving out of this class. + IdentInterfaceSymbol GetCommandSymbol(const PluginID & ID); wxString GetCommandName(const PluginID & ID); // translated wxString GetCommandIdentifier(const PluginID & ID); wxString GetCommandDescription(const PluginID & ID);