2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
AudacityApp.h
|
|
|
|
|
|
|
|
Dominic Mazzoni
|
|
|
|
|
|
|
|
This is the main source file for Audacity which handles
|
|
|
|
initialization and termination by subclassing wxApp.
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef __AUDACITY_APP__
|
|
|
|
#define __AUDACITY_APP__
|
|
|
|
|
|
|
|
#include "Audacity.h"
|
2019-03-07 19:50:22 +00:00
|
|
|
#include "audacity/Types.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-11-11 17:27:44 +00:00
|
|
|
#include "Experimental.h"
|
|
|
|
|
2016-04-10 03:02:25 +00:00
|
|
|
#include "MemoryX.h"
|
2018-11-14 20:23:25 +00:00
|
|
|
#include <wx/app.h> // to inherit
|
2010-01-23 19:44:49 +00:00
|
|
|
#include <wx/dir.h>
|
|
|
|
#include <wx/snglinst.h>
|
2011-03-30 14:30:58 +00:00
|
|
|
#include <wx/timer.h>
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
#include "widgets/FileHistory.h"
|
2011-03-29 23:39:00 +00:00
|
|
|
#include "ondemand/ODTaskThread.h"
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-18 10:06:28 +00:00
|
|
|
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
|
|
|
#include <wx/debugrpt.h>
|
|
|
|
#endif
|
|
|
|
|
2018-11-15 23:05:46 +00:00
|
|
|
class wxSocketEvent;
|
|
|
|
class wxSocketServer;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
class IPCServ;
|
|
|
|
class Importer;
|
|
|
|
class CommandHandler;
|
|
|
|
class AppCommandEvent;
|
2013-10-23 17:00:28 +00:00
|
|
|
class AudacityLogger;
|
2016-08-15 14:51:16 +00:00
|
|
|
class AudacityProject;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void SaveWindowSize();
|
|
|
|
|
|
|
|
void QuitAudacity(bool bForce);
|
|
|
|
void QuitAudacity();
|
|
|
|
|
|
|
|
extern bool gIsQuitting;
|
|
|
|
|
2018-02-17 03:25:00 +00:00
|
|
|
// An event emitted by the application whenever the global clipboard's
|
|
|
|
// contents change.
|
|
|
|
wxDECLARE_EXPORTED_EVENT( AUDACITY_DLL_API,
|
|
|
|
EVT_CLIPBOARD_CHANGE, wxCommandEvent);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
// Asynchronous open
|
|
|
|
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_OPEN_AUDIO_FILE, -1);
|
|
|
|
|
2011-03-29 23:39:00 +00:00
|
|
|
class BlockFile;
|
2016-08-15 14:51:16 +00:00
|
|
|
class AliasBlockFile;
|
2011-03-29 23:39:00 +00:00
|
|
|
|
2016-02-24 06:06:39 +00:00
|
|
|
class AudacityApp final : public wxApp {
|
2010-01-23 19:44:49 +00:00
|
|
|
public:
|
2015-04-18 10:06:28 +00:00
|
|
|
AudacityApp();
|
2016-04-10 03:02:25 +00:00
|
|
|
~AudacityApp();
|
2016-02-24 06:06:47 +00:00
|
|
|
bool OnInit(void) override;
|
|
|
|
int OnExit(void) override;
|
|
|
|
void OnFatalException() override;
|
2016-11-08 15:10:50 +00:00
|
|
|
bool OnExceptionInMainLoop() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2018-04-07 19:28:27 +00:00
|
|
|
int FilterEvent(wxEvent & event) override;
|
2013-10-11 20:00:47 +00:00
|
|
|
|
2019-03-27 16:14:59 +00:00
|
|
|
// If no input language given, defaults first to choice in preferences, then
|
|
|
|
// to system language.
|
2016-01-27 01:09:54 +00:00
|
|
|
// Returns the language actually used which is not lang if lang cannot be found.
|
2019-03-27 16:14:59 +00:00
|
|
|
wxString InitLang( wxString lang = {} );
|
|
|
|
|
|
|
|
// If no input language given, defaults to system language.
|
|
|
|
// Returns the language actually used which is not lang if lang cannot be found.
|
|
|
|
wxString SetLang( const wxString & lang );
|
|
|
|
|
|
|
|
// Returns the last language code that was set
|
|
|
|
wxString GetLang() const;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
// These are currently only used on Mac OS, where it's
|
|
|
|
// possible to have a menu bar but no windows open. It doesn't
|
|
|
|
// hurt any other platforms, though.
|
|
|
|
void OnMenuAbout(wxCommandEvent & event);
|
|
|
|
void OnMenuNew(wxCommandEvent & event);
|
|
|
|
void OnMenuOpen(wxCommandEvent & event);
|
|
|
|
void OnMenuPreferences(wxCommandEvent & event);
|
|
|
|
void OnMenuExit(wxCommandEvent & event);
|
|
|
|
|
2016-10-03 18:29:42 +00:00
|
|
|
void OnQueryEndSession(wxCloseEvent & event);
|
2010-01-23 19:44:49 +00:00
|
|
|
void OnEndSession(wxCloseEvent & event);
|
|
|
|
|
|
|
|
// Most Recently Used File support (for all platforms).
|
|
|
|
void OnMRUClear(wxCommandEvent &event);
|
|
|
|
void OnMRUFile(wxCommandEvent &event);
|
|
|
|
// Backend for above - returns true for success, false for failure
|
2019-03-07 19:50:22 +00:00
|
|
|
bool MRUOpen(const FilePath &fileName);
|
2016-12-20 21:15:20 +00:00
|
|
|
// A wrapper of the above that does not throw
|
|
|
|
bool SafeMRUOpen(const wxString &fileName);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
void OnReceiveCommand(AppCommandEvent &event);
|
|
|
|
|
2016-04-20 19:34:49 +00:00
|
|
|
void OnKeyDown(wxKeyEvent &event);
|
|
|
|
|
2011-03-29 23:39:00 +00:00
|
|
|
void OnTimer(wxTimerEvent & event);
|
|
|
|
|
2015-01-09 07:47:28 +00:00
|
|
|
// IPC communication
|
|
|
|
void OnServerEvent(wxSocketEvent & evt);
|
|
|
|
void OnSocketEvent(wxSocketEvent & evt);
|
|
|
|
|
2011-03-29 23:39:00 +00:00
|
|
|
/** \brief Mark playback as having missing aliased blockfiles
|
|
|
|
*
|
|
|
|
* Playback will continue, but the missing files will be silenced
|
|
|
|
* ShouldShowMissingAliasedFileWarning can be called to determine
|
|
|
|
* if the user should be notified
|
|
|
|
*/
|
2016-08-15 14:51:16 +00:00
|
|
|
void MarkAliasedFilesMissingWarning(const AliasBlockFile *b);
|
2011-03-29 23:39:00 +00:00
|
|
|
|
|
|
|
/** \brief Changes the behavior of missing aliased blockfiles warnings
|
|
|
|
*/
|
|
|
|
void SetMissingAliasedFileWarningShouldShow(bool b);
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2011-03-29 23:39:00 +00:00
|
|
|
/** \brief Returns true if the user should be notified of missing alias warnings
|
|
|
|
*/
|
|
|
|
bool ShouldShowMissingAliasedFileWarning();
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
// In response to Apple Events
|
2016-02-24 06:06:47 +00:00
|
|
|
void MacOpenFile(const wxString &fileName) override;
|
|
|
|
void MacPrintFile(const wxString &fileName) override;
|
|
|
|
void MacNewFile() override;
|
2010-01-23 19:44:49 +00:00
|
|
|
#endif
|
|
|
|
|
2013-02-20 23:42:58 +00:00
|
|
|
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__)
|
|
|
|
void AssociateFileTypes();
|
|
|
|
#endif
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
/** \brief A list of directories that should be searched for Audacity files
|
2014-06-03 20:30:19 +00:00
|
|
|
* (plug-ins, help files, etc.).
|
2010-01-23 19:44:49 +00:00
|
|
|
*
|
|
|
|
* On Unix this will include the directory Audacity was installed into,
|
|
|
|
* plus the current user's .audacity-data/Plug-Ins directory. Additional
|
|
|
|
* directories can be specified using the AUDACITY_PATH environment
|
|
|
|
* variable. On Windows or Mac OS, this will include the directory
|
|
|
|
* which contains the Audacity program. */
|
2019-03-07 19:50:22 +00:00
|
|
|
FilePaths audacityPathList;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
/** \brief Default temp directory */
|
|
|
|
wxString defaultTempDir;
|
|
|
|
|
|
|
|
// Useful functions for working with search paths
|
2019-03-07 19:50:22 +00:00
|
|
|
static void AddUniquePathToPathList(const FilePath &path,
|
|
|
|
FilePaths &pathList);
|
2016-02-23 02:18:11 +00:00
|
|
|
static void AddMultiPathsToPathList(const wxString &multiPathString,
|
2019-03-07 19:50:22 +00:00
|
|
|
FilePaths &pathList);
|
2010-01-23 19:44:49 +00:00
|
|
|
static void FindFilesInPathList(const wxString & pattern,
|
2019-03-07 19:50:22 +00:00
|
|
|
const FilePaths & pathList,
|
|
|
|
FilePaths &results,
|
2010-01-23 19:44:49 +00:00
|
|
|
int flags = wxDIR_FILES);
|
2015-12-26 14:56:47 +00:00
|
|
|
static bool IsTempDirectoryNameOK( const wxString & Name );
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-04-08 08:32:11 +00:00
|
|
|
FileHistory *GetRecentFiles() {return mRecentFiles.get();}
|
2019-03-07 19:50:22 +00:00
|
|
|
void AddFileToHistory(const FilePath & name);
|
2010-01-23 19:44:49 +00:00
|
|
|
bool GetWindowRectAlreadySaved()const {return mWindowRectAlreadySaved;}
|
|
|
|
void SetWindowRectAlreadySaved(bool alreadySaved) {mWindowRectAlreadySaved = alreadySaved;}
|
|
|
|
|
2013-10-23 17:00:28 +00:00
|
|
|
AudacityLogger *GetLogger();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2015-04-18 10:06:28 +00:00
|
|
|
#if defined(EXPERIMENTAL_CRASH_REPORT)
|
|
|
|
void GenerateCrashReport(wxDebugReport::Context ctx);
|
|
|
|
#endif
|
|
|
|
|
2017-01-11 16:45:41 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
|
|
|
|
void MacActivateApp();
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2018-01-10 11:26:29 +00:00
|
|
|
// Set and Get values of the version major/minor/micro keys in audacity.cfg when Audacity first opens
|
|
|
|
void SetVersionKeysInit( int major, int minor, int micro)
|
|
|
|
{ mVersionMajorKeyInit = major; mVersionMinorKeyInit = minor; mVersionMicroKeyInit = micro;}
|
|
|
|
void GetVersionKeysInit( int& major, int& minor, int& micro) const
|
|
|
|
{ major = mVersionMajorKeyInit; minor = mVersionMinorKeyInit; micro = mVersionMicroKeyInit;}
|
|
|
|
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
private:
|
2016-04-08 08:32:11 +00:00
|
|
|
std::unique_ptr<CommandHandler> mCmdHandler;
|
|
|
|
std::unique_ptr<FileHistory> mRecentFiles;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-04-08 08:32:11 +00:00
|
|
|
std::unique_ptr<wxLocale> mLocale;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-04-08 08:32:11 +00:00
|
|
|
std::unique_ptr<wxSingleInstanceChecker> mChecker;
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2014-12-04 07:15:58 +00:00
|
|
|
wxTimer mTimer;
|
|
|
|
|
2011-03-29 23:39:00 +00:00
|
|
|
bool m_aliasMissingWarningShouldShow;
|
2016-08-15 14:51:16 +00:00
|
|
|
std::weak_ptr< AudacityProject > m_LastMissingBlockFileProject;
|
|
|
|
wxString m_LastMissingBlockFilePath;
|
2014-06-03 20:30:19 +00:00
|
|
|
|
2011-03-29 23:39:00 +00:00
|
|
|
ODLock m_LastMissingBlockFileLock;
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
void InitCommandHandler();
|
|
|
|
|
|
|
|
bool InitTempDir();
|
2016-02-23 02:18:11 +00:00
|
|
|
bool CreateSingleInstanceChecker(const wxString &dir);
|
2010-01-23 19:44:49 +00:00
|
|
|
|
2016-04-10 03:02:25 +00:00
|
|
|
std::unique_ptr<wxCmdLineParser> ParseCommandLine();
|
2010-01-23 19:44:49 +00:00
|
|
|
|
|
|
|
bool mWindowRectAlreadySaved;
|
|
|
|
|
2015-01-09 07:47:28 +00:00
|
|
|
#if defined(__WXMSW__)
|
2016-04-08 08:32:11 +00:00
|
|
|
std::unique_ptr<IPCServ> mIPCServ;
|
2015-01-09 07:47:28 +00:00
|
|
|
#else
|
2016-04-08 08:32:11 +00:00
|
|
|
std::unique_ptr<wxSocketServer> mIPCServ;
|
2015-01-09 07:47:28 +00:00
|
|
|
#endif
|
2015-01-07 19:39:44 +00:00
|
|
|
|
2018-01-10 11:26:29 +00:00
|
|
|
// values of the version major/minor/micro keys in audacity.cfg when Audacity first opens
|
|
|
|
int mVersionMajorKeyInit{};
|
|
|
|
int mVersionMinorKeyInit{};
|
|
|
|
int mVersionMicroKeyInit{};
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
public:
|
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
|
|
|
extern AudacityApp & wxGetApp();
|
|
|
|
|
|
|
|
#endif
|