Use IdentInterfaceSymbol in PluginDescriptor

This commit is contained in:
Paul Licameli 2018-03-09 04:52:18 -05:00
parent 68e4bf6c5e
commit e3c54a769e
6 changed files with 51 additions and 73 deletions

View File

@ -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)")
} );

View File

@ -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())
{

View File

@ -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) +

View File

@ -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);

View File

@ -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);

View File

@ -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);