1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-16 15:41:11 +02:00

Modules should register their menu items only after version check

This commit is contained in:
Paul Licameli
2020-02-16 13:28:40 -05:00
parent 11bbce10b1
commit 5c85deb944
2 changed files with 49 additions and 37 deletions

View File

@@ -136,28 +136,13 @@ const wxChar * GetVersionString()
return AUDACITY_VERSION_STRING; return AUDACITY_VERSION_STRING;
} }
// This is the function that connects us to Audacity.
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
int ModuleDispatch(ModuleDispatchTypes type)
{
switch (type)
{
case AppInitialized:
break;
case AppQuiting:
break;
default:
break;
}
return 1;
}
// Register our extra menu items
namespace { namespace {
void RegisterMenuItems()
{
// Get here only after the module version check passes
using namespace MenuTable; using namespace MenuTable;
// We add two new commands into the Analyze menu. // We add two new commands into the Analyze menu.
AttachedItem sAttachment{ wxT("Analyze"), static AttachedItem sAttachment{ wxT("Analyze"),
( FinderScope( ident ), Section( wxT("NullModule"), ( FinderScope( ident ), Section( wxT("NullModule"),
Command( Command(
_T("A New Command"), // internal name _T("A New Command"), // internal name
@@ -172,6 +157,27 @@ namespace {
) ) ) )
}; };
} }
}
// This is the function that connects us to Audacity.
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
int ModuleDispatch(ModuleDispatchTypes type)
{
switch (type)
{
case ModuleInitialize:
RegisterMenuItems();
break;
case AppInitialized:
break;
case AppQuiting:
break;
default:
break;
}
return 1;
}
//Example code commented out. //Example code commented out.
#if 0 #if 0

View File

@@ -140,15 +140,30 @@ and replace the main project window with our own wxFrame.
*/ */
namespace {
CommandHandlerObject &findme(AudacityProject&)
{
return *NyqBench::GetBench();
}
void RegisterMenuItems()
{
// Get here only after the module version check passes
using namespace MenuTable;
static AttachedItem sAttachment{ wxT("Tools"),
( FinderScope( findme ), Section( wxT("NyquistWorkBench"),
Command( wxT("NyqBench"), XO("&Nyquist Workbench..."),
static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench),
AudioIONotBusyFlag())
) )
};
}
}
extern "C" extern "C"
{ {
static NyqBench *gBench = NULL; static NyqBench *gBench = NULL;
static CommandHandlerObject &findme(AudacityProject&)
{
return *NyqBench::GetBench();
}
#ifdef _MSC_VER #ifdef _MSC_VER
#define DLL_API _declspec(dllexport) #define DLL_API _declspec(dllexport)
#else #else
@@ -171,6 +186,9 @@ extern "C"
// is called by Audacity to initialize/terminate the module // is called by Audacity to initialize/terminate the module
int ModuleDispatch(ModuleDispatchTypes type){ int ModuleDispatch(ModuleDispatchTypes type){
switch (type){ switch (type){
case ModuleInitialize:
RegisterMenuItems();
break;
case AppQuiting: { case AppQuiting: {
//It is perfectly OK for gBench to be NULL. //It is perfectly OK for gBench to be NULL.
//Can happen if the menu item was never invoked. //Can happen if the menu item was never invoked.
@@ -188,18 +206,6 @@ extern "C"
} }
}; };
// Register our extra menu item
namespace {
using namespace MenuTable;
AttachedItem sAttachment{ wxT("Tools"),
( FinderScope( findme ), Section( wxT("NyquistWorkBench"),
Command( wxT("NyqBench"), XO("&Nyquist Workbench..."),
static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench),
AudioIONotBusyFlag())
) )
};
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// NyqTextCtrl // NyqTextCtrl
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------