diff --git a/lib-src/mod-null/ModNullCallback.cpp b/lib-src/mod-null/ModNullCallback.cpp index a91fadd92..abac88a90 100644 --- a/lib-src/mod-null/ModNullCallback.cpp +++ b/lib-src/mod-null/ModNullCallback.cpp @@ -136,12 +136,38 @@ const wxChar * GetVersionString() return AUDACITY_VERSION_STRING; } +namespace { +void RegisterMenuItems() +{ + // Get here only after the module version check passes + using namespace MenuTable; + // We add two new commands into the Analyze menu. + static AttachedItem sAttachment{ wxT("Analyze"), + ( FinderScope( ident ), Section( wxT("NullModule"), + Command( + _T("A New Command"), // internal name + XO("1st Experimental Command..."), //displayed name + ModNullFN( OnFuncFirst ), + AudioIONotBusyFlag() ), + Command( + _T("Another New Command"), + XO("2nd Experimental Command"), + ModNullFN( OnFuncSecond ), + AudioIONotBusyFlag() ) + ) ) + }; +} +} + // 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: @@ -153,26 +179,6 @@ int ModuleDispatch(ModuleDispatchTypes type) return 1; } -// Register our extra menu items -namespace { - using namespace MenuTable; - // We add two new commands into the Analyze menu. - AttachedItem sAttachment{ wxT("Analyze"), - ( FinderScope( ident ), Section( wxT("NullModule"), - Command( - _T("A New Command"), // internal name - XO("1st Experimental Command..."), //displayed name - ModNullFN( OnFuncFirst ), - AudioIONotBusyFlag() ), - Command( - _T("Another New Command"), - XO("2nd Experimental Command"), - ModNullFN( OnFuncSecond ), - AudioIONotBusyFlag() ) - ) ) - }; -} - //Example code commented out. #if 0 // This is an example function to hijack the main panel diff --git a/lib-src/mod-nyq-bench/NyqBench.cpp b/lib-src/mod-nyq-bench/NyqBench.cpp index 71bb59b43..7e57db9bd 100755 --- a/lib-src/mod-nyq-bench/NyqBench.cpp +++ b/lib-src/mod-nyq-bench/NyqBench.cpp @@ -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(&NyqBench::ShowNyqBench), + AudioIONotBusyFlag()) + ) ) + }; +} +} + extern "C" { static NyqBench *gBench = NULL; - static CommandHandlerObject &findme(AudacityProject&) - { - return *NyqBench::GetBench(); - } - #ifdef _MSC_VER #define DLL_API _declspec(dllexport) #else @@ -171,6 +186,9 @@ extern "C" // is called by Audacity to initialize/terminate the module int ModuleDispatch(ModuleDispatchTypes type){ switch (type){ + case ModuleInitialize: + RegisterMenuItems(); + break; case AppQuiting: { //It is perfectly OK for gBench to be NULL. //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(&NyqBench::ShowNyqBench), - AudioIONotBusyFlag()) - ) ) - }; -} - //---------------------------------------------------------------------------- // NyqTextCtrl //----------------------------------------------------------------------------