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 "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 725 of file AudacityApp.cpp.

Referenced by AudacityApp::CreateSingleInstanceChecker().

#define ID_IPC_SOCKET   6201

Definition at line 726 of file AudacityApp.cpp.

#define ID_RECENT_CLEAR   6100

Definition at line 720 of file AudacityApp.cpp.

Referenced by AudacityApp::OnInit().

#define ID_RECENT_FIRST   6101

Definition at line 721 of file AudacityApp.cpp.

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

#define ID_RECENT_LAST   6112

Definition at line 722 of file AudacityApp.cpp.

Referenced by AudacityApp::OnInit().

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

Definition at line 729 of file AudacityApp.cpp.

#define WL (   lang,
  sublang 
)

Definition at line 975 of file AudacityApp.cpp.

Function Documentation

DEFINE_EVENT_TYPE ( EVT_OPEN_AUDIO_FILE  )

Custom events.

void QuitAudacity ( bool  bForce)

Definition at line 267 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().

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

Definition at line 335 of file AudacityApp.cpp.

References QuitAudacity().

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

Definition at line 340 of file AudacityApp.cpp.

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

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

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

Definition at line 1712 of file AudacityApp.cpp.

References name.

Referenced by AudacityApp::InitTempDir().

1712  {
1713  // don't allow path of "".
1714  if( dir.IsEmpty() )
1715  return;
1716  if( wxDirExists( dir ) ){
1717  result = dir;
1718  return;
1719  }
1720  // Use '/' so that this works on Mac and Windows alike.
1721  wxFileName name( dir + "/junkname.cfg" );
1722  if( name.Mkdir( wxS_DIR_DEFAULT , wxPATH_MKDIR_FULL ) )
1723  result = dir;
1724 }
const wxChar * name
Definition: Distortion.cpp:94
wxDEFINE_EVENT ( EVT_LANGUAGE_CHANGE  ,
wxCommandEvent   
)

Variable Documentation

bool gInited = false
static

Definition at line 264 of file AudacityApp.cpp.

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

bool gIsQuitting = false
wxArrayString ofqueue
static

Definition at line 594 of file AudacityApp.cpp.