mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-15 07:01:18 +02:00
Modules should register their menu items only after version check
This commit is contained in:
@@ -136,12 +136,38 @@ const wxChar * GetVersionString()
|
|||||||
return AUDACITY_VERSION_STRING;
|
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.
|
// This is the function that connects us to Audacity.
|
||||||
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
|
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
|
||||||
int ModuleDispatch(ModuleDispatchTypes type)
|
int ModuleDispatch(ModuleDispatchTypes type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
|
case ModuleInitialize:
|
||||||
|
RegisterMenuItems();
|
||||||
|
break;
|
||||||
case AppInitialized:
|
case AppInitialized:
|
||||||
break;
|
break;
|
||||||
case AppQuiting:
|
case AppQuiting:
|
||||||
@@ -153,26 +179,6 @@ int ModuleDispatch(ModuleDispatchTypes type)
|
|||||||
return 1;
|
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.
|
//Example code commented out.
|
||||||
#if 0
|
#if 0
|
||||||
// This is an example function to hijack the main panel
|
// This is an example function to hijack the main panel
|
||||||
|
@@ -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
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user