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

Rewrite insertion of menu items by null and Nyquist modules...

... using the new registration system, and without the fragile hacks making
assumptions about the positions of menus within the menu bar.
This commit is contained in:
Paul Licameli
2019-01-05 15:20:28 -05:00
parent baada94567
commit 56cd24a062
7 changed files with 38 additions and 90 deletions

View File

@@ -35,6 +35,7 @@
#include "effects/nyquist/Nyquist.h"
#include "../images/AudacityLogo.xpm"
#include "../../src/commands/CommandContext.h"
#include "../../src/commands/CommandManager.h"
#include "widgets/AudacityMessageBox.h"
#include "NyqBench.h"
@@ -167,8 +168,7 @@ extern "C"
extern int DLL_API ModuleDispatch(ModuleDispatchTypes type);
// ModuleDispatch
// is called by Audacity to initialize/terminmate the module,
// and ask if it has anything for the menus.
// is called by Audacity to initialize/terminate the module
int ModuleDispatch(ModuleDispatchTypes type){
switch (type){
case AppQuiting: {
@@ -181,29 +181,6 @@ extern "C"
}
}
break;
case ProjectInitialized:
case MenusRebuilt: {
AudacityProject *p = GetActiveProject();
wxASSERT(p != NULL);
CommandManager *c = &CommandManager::Get( *p );
wxASSERT(c != NULL);
wxMenuBar * pBar = GetProjectFrame( *p ).GetMenuBar();
wxASSERT(pBar != NULL );
wxMenu * pMenu = pBar->GetMenu( 9 ); // Menu 9 is the Tools Menu.
wxASSERT( pMenu != NULL );
c->SetCurrentMenu(pMenu);
c->AddSeparator();
c->AddItem( *p, wxT("NyqBench"),
XO("&Nyquist Workbench..."),
findme,
static_cast<CommandFunctorPointer>(&NyqBench::ShowNyqBench),
AudioIONotBusyFlag());
c->ClearCurrentMenu();
}
break;
default:
break;
}
@@ -211,6 +188,18 @@ 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
//----------------------------------------------------------------------------