void EditToolBar::ForAllButtons(int Action) { AudacityProject *p; CommandManager* cm = nullptr; if( Action & ETBActEnableDisable ){ p = GetActiveProject(); if (!p) return; cm = p->GetCommandManager(); if (!cm) return; #ifdef OPTION_SYNC_LOCK_BUTTON bool bSyncLockTracks; gPrefs->Read(wxT("/GUI/SyncLockTracks"), &bSyncLockTracks, false); if (bSyncLockTracks) mButtons[ETBSyncLockID]->PushDown(); else mButtons[ETBSyncLockID]->PopUp(); #endif } for (const auto &entry : EditToolbarButtonList) { #if wxUSE_TOOLTIPS if( Action & ETBActTooltips ){ TranslatedInternalString command{ entry.commandName, wxGetTranslation(entry.untranslatedLabel) }; ToolBar::SetButtonToolTip( *mButtons[entry.tool], &command, 1u ); } #endif if (cm) { mButtons[entry.tool]->SetEnabled(cm->GetEnabled(entry.commandName)); } } }
bool GetAllMenuCommands::Apply(CommandExecutionContext context) { bool showStatus = GetBool(wxT("ShowStatus")); wxArrayString names; CommandManager *cmdManager = context.GetProject()->GetCommandManager(); cmdManager->GetAllCommandNames(names, false); wxArrayString::iterator iter; for (iter = names.begin(); iter != names.end(); ++iter) { wxString name = *iter; wxString out = name; if (showStatus) { out += wxT("\t"); out += cmdManager->GetEnabled(name) ? wxT("Enabled") : wxT("Disabled"); } Status(out); } return true; }