mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 08:27:13 +01:00
Merge remote-tracking branch 'upstream/master' into wx3
This commit is contained in:
@@ -92,6 +92,9 @@ It handles initialization and termination by subclassing wxApp.
|
||||
#include "ondemand/ODManager.h"
|
||||
#include "commands/Keyboard.h"
|
||||
#include "widgets/ErrorDialog.h"
|
||||
#include "prefs/DirectoriesPrefs.h"
|
||||
#include "prefs/SpectrogramSettings.h"
|
||||
#include "prefs/WaveformSettings.h"
|
||||
|
||||
//temporarilly commented out till it is added to all projects
|
||||
//#include "Profiler.h"
|
||||
@@ -123,9 +126,7 @@ It handles initialization and termination by subclassing wxApp.
|
||||
// Windows specific linker control...only needed once so
|
||||
// this is a good place (unless we want to add another file).
|
||||
#if defined(__WXMSW__)
|
||||
//#if wxCHECK_VERSION(3, 0, 2) && !wxCHECK_VERSION(3, 1, 0)
|
||||
#include <wx/init.h>
|
||||
//#endif
|
||||
|
||||
// These lines ensure that Audacity gets WindowsXP themes.
|
||||
// Without them we get the old-style Windows98/2000 look under XP.
|
||||
# if !defined(__WXWINCE__)
|
||||
@@ -209,15 +210,6 @@ It handles initialization and termination by subclassing wxApp.
|
||||
# if defined(EXPERIMENTAL_CRASH_REPORT)
|
||||
# pragma comment(lib, "wxmsw" V "u" D "_qa")
|
||||
# endif
|
||||
# pragma comment(lib, "wxbase" V "u" D)
|
||||
# pragma comment(lib, "wxbase" V "u" D "_net.lib")
|
||||
# pragma comment(lib, "wxmsw" V "u" D "_adv.lib")
|
||||
# pragma comment(lib, "wxmsw" V "u" D "_core.lib")
|
||||
# pragma comment(lib, "wxmsw" V "u" D "_html.lib")
|
||||
# pragma comment(lib, "wxpng" D)
|
||||
# pragma comment(lib, "wxzlib" D)
|
||||
# pragma comment(lib, "wxjpeg" D)
|
||||
# pragma comment(lib, "wxtiff" D)
|
||||
|
||||
# undef V
|
||||
# undef D
|
||||
@@ -231,6 +223,9 @@ It handles initialization and termination by subclassing wxApp.
|
||||
////////////////////////////////////////////////////////////
|
||||
|
||||
DEFINE_EVENT_TYPE(EVT_OPEN_AUDIO_FILE);
|
||||
DEFINE_EVENT_TYPE(EVT_CAPTURE_KEYBOARD);
|
||||
DEFINE_EVENT_TYPE(EVT_RELEASE_KEYBOARD);
|
||||
DEFINE_EVENT_TYPE(EVT_CAPTURE_KEY);
|
||||
|
||||
#ifdef __WXGTK__
|
||||
static void wxOnAssert(const wxChar *fileName, int lineNumber, const wxChar *msg)
|
||||
@@ -249,6 +244,8 @@ static void wxOnAssert(const wxChar *fileName, int lineNumber, const wxChar *msg
|
||||
}
|
||||
#endif
|
||||
|
||||
static wxFrame *gParentFrame = NULL;
|
||||
|
||||
static bool gInited = false;
|
||||
bool gIsQuitting = false;
|
||||
|
||||
@@ -259,8 +256,6 @@ void QuitAudacity(bool bForce)
|
||||
|
||||
gIsQuitting = true;
|
||||
|
||||
wxTheApp->SetExitOnFrameDelete(true);
|
||||
|
||||
// Try to close each open window. If the user hits Cancel
|
||||
// in a Save Changes dialog, don't continue.
|
||||
// BG: unless force is true
|
||||
@@ -295,8 +290,14 @@ void QuitAudacity(bool bForce)
|
||||
}
|
||||
}
|
||||
|
||||
LWSlider::DeleteSharedTipPanel();
|
||||
|
||||
ModuleManager::Get().Dispatch(AppQuiting);
|
||||
|
||||
if (gParentFrame)
|
||||
gParentFrame->Destroy();
|
||||
gParentFrame = NULL;
|
||||
|
||||
#ifdef EXPERIMENTAL_SCOREALIGN
|
||||
CloseScoreAlignDialog();
|
||||
#endif
|
||||
@@ -648,12 +649,12 @@ public:
|
||||
};
|
||||
};
|
||||
|
||||
#if !defined(__WXMAC__) && !defined(__WXMSW__)
|
||||
#ifndef __WXMAC__
|
||||
IMPLEMENT_APP(AudacityApp)
|
||||
/* make the application class known to wxWidgets for dynamic construction */
|
||||
#endif
|
||||
|
||||
#if defined(__WXMAC__) || defined(__WXMSW__)
|
||||
#ifdef __WXMAC__
|
||||
// This should be removed when Lame and FFmpeg support is converted
|
||||
// from loadable libraries to commands.
|
||||
//
|
||||
@@ -668,8 +669,6 @@ IMPLEMENT_APP(AudacityApp)
|
||||
// one tried.
|
||||
IMPLEMENT_APP_NO_MAIN(AudacityApp)
|
||||
IMPLEMENT_WX_THEME_SUPPORT
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (getenv("DYLD_LIBRARY_PATH")) {
|
||||
@@ -678,31 +677,8 @@ int main(int argc, char *argv[])
|
||||
unsetenv("DYLD_LIBRARY_PATH");
|
||||
execve(argv[0], argv, environ);
|
||||
}
|
||||
|
||||
wxDISABLE_DEBUG_SUPPORT();
|
||||
|
||||
return wxEntry(argc, argv);
|
||||
}
|
||||
|
||||
#elif defined(__WXMSW__)
|
||||
|
||||
extern "C" int WINAPI WinMain(HINSTANCE hInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
wxCmdLineArgType WXUNUSED(lpCmdLine),
|
||||
int nCmdShow)
|
||||
{
|
||||
wxDISABLE_DEBUG_SUPPORT();
|
||||
|
||||
// Disable setting of HiDPI aware mode
|
||||
wxMSWDisableSettingHighDPIAware();
|
||||
|
||||
/* NB: We pass NULL in place of lpCmdLine to behave the same as */
|
||||
/* Borland-specific wWinMain() above. If it becomes needed */
|
||||
/* to pass lpCmdLine to wxEntry() here, you'll have to fix */
|
||||
/* wWinMain() above too. */
|
||||
return wxEntry(hInstance, hPrevInstance, NULL, nCmdShow);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __WXMAC__
|
||||
@@ -1012,12 +988,11 @@ void AudacityApp::InitLang( const wxString & lang )
|
||||
wxSetEnv(wxT("LANG"), wxT("en_US.UTF-8"));
|
||||
#endif
|
||||
|
||||
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);
|
||||
if (!lang)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mLocale = new wxLocale(info->Language);
|
||||
#if wxCHECK_VERSION(3,0,0)
|
||||
mLocale = new wxLocale(wxT(""), lang, wxT(""), true);
|
||||
#else
|
||||
mLocale = new wxLocale(wxT(""), lang, wxT(""), true, true);
|
||||
#endif
|
||||
|
||||
for(unsigned int i=0; i<audacityPathList.GetCount(); i++)
|
||||
mLocale->AddCatalogLookupPathPrefix(audacityPathList[i]);
|
||||
@@ -1038,7 +1013,12 @@ void AudacityApp::InitLang( const wxString & lang )
|
||||
//
|
||||
// This must go _after_ creating the wxLocale instance because
|
||||
// creating the wxLocale instance sets the application-wide locale.
|
||||
|
||||
Internat::Init();
|
||||
|
||||
// Some static arrays unconnected with any project want to be informed of language changes.
|
||||
SpectrogramSettings::InvalidateNames();
|
||||
WaveformSettings::InvalidateNames();
|
||||
}
|
||||
|
||||
void AudacityApp::OnFatalException()
|
||||
@@ -1096,16 +1076,16 @@ void AudacityApp::GenerateCrashReport(wxDebugReport::Context ctx)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__WXGTK__)
|
||||
// On wxGTK, there's a focus issue where dialogs do not automatically pass focus
|
||||
// to the first child. This means that you can use the keyboard to navigate within
|
||||
// the dialog. Watching for the ACTIVATE event allows us to set the focus ourselves
|
||||
// when each dialog opens.
|
||||
//
|
||||
// See bug #57
|
||||
//
|
||||
int AudacityApp::FilterEvent(wxEvent & event)
|
||||
{
|
||||
#if !wxCHECK_VERSION(3, 0, 0) && defined(__WXGTK__)
|
||||
// On wxGTK, there's a focus issue where dialogs do not automatically pass focus
|
||||
// to the first child. This means that you can use the keyboard to navigate within
|
||||
// the dialog. Watching for the ACTIVATE event allows us to set the focus ourselves
|
||||
// when each dialog opens.
|
||||
//
|
||||
// See bug #57
|
||||
//
|
||||
if (event.GetEventType() == wxEVT_ACTIVATE)
|
||||
{
|
||||
wxActivateEvent & e = (wxActivateEvent &) event;
|
||||
@@ -1115,11 +1095,10 @@ int AudacityApp::FilterEvent(wxEvent & event)
|
||||
((wxWindow *)e.GetEventObject())->SetFocus();
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
|
||||
return Event_Skip;
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
AudacityApp::AudacityApp()
|
||||
{
|
||||
@@ -1137,9 +1116,6 @@ AudacityApp::AudacityApp()
|
||||
// main frame
|
||||
bool AudacityApp::OnInit()
|
||||
{
|
||||
// Ensure we have an event loop during initialization
|
||||
wxEventLoopGuarantor eventLoop;
|
||||
|
||||
delete wxLog::SetActiveTarget(new AudacityLogger);
|
||||
|
||||
mLocale = NULL;
|
||||
@@ -1150,6 +1126,11 @@ bool AudacityApp::OnInit()
|
||||
mChecker = NULL;
|
||||
mIPCServ = NULL;
|
||||
|
||||
#if defined(__WXGTK__)
|
||||
// Workaround for bug 154 -- initialize to false
|
||||
inKbdHandler = false;
|
||||
#endif
|
||||
|
||||
#if defined(__WXMAC__)
|
||||
// Disable window animation
|
||||
wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
|
||||
@@ -1299,6 +1280,15 @@ bool AudacityApp::OnInit()
|
||||
// If we're waiitng in a dialog before then we can very easily
|
||||
// start multiple instances, defeating the single instance checker.
|
||||
|
||||
|
||||
|
||||
|
||||
//JKC We'd like to initialise the module manager WHILE showing the splash screen.
|
||||
//Can't in wx3.0.1 as MultiDialog interacts poorly with the splash screen. So we do it before.
|
||||
//TODO: Find out why opening a multidialog wrecks the splash screen.
|
||||
//best current guess is that it's something to do with doing a DoModal this early
|
||||
//in the program.
|
||||
|
||||
// Initialize the CommandHandler
|
||||
InitCommandHandler();
|
||||
|
||||
@@ -1308,6 +1298,64 @@ bool AudacityApp::OnInit()
|
||||
// Initialize the ModuleManager, including loading found modules
|
||||
ModuleManager::Get().Initialize(*mCmdHandler);
|
||||
|
||||
#if !wxCHECK_VERSION(3, 0, 0)
|
||||
FinishInits();
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if wxCHECK_VERSION(3, 0, 0)
|
||||
#include <wx/evtloop.h>
|
||||
static bool bInitsDone = false;
|
||||
void AudacityApp::OnEventLoopEnter(wxEventLoopBase * pLoop)
|
||||
{
|
||||
if( !pLoop->IsMain() )
|
||||
return;
|
||||
if (bInitsDone)
|
||||
return;
|
||||
bInitsDone = true;
|
||||
FinishInits();
|
||||
}
|
||||
#endif
|
||||
|
||||
// JKC: I've split 'FinishInits()' from 'OnInit()', so that
|
||||
// we can have a real event loop running. We could (I think)
|
||||
// put everything that is in OnInit() in here.
|
||||
// This change was to support wxWidgets 3.0.0 and allow us
|
||||
// to show a dialog (for module loading) during initialisation.
|
||||
// without it messing up the splash screen.
|
||||
// Hasn't actually fixed that yet, but is addressing the point
|
||||
// they make in their release notes.
|
||||
void AudacityApp::FinishInits()
|
||||
{
|
||||
|
||||
// Until we are ready for wxWidgets 3.x, put a warning dialog up.
|
||||
// Our problem is that distros may ship with 3.x builds as default.
|
||||
// We are saying, don't.
|
||||
//
|
||||
// wx3 is Ok for experimental builds.
|
||||
//
|
||||
// Deliberately not translated. People can search for the english error
|
||||
// text for more details. This error will only show in versions
|
||||
// of Audacity that were incorrectly built.
|
||||
//
|
||||
// The intention was to do this, if needed, as part of the splash screen.
|
||||
// However the splash screen is one of the things broken by wx3.0
|
||||
// changes in OnInit handling. We also can't put this dialog earlier.
|
||||
#if wxCHECK_VERSION(3, 0, 0)
|
||||
ShowErrorDialog( NULL,
|
||||
wxT("Bad Version"),
|
||||
wxT(
|
||||
"Audacity should be built with wxWidgets 2.8.12.\n\n This version \
|
||||
of Audacity (") AUDACITY_VERSION_STRING wxT(") is using ") wxVERSION_STRING \
|
||||
wxT( ".\n We're not ready for that version of wxWidgets yet.\n\n \
|
||||
Click the 'Help' button for known issues."),
|
||||
wxT("http://wiki.audacityteam.org/wiki/Incorrect_wxWidgets_Version"),
|
||||
true);
|
||||
#endif
|
||||
|
||||
|
||||
// Parse command line and handle options that might require
|
||||
// immediate exit...no need to initialize all of the audio
|
||||
// stuff to display the version string.
|
||||
@@ -1357,6 +1405,9 @@ bool AudacityApp::OnInit()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// No Splash screen on wx3 whislt we sort out the problem
|
||||
// with showing a dialog AND a splash screen during inits.
|
||||
#if !wxCHECK_VERSION(3, 0, 0)
|
||||
// BG: Create a temporary window to set as the top window
|
||||
wxImage logoimage((const char **) AudacityLogoWithName_xpm);
|
||||
logoimage.Rescale(logoimage.GetWidth() / 2, logoimage.GetHeight() / 2);
|
||||
@@ -1373,7 +1424,7 @@ bool AudacityApp::OnInit()
|
||||
wxSTAY_ON_TOP);
|
||||
temporarywindow->SetTitle(_("Audacity is starting up..."));
|
||||
SetTopWindow(temporarywindow);
|
||||
wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI);
|
||||
#endif
|
||||
|
||||
//JKC: Would like to put module loading here.
|
||||
|
||||
@@ -1403,10 +1454,15 @@ bool AudacityApp::OnInit()
|
||||
mRecentFiles->UseMenu(recentMenu);
|
||||
mRecentFiles->AddFilesToMenu(recentMenu);
|
||||
|
||||
SetExitOnFrameDelete(false);
|
||||
// This invisibale frame will be the "root" of all other frames and will
|
||||
// become the active frame when no projects are open.
|
||||
gParentFrame = new wxFrame(NULL, -1, wxEmptyString, wxPoint(0, 0), wxSize(0, 0), 0);
|
||||
|
||||
#endif //__WXMAC__
|
||||
|
||||
SetExitOnFrameDelete(true);
|
||||
|
||||
|
||||
AudacityProject *project = CreateNewAudacityProject();
|
||||
mCmdHandler->SetProject(project);
|
||||
wxWindow * pWnd = MakeHijackPanel() ;
|
||||
@@ -1418,8 +1474,11 @@ bool AudacityApp::OnInit()
|
||||
pWnd->Show( true );
|
||||
}
|
||||
|
||||
|
||||
#if !wxCHECK_VERSION(3, 0, 0)
|
||||
temporarywindow->Show(false);
|
||||
delete temporarywindow;
|
||||
#endif
|
||||
|
||||
if( project->mShowSplashScreen )
|
||||
project->OnHelpWelcome();
|
||||
@@ -1447,7 +1506,7 @@ bool AudacityApp::OnInit()
|
||||
DirManager::SetDontDeleteTempFiles();
|
||||
delete parser;
|
||||
QuitAudacity(true);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1460,7 +1519,7 @@ bool AudacityApp::OnInit()
|
||||
delete parser;
|
||||
|
||||
RunBenchmark(NULL);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (size_t i = 0, cnt = parser->GetParamCount(); i < cnt; i++)
|
||||
@@ -1479,8 +1538,6 @@ bool AudacityApp::OnInit()
|
||||
|
||||
mTimer.SetOwner(this, kAudacityAppTimerID);
|
||||
mTimer.Start(200);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void AudacityApp::InitCommandHandler()
|
||||
@@ -1556,8 +1613,11 @@ bool AudacityApp::InitTempDir()
|
||||
// Failed
|
||||
wxMessageBox(_("Audacity could not find a place to store temporary files.\nPlease enter an appropriate directory in the preferences dialog."));
|
||||
|
||||
PrefsDialog dialog(NULL);
|
||||
dialog.ShowTempDirPage();
|
||||
// Only want one page of the preferences
|
||||
DirectoriesPrefsFactory directoriesPrefsFactory;
|
||||
PrefsDialog::Factories factories;
|
||||
factories.push_back(&directoriesPrefsFactory);
|
||||
GlobalPrefsDialog dialog(NULL, factories);
|
||||
dialog.ShowModal();
|
||||
|
||||
wxMessageBox(_("Audacity is now going to exit. Please launch Audacity again to use the new temporary directory."));
|
||||
@@ -2083,7 +2143,7 @@ void AudacityApp::OnMenuPreferences(wxCommandEvent & event)
|
||||
// all platforms.
|
||||
|
||||
if(gAudacityProjects.GetCount() == 0) {
|
||||
PrefsDialog dialog(NULL /* parent */ );
|
||||
GlobalPrefsDialog dialog(NULL /* parent */ );
|
||||
dialog.ShowModal();
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user