Audacity  2.2.2
Classes | Macros | Functions | Variables
AudacityApp.cpp File Reference
#include "Audacity.h"
#include "AudacityApp.h"
#include "TranslatableStringArray.h"
#include <wx/defs.h>
#include <wx/app.h>
#include <wx/bitmap.h>
#include <wx/docview.h>
#include <wx/event.h>
#include <wx/ipc.h>
#include <wx/log.h>
#include <wx/window.h>
#include <wx/intl.h>
#include <wx/menu.h>
#include <wx/snglinst.h>
#include <wx/splash.h>
#include <wx/stdpaths.h>
#include <wx/sysopt.h>
#include <wx/fontmap.h>
#include <wx/fs_zip.h>
#include <wx/image.h>
#include <wx/dir.h>
#include <wx/file.h>
#include <wx/filename.h>
#include "AudacityException.h"
#include "AudacityLogger.h"
#include "AboutDialog.h"
#include "AColor.h"
#include "AudioIO.h"
#include "Benchmark.h"
#include "DirManager.h"
#include "commands/CommandHandler.h"
#include "commands/AppCommandEvent.h"
#include "commands/CommandContext.h"
#include "effects/Contrast.h"
#include "widgets/ASlider.h"
#include "FFmpeg.h"
#include "Internat.h"
#include "LangChoice.h"
#include "Languages.h"
#include "PluginManager.h"
#include "Prefs.h"
#include "Project.h"
#include "Screenshot.h"
#include "Sequence.h"
#include "WaveTrack.h"
#include "prefs/PrefsDialog.h"
#include "Theme.h"
#include "PlatformCompatibility.h"
#include "FileNames.h"
#include "AutoRecovery.h"
#include "SplashDialog.h"
#include "FFT.h"
#include "BlockFile.h"
#include "ondemand/ODManager.h"
#include "commands/Keyboard.h"
#include "widgets/ErrorDialog.h"
#include "prefs/DirectoriesPrefs.h"
#include "tracks/ui/Scrubbing.h"
#include "ModuleManager.h"
#include "import/Import.h"
#include "Experimental.h"
#include "../images/AudacityLogoWithName.xpm"

Go to the source code of this file.

Classes

class  IPCConn
 
class  IPCServ
 

Macros

#define IPC_APPL   wxT("audacity")
 
#define IPC_TOPIC   wxT("System")
 
#define ID_RECENT_CLEAR   6100
 
#define ID_RECENT_FIRST   6101
 
#define ID_RECENT_LAST   6112
 
#define ID_IPC_SERVER   6200
 
#define ID_IPC_SOCKET   6201
 
#define kAudacityAppTimerID   0
 
#define WL(lang, sublang)
 

Functions

 DEFINE_EVENT_TYPE (EVT_OPEN_AUDIO_FILE)
 Custom events. More...
 
 wxDEFINE_EVENT (EVT_LANGUAGE_CHANGE, wxCommandEvent)
 
void QuitAudacity (bool bForce)
 
void QuitAudacity ()
 
void SaveWindowSize ()
 
void SetToExtantDirectory (wxString &result, const wxString &dir)
 

Variables

static bool gInited = false
 
bool gIsQuitting = false
 
static wxArrayString ofqueue
 

Macro Definition Documentation

#define ID_IPC_SERVER   6200

Definition at line 726 of file AudacityApp.cpp.

Referenced by AudacityApp::CreateSingleInstanceChecker().

#define ID_IPC_SOCKET   6201

Definition at line 727 of file AudacityApp.cpp.

#define ID_RECENT_CLEAR   6100

Definition at line 721 of file AudacityApp.cpp.

Referenced by AudacityApp::OnInit().

#define ID_RECENT_FIRST   6101

Definition at line 722 of file AudacityApp.cpp.

Referenced by AudacityApp::OnInit(), and AudacityApp::OnMRUFile().

#define ID_RECENT_LAST   6112

Definition at line 723 of file AudacityApp.cpp.

Referenced by AudacityApp::OnInit().

#define IPC_APPL   wxT("audacity")
#define IPC_TOPIC   wxT("System")
#define kAudacityAppTimerID   0

Definition at line 730 of file AudacityApp.cpp.

#define WL (   lang,
  sublang 
)

Definition at line 976 of file AudacityApp.cpp.

Function Documentation

DEFINE_EVENT_TYPE ( EVT_OPEN_AUDIO_FILE  )

Custom events.

void QuitAudacity ( bool  bForce)

Definition at line 268 of file AudacityApp.cpp.

References AppQuiting, CloseScoreAlignDialog(), CloseScreenshotTools(), AudacityProject::DeleteClipboard(), ModuleManager::Dispatch(), gAudacityProjects, ModuleManager::Get(), ODManager::Quit(), and SaveWindowSize().

Referenced by AudacityProject::OnCloseWindow(), AudacityProject::OnExit(), AudacityApp::OnInit(), AudacityApp::OnMenuExit(), AudacityProject::OnTimerRecord(), and QuitAudacity().

269 {
270  if (gIsQuitting)
271  return;
272 
273  gIsQuitting = true;
274 
275  wxTheApp->SetExitOnFrameDelete(true);
276 
277  // Try to close each open window. If the user hits Cancel
278  // in a Save Changes dialog, don't continue.
279  // BG: unless force is true
280 
281  // BG: Are there any projects open?
282  //- if (!gAudacityProjects.IsEmpty())
283 /*start+*/
284  if (gAudacityProjects.empty())
285  {
286 #ifdef __WXMAC__
288 #endif
289  }
290  else
291 /*end+*/
292  {
293  SaveWindowSize();
294  while (gAudacityProjects.size())
295  {
296  // Closing the project has global side-effect
297  // of deletion from gAudacityProjects
298  if (bForce)
299  {
300  gAudacityProjects[0]->Close(true);
301  }
302  else
303  {
304  if (!gAudacityProjects[0]->Close())
305  {
306  gIsQuitting = false;
307  return;
308  }
309  }
310  }
311  }
312 
314 
315 #ifdef EXPERIMENTAL_SCOREALIGN
317 #endif
319 
320  //release ODManager Threads
321  ODManager::Quit();
322 
323  //print out profile if we have one by deleting it
324  //temporarilly commented out till it is added to all projects
325  //DELETE Profiler::Instance();
326 
327  //remove our logger
328  std::unique_ptr<wxLog>{ wxLog::SetActiveTarget(NULL) }; // DELETE
329 
330  if (bForce)
331  {
332  wxExit();
333  }
334 }
static ModuleManager & Get()
static void Quit()
Kills the ODMananger Thread.
Definition: ODManager.cpp:363
void SaveWindowSize()
AProjectArray gAudacityProjects
Definition: Project.cpp:303
int Dispatch(ModuleDispatchTypes type)
void CloseScreenshotTools()
Definition: Screenshot.cpp:128
void CloseScoreAlignDialog()
bool gIsQuitting
static void DeleteClipboard()
Definition: Project.cpp:4888
void QuitAudacity ( )

Definition at line 336 of file AudacityApp.cpp.

References QuitAudacity().

337 {
338  QuitAudacity(false);
339 }
void QuitAudacity(bool bForce)
void SaveWindowSize ( )

Definition at line 341 of file AudacityApp.cpp.

References gAudacityProjects, GetDefaultWindowRect(), AudacityProject::GetNormalizedWindowState(), gPrefs, AudacityApp::SetWindowRectAlreadySaved(), and wxGetApp().

Referenced by AudacityProject::OnCloseWindow(), and QuitAudacity().

342 {
343  if (wxGetApp().GetWindowRectAlreadySaved())
344  {
345  return;
346  }
347  bool validWindowForSaveWindowSize = FALSE;
348  AudacityProject * validProject = NULL;
349  bool foundIconizedProject = FALSE;
350  size_t numProjects = gAudacityProjects.size();
351  for (size_t i = 0; i < numProjects; i++)
352  {
353  if (!gAudacityProjects[i]->IsIconized()) {
354  validWindowForSaveWindowSize = TRUE;
355  validProject = gAudacityProjects[i].get();
356  i = numProjects;
357  }
358  else
359  foundIconizedProject = TRUE;
360 
361  }
362  if (validWindowForSaveWindowSize)
363  {
364  wxRect windowRect = validProject->GetRect();
365  wxRect normalRect = validProject->GetNormalizedWindowState();
366  bool wndMaximized = validProject->IsMaximized();
367  gPrefs->Write(wxT("/Window/X"), windowRect.GetX());
368  gPrefs->Write(wxT("/Window/Y"), windowRect.GetY());
369  gPrefs->Write(wxT("/Window/Width"), windowRect.GetWidth());
370  gPrefs->Write(wxT("/Window/Height"), windowRect.GetHeight());
371  gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
372  gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
373  gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
374  gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
375  gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
376  gPrefs->Write(wxT("/Window/Iconized"), FALSE);
377  }
378  else
379  {
380  if (foundIconizedProject) {
381  validProject = gAudacityProjects[0].get();
382  bool wndMaximized = validProject->IsMaximized();
383  wxRect normalRect = validProject->GetNormalizedWindowState();
384  // store only the normal rectangle because the itemized rectangle
385  // makes no sense for an opening project window
386  gPrefs->Write(wxT("/Window/X"), normalRect.GetX());
387  gPrefs->Write(wxT("/Window/Y"), normalRect.GetY());
388  gPrefs->Write(wxT("/Window/Width"), normalRect.GetWidth());
389  gPrefs->Write(wxT("/Window/Height"), normalRect.GetHeight());
390  gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
391  gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
392  gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
393  gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
394  gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
395  gPrefs->Write(wxT("/Window/Iconized"), TRUE);
396  }
397  else {
398  // this would be a very strange case that might possibly occur on the Mac
399  // Audacity would have to be running with no projects open
400  // in this case we are going to write only the default values
401  wxRect defWndRect;
402  GetDefaultWindowRect(&defWndRect);
403  gPrefs->Write(wxT("/Window/X"), defWndRect.GetX());
404  gPrefs->Write(wxT("/Window/Y"), defWndRect.GetY());
405  gPrefs->Write(wxT("/Window/Width"), defWndRect.GetWidth());
406  gPrefs->Write(wxT("/Window/Height"), defWndRect.GetHeight());
407  gPrefs->Write(wxT("/Window/Maximized"), FALSE);
408  gPrefs->Write(wxT("/Window/Normal_X"), defWndRect.GetX());
409  gPrefs->Write(wxT("/Window/Normal_Y"), defWndRect.GetY());
410  gPrefs->Write(wxT("/Window/Normal_Width"), defWndRect.GetWidth());
411  gPrefs->Write(wxT("/Window/Normal_Height"), defWndRect.GetHeight());
412  gPrefs->Write(wxT("/Window/Iconized"), FALSE);
413  }
414  }
415  gPrefs->Flush();
417 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AProjectArray gAudacityProjects
Definition: Project.cpp:303
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
void SetWindowRectAlreadySaved(bool alreadySaved)
Definition: AudacityApp.h:157
void GetDefaultWindowRect(wxRect *defRect)
Definition: Project.cpp:623
wxRect GetNormalizedWindowState() const
Definition: Project.h:711
AudacityApp & wxGetApp()
void SetToExtantDirectory ( wxString &  result,
const wxString &  dir 
)

Definition at line 1720 of file AudacityApp.cpp.

References name.

Referenced by AudacityApp::InitTempDir().

1720  {
1721  // don't allow path of "".
1722  if( dir.IsEmpty() )
1723  return;
1724  if( wxDirExists( dir ) ){
1725  result = dir;
1726  return;
1727  }
1728  // Use '/' so that this works on Mac and Windows alike.
1729  wxFileName name( dir + "/junkname.cfg" );
1730  if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1731  result = dir;
1732 }
const wxChar * name
Definition: Distortion.cpp:94
wxDEFINE_EVENT ( EVT_LANGUAGE_CHANGE  ,
wxCommandEvent   
)

Variable Documentation

bool gInited = false
static

Definition at line 265 of file AudacityApp.cpp.

Referenced by AudacityApp::OnInit(), and AudacityApp::OnTimer().

bool gIsQuitting = false
wxArrayString ofqueue
static

Definition at line 595 of file AudacityApp.cpp.