mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-06 07:09:39 +02:00
Use IdentInterfaceSymbol in old-style commands...
... Give each a translatable name, but don't use it anywhere yet, use the CamelCase name
This commit is contained in:
parent
e3c54a769e
commit
915e6ead40
@ -17,9 +17,9 @@
|
||||
#include "BatchEvalCommand.h"
|
||||
#include "CommandContext.h"
|
||||
|
||||
wxString BatchEvalCommandType::BuildName()
|
||||
IdentInterfaceSymbol BatchEvalCommandType::BuildName()
|
||||
{
|
||||
return wxT("BatchCommand");
|
||||
return { wxT("BatchCommand"), XO("Batch Command") };
|
||||
}
|
||||
|
||||
void BatchEvalCommandType::BuildSignature(CommandSignature &signature)
|
||||
|
@ -29,7 +29,7 @@ to that system.
|
||||
class BatchEvalCommandType final : public OldStyleCommandType
|
||||
{
|
||||
public:
|
||||
wxString BuildName() override;
|
||||
IdentInterfaceSymbol BuildName() override;
|
||||
void BuildSignature(CommandSignature &signature) override;
|
||||
OldStyleCommandPointer Create(std::unique_ptr<CommandOutputTargets> &&target) override;
|
||||
};
|
||||
|
@ -106,9 +106,9 @@ DecoratedCommand::~DecoratedCommand()
|
||||
{
|
||||
}
|
||||
|
||||
wxString DecoratedCommand::GetName()
|
||||
IdentInterfaceSymbol DecoratedCommand::GetSymbol()
|
||||
{
|
||||
return mCommand->GetName();
|
||||
return mCommand->GetSymbol();
|
||||
}
|
||||
|
||||
CommandSignature &DecoratedCommand::GetSignature()
|
||||
@ -150,7 +150,11 @@ bool ApplyAndSendResponse::Apply()
|
||||
return bResult; }
|
||||
);
|
||||
wxString response = wxT( "\n" );
|
||||
response += GetName();
|
||||
|
||||
// PRL: it's all right to send untranslated strings to this channel
|
||||
// I don't see _("") used with literal strings.
|
||||
response += GetSymbol().Internal();
|
||||
|
||||
// These three strings are deliberately not localised.
|
||||
// They are used in script responses and always happen in English.
|
||||
response += wxT(" finished: ");
|
||||
@ -183,7 +187,7 @@ void CommandImplementation::TypeCheck(const wxString &typeName,
|
||||
{
|
||||
// this macro is empty if wxWidgets is not compiled in debug mode
|
||||
wxASSERT_MSG(param.IsType(typeName),
|
||||
GetName()
|
||||
GetSymbol().Internal()
|
||||
+ wxT("command tried to get '")
|
||||
+ paramName
|
||||
+ wxT("' parameter as a ")
|
||||
@ -195,7 +199,7 @@ void CommandImplementation::CheckParam(const wxString ¶mName)
|
||||
{
|
||||
// this macro is empty if wxWidgets is not compiled in debug mode
|
||||
wxASSERT_MSG(mParams.find(paramName) != mParams.end(),
|
||||
GetName()
|
||||
GetSymbol().Internal()
|
||||
+ wxT("command tried to get '")
|
||||
+ paramName
|
||||
+ wxT("' parameter, but that parameter doesn't exist in the command signature!"));
|
||||
@ -242,9 +246,9 @@ wxString CommandImplementation::GetString(const wxString ¶mName)
|
||||
}
|
||||
|
||||
/// Get the name of the command
|
||||
wxString CommandImplementation::GetName()
|
||||
IdentInterfaceSymbol CommandImplementation::GetSymbol()
|
||||
{
|
||||
return mType.GetName();
|
||||
return mType.GetSymbol();
|
||||
}
|
||||
|
||||
/// Get the signature of the command
|
||||
@ -260,8 +264,11 @@ bool CommandImplementation::SetParameter(const wxString ¶mName, const wxVari
|
||||
ParamValueMap::iterator iter = mParams.find(paramName);
|
||||
if (iter == mParams.end())
|
||||
{
|
||||
// Translated format, but untranslated command name substituted into it?
|
||||
// Perhaps these formats that don't need translating.
|
||||
context.Error( wxString::Format(
|
||||
_("%s is not a parameter accepted by %s"), paramName, GetName() ) );
|
||||
_("%s is not a parameter accepted by %s"),
|
||||
paramName, GetSymbol().Internal() ) );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class OldStyleCommand /* not final */
|
||||
public:
|
||||
OldStyleCommand() {};
|
||||
virtual ~OldStyleCommand() { }
|
||||
virtual wxString GetName() = 0;
|
||||
virtual IdentInterfaceSymbol GetSymbol() = 0;
|
||||
virtual CommandSignature &GetSignature() = 0;
|
||||
virtual bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue);
|
||||
virtual bool Apply()=0;
|
||||
@ -57,7 +57,7 @@ public:
|
||||
wxASSERT(cmd != NULL);
|
||||
}
|
||||
virtual ~DecoratedCommand();
|
||||
wxString GetName() override;
|
||||
IdentInterfaceSymbol GetSymbol() override;
|
||||
CommandSignature &GetSignature() override;
|
||||
bool SetParameter(const wxString ¶mName, const wxVariant ¶mValue) override;
|
||||
};
|
||||
@ -105,7 +105,7 @@ public:
|
||||
virtual ~CommandImplementation();
|
||||
|
||||
/// An instance method for getting the command name (for consistency)
|
||||
wxString GetName() override;
|
||||
IdentInterfaceSymbol GetSymbol() override;
|
||||
|
||||
/// Get the signature of the command
|
||||
CommandSignature &GetSignature() override;
|
||||
|
@ -80,7 +80,8 @@ OldStyleCommandType *CommandDirectory::LookUp(const wxString &cmdName) const
|
||||
void CommandDirectory::AddCommand(movable_ptr<OldStyleCommandType> &&type)
|
||||
{
|
||||
wxASSERT(type != NULL);
|
||||
wxString cmdName = type->GetName();
|
||||
// Internal string is shown but only in assertion message
|
||||
auto cmdName = type->GetName();
|
||||
wxASSERT_MSG(mCmdMap.find(cmdName) == mCmdMap.end()
|
||||
, wxT("A command named ") + cmdName
|
||||
+ wxT(" already exists."));
|
||||
|
@ -24,7 +24,7 @@ Also acts as a factory.
|
||||
#include <wx/string.h>
|
||||
|
||||
OldStyleCommandType::OldStyleCommandType()
|
||||
: mName{}, mSignature{}
|
||||
: mSymbol{}, mSignature{}
|
||||
{ }
|
||||
|
||||
OldStyleCommandType::~OldStyleCommandType()
|
||||
@ -33,9 +33,9 @@ OldStyleCommandType::~OldStyleCommandType()
|
||||
|
||||
wxString OldStyleCommandType::GetName()
|
||||
{
|
||||
if (mName.empty())
|
||||
mName = BuildName();
|
||||
return mName;
|
||||
if (mSymbol.empty())
|
||||
mSymbol = BuildName();
|
||||
return mSymbol.Internal();
|
||||
}
|
||||
|
||||
CommandSignature &OldStyleCommandType::GetSignature()
|
||||
@ -50,6 +50,8 @@ CommandSignature &OldStyleCommandType::GetSignature()
|
||||
|
||||
wxString OldStyleCommandType::Describe()
|
||||
{
|
||||
// PRL: Is this intended for end-user visibility or just debugging? It did not
|
||||
// use _(""), so I assume it is meant to use internal strings
|
||||
wxString desc = GetName() + wxT("\nParameters:");
|
||||
GetSignature();
|
||||
ParamValueMap::iterator iter;
|
||||
|
@ -44,7 +44,7 @@ class wxString;
|
||||
class OldStyleCommandType : public AudacityCommand
|
||||
{
|
||||
private:
|
||||
wxString mName;
|
||||
IdentInterfaceSymbol mSymbol;
|
||||
Maybe<CommandSignature> mSignature;
|
||||
|
||||
public:
|
||||
@ -52,13 +52,13 @@ public:
|
||||
virtual ~OldStyleCommandType();
|
||||
wxString GetName() override;
|
||||
CommandSignature &GetSignature();
|
||||
wxString Describe();
|
||||
wxString Describe(); // for debugging only ?
|
||||
|
||||
// Subclasses should override the following:
|
||||
// =========================================
|
||||
|
||||
// Return the name of the command type
|
||||
virtual wxString BuildName() = 0;
|
||||
virtual IdentInterfaceSymbol BuildName() = 0;
|
||||
|
||||
/// Postcondition: signature is a 'signature' map containing parameter
|
||||
// names, validators and default values.
|
||||
|
Loading…
x
Reference in New Issue
Block a user