bool emulatorApp::OnInit() { if (!wxApp::OnInit()) return false; int orig_argc = argc; char** new_argv = (char**) malloc(argc*sizeof(char*)); for (int i = 0; i < argc; i++) { wxString tmp(argv[i]); const char* tmp_c = tmp.mb_str(wxConvLibc); new_argv[i] = (char*) malloc((strlen(tmp_c)+2)*sizeof(char)); strcpy(new_argv[i], tmp_c); } glutInit(&argc, new_argv); //Supposed to be the unaltered int* argc/char** argv, but wxwidgets insists on wxChar everywhere for (int i = 0; i < orig_argc; i++) free(new_argv[i]); free(new_argv); config = new emulationConfig(argc-1, ((wxChar**)argv+1)); //in a specific MinGW/library configuration, argv+1 is ambigous. argv should be wxChar**, who knew? config->print(); masterWindow *master = new masterWindow(this, wxPoint(50, 50)); master->Show(true); SetTopWindow(master); SetExitOnFrameDelete(true); setFreeglutManager(new freeglut()); getFreeglutManager()->Run(); environment = config->createEmulation(); return true; }
MyDllApp::MyDllApp() { // Keep the wx "main" thread running even without windows. This greatly // simplifies threads handling, because we don't have to correctly // implement wx-thread restarting. // // Note that this only works if you don't explicitly call ExitMainLoop(), // except in reaction to wx_dll_cleanup()'s message. wx_dll_cleanup() // relies on the availability of wxApp instance and if the event loop // terminated, wxEntry() would return and wxApp instance would be // destroyed. // // Also note that this is efficient, because if there are no windows, the // thread will sleep waiting for a new event. We could safe some memory // by shutting the thread down when it's no longer needed, though. SetExitOnFrameDelete(false); Connect(wxEVT_IDLE, wxIdleEventHandler(MyDllApp::OnIdle)); Connect(CMD_SHOW_WINDOW, wxEVT_THREAD, wxThreadEventHandler(MyDllApp::OnShowWindow)); Connect(CMD_TERMINATE, wxEVT_THREAD, wxThreadEventHandler(MyDllApp::OnTerminate)); }
bool THDApp::OnInit() { #ifdef __WXMAC__ /* * On Mac OS, we have one frame per opened document, and the application * doesn't exit when the last window is closed. */ SetExitOnFrameDelete(false); if (argv[1]) MacOpenFile(argv[1]); #else /* * On other platforms, there is one frame per process. */ frame = new THDMainWindow(); frame->Show(); SetTopWindow(frame); if (argv[1]) frame->Open(argv[1]); #endif return true; }
bool OnInit() { g_uiMainThreadId = Thread::BaseThread::GetCurrentThreadId(); //needed for mfc loading otherwise it asserts out SetExitOnFrameDelete(true); wxWindow::MSWRegisterMessageHandler(WM_QUERYENDSESSION, &WindowsShutdown); wxWindow::MSWRegisterMessageHandler(WM_ENDSESSION, &WindowsShutdown); wxInitAllImageHandlers(); InitManagers(); InitLocalManagers(); //InitLogging(); ControllerForm* cf = new ControllerForm(); if (!cf->init(argc, argv)) return false; g_pMainApp = cf; //SetTopWindow(g_pMainApp); return true; }
virtual bool OnInit() { wxImage::AddHandler(new wxGIFHandler); //wxImage::AddHandler(new wxBMPHandler); val_call0(sgOnInit); SetExitOnFrameDelete(true); return true; }
//------------------------------------------------------------------------------------------------- bool PlayerWatcher::OnInit(){ loadSeDebugPrivilege(); AppWin *frame = new AppWin(_T("D2 Player Watcher"), 50, 50, 350, 140); frame->Show(TRUE); SetTopWindow(frame); SetExitOnFrameDelete(true); return TRUE; }
bool MyApp::OnInit() { #if !START_WITH_MFC_WINDOW // as we're not inside wxWidgets main loop, the default logic doesn't work // in our case and we need to do this explicitly SetExitOnFrameDelete(true); (void) CreateFrame(); #endif return true; }
/*------------------------------------------------------ flexemuSetup implementation (The Application class) --------------------------------------------------------*/ bool FlexemuSetup::OnInit() { #ifdef _UNICODE int i; std::vector<wxCharBuffer> args; auto mb_argv = std::unique_ptr<char *[]>(new char *[argc]); args.reserve(argc); for (i = 0; i < argc; i++) { args.push_back(argv[i].ToUTF8()); } for (i = 0; i < argc; i++) { mb_argv[i] = args[i].data(); } optionMan.InitOptions(&guiOptions, &options, argc, mb_argv.get()); #else optionMan.InitOptions(&guiOptions, &options, argc, argv); #endif wxLocale::AddCatalogLookupPathPrefix("."); wxLocale::AddCatalogLookupPathPrefix("./locale"); m_locale.Init(); m_locale.AddCatalog("flexemu"); optionMan.GetOptions(&guiOptions, &options); optionMan.GetEnvironmentOptions(&guiOptions, &options); SetAppName("FlexemuSetup"); SetExitOnFrameDelete(true); auto dialog = new FlexemuOptionsDialog(guiOptions, options, nullptr, -1, _("Flexemu Options Dialog"), wxDefaultPosition, wxDefaultSize, wxCAPTION | wxSYSTEM_MENU | wxDIALOG_NO_PARENT | wxRESIZE_BORDER); SetTopWindow(dialog); if (dialog->ShowModal() == wxID_OK) { optionMan.WriteOptions(&guiOptions, &options); } dialog->Destroy(); return true; }
void PoeditApp::OnQuit(wxCommandEvent&) { // The Close() calls below may not terminate immediately, they may ask for // confirmation window-modally on OS X. So change the behavior to terminate // the app when the last window is closed now, instead of calling // ExitMainLoop(). This will terminate the app automagically when all the // windows are closed. SetExitOnFrameDelete(true); for ( wxWindowList::iterator i = wxTopLevelWindows.begin(); i != wxTopLevelWindows.end(); ++i ) { if ( !(*i)->Close() ) return; } }
bool MyApp::OnInit() { // make sure we exit properly on macosx SetExitOnFrameDelete(true); wxPoint pos(100, 100); MyFrame *frame = new MyFrame(NULL, -1, "Motion Sensor Calibration Tool", pos, wxSize(1120,760), wxDEFAULT_FRAME_STYLE); #ifdef WINDOWS frame->SetIcon(wxIcon("MotionCal")); #endif frame->Show( true ); return true; }
/*! * Initialisation for tracelogApp */ bool tracelogApp::OnInit() { // Win: Don't remap bitmaps to system colors wxSystemOptions::SetOption(wxT("msw.remap"), 0); // WinXP: Don't draw themed gradients on notebook pages wxSystemOptions::SetOption(wxT("msw.notebook.themed-background"), 0); // Call to base class needed for initializing command line processing if (!wxApp::OnInit()) return false; wxFileSystem::AddHandler(new wxZipFSHandler); wxFileSystem::AddHandler(new wxMemoryFSHandler); wxInitAllImageHandlers(); wxBitmap::InitStandardHandlers(); wxXmlResource::Get()->InitAllHandlers(); const unsigned char *resptr = get_mem_res(); wxMemoryFSHandler::AddFileWithMimeType(wxT("memrsc"), resptr, cnt_mem_res, wxT("application/zip")); { // The following code eliminates a stupid error dialog which shows up // if some .desktop entires (in KDE or GNOME applink dirs) are dangling symlinks. wxLogNull lognull; wxTheMimeTypesManager->GetFileTypeFromExtension(wxT("zip")); } free_mem_res(resptr); m_sResourcePrefix = wxT("memory:memrsc#zip:"); if (!wxXmlResource::Get()->Load(m_sResourcePrefix + wxT("res/tracelog.xrc"))) return false; m_pGrabber = new DebugStringGrabber(); if (!m_pGrabber->IsOk()) return false; m_pLogFrame = new TraceLogFrame(NULL); SetTopWindow(m_pLogFrame); Connect(wxEVT_DEBUGSTRING, wxCommandEventHandler(tracelogApp::OnDebugString)); m_pGrabber->SetHandler(this); m_pTaskBarIcon = new MyTaskBarIcon(); m_pTaskBarIcon->SetIcon(CreateIconFromFile(wxT("res/nx.png")), _("OpenNX")); SetExitOnFrameDelete(true); return true; }
bool WxeApp::OnInit() { global_me = new wxeMemEnv(); wxe_queue = new wxeFifo(1000); wxe_queue_cb_saved = new wxeFifo(200); cb_buff = NULL; recurse_level = 0; delayed_delete = new wxeFifo(10); delayed_cleanup = new wxList; wxe_ps_init2(); // wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); // Hmm printpreview doesn't work in 2.9 with this Connect(wxID_ANY, wxEVT_IDLE, (wxObjectEventFunction) (wxEventFunction) &WxeApp::idle); Connect(CREATE_PORT, wxeEVT_META_COMMAND,(wxObjectEventFunction) (wxEventFunction) &WxeApp::newMemEnv); Connect(DELETE_PORT, wxeEVT_META_COMMAND,(wxObjectEventFunction) (wxEventFunction) &WxeApp::destroyMemEnv); Connect(WXE_SHUTDOWN, wxeEVT_META_COMMAND,(wxObjectEventFunction) (wxEventFunction) &WxeApp::shutdown); // fprintf(stderr, "Size void* %d: long %d long long %d int64 %d \r\n", // sizeof(void *), sizeof(long), sizeof(long long), sizeof(wxInt64)); initEventTable(); wxInitAllImageHandlers(); #ifdef _MACOSX /* Create a default MenuBar so that we can intercept the quit command */ wxMenuBar *macMB = new wxMenuBar; wxMenuBar::MacSetCommonMenuBar(macMB); macMB->MacInstallMenuBar(); macMB->Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction) (wxEventFunction) &WxeApp::dummy_close); #endif SetExitOnFrameDelete(false); init_nonconsts(global_me, init_caller); erl_drv_mutex_lock(wxe_status_m); wxe_status = WXE_INITIATED; erl_drv_cond_signal(wxe_status_c); erl_drv_mutex_unlock(wxe_status_m); return TRUE; }
bool TrenchBroomApp::OnInit() { // set the locale to US so that we can parse floats property std::setlocale(LC_ALL, "us"); if (AbstractApp::OnInit()) { SetExitOnFrameDelete(true); m_docManager->SetUseSDI(false); if (wxApp::argc > 1) { wxString filename = wxApp::argv[1]; if (m_docManager->CreateDocument(filename) == NULL) { return false; } } else { m_docManager->CreateNewDocument(); } return true; } return false; }
int NesulatorApp::OnRun() { try { SetExitOnFrameDelete(true); stopWatch.Start(); EventLoop eventLoop(this); wxEventLoop::SetActive(&eventLoop); m_mainLoop = &eventLoop; while ( !mQuitNow ) { if ( g_activeMainboard != NULL ) { g_activeMainboard->DoLoop(); } else { while ( g_activeMainboard == NULL && !mQuitNow ) { Sleep( 100 ); DoWindowsEvents(); } } } } catch ( std::exception& e ) { DisplayError( e.what() ); } m_mainLoop = NULL; return 0; }
bool MyApp::OnInit() { #ifndef __WXMSW__ if (wxPlatformInfo::Get().GetOperatingSystemId() & wxOS_UNIX) { wxStandardPaths::Get().SetInstallPrefix("/usr"); } #endif wxString datadir = wxStandardPaths::Get().GetDataDir() + wxFileName::GetPathSeparator(); if (!setlocale(LC_CTYPE, "")) { fprintf(stderr, "Can't set the specified locale! " "Check LANG, LC_CTYPE, LC_ALL.\n"); return 1; } m_locale.Init(); m_locale.AddCatalog("astercti"); m_start_gui = ParseCmdLine(); if (!m_start_gui) return true; m_config = NULL; m_config = new wxFileConfig(wxT("astercti"), wxEmptyString, wxT("astercti.ini"), wxEmptyString, wxCONFIG_USE_SUBDIR); wxFileName configfile = m_config->GetLocalFile("astercti.ini", wxCONFIG_USE_SUBDIR); if (!configfile.IsFileReadable()) { std::ostringstream msg; msg << _("Error opening config file.") << std::endl << _("Sample config is at ") << configfile.GetFullPath() << ".default" << std::endl << _("Rename it to astercti.ini and edit."); wxLogError("%s", msg.str()); return false; } m_chanstatuspool = new ChannelStatusPool(m_config->Read("dialplan/channel").ToStdString()); if (m_config->HasEntry("lookup/lookup_url")) { m_lookuper = new CallerInfoLookuperURL(Cfg("lookup/lookup_url")); } else if (m_config->HasEntry("lookup/lookup_cmd")) { m_lookuper = new CallerInfoLookuperCmd(Cfg("lookup/lookup_cmd")); } else { m_lookuper = NULL; } wxPoint pos = m_config->ReadObject("autosave/position", wxDefaultPosition); wxSize size = m_config->ReadObject("autosave/size", wxSize(600, 400)); asterisk = new Asterisk(m_config->Read("server/address").ToStdString(), 5038, m_config->Read("server/username").ToStdString(), m_config->Read("server/password").ToStdString()); bool maximized = m_config->ReadBool("autosave/maximized", false); m_mainframe = new MyFrame( "AsterCTI", pos, size, m_chanstatuspool, asterisk, m_lookuper, Cfg("lookup/caller_name_field")); if (maximized) m_mainframe->Maximize(); m_mychanfilter = new MyChanFilter(m_config->Read("dialplan/channel").ToStdString()); m_intmsgfilter = new InternalMessageFilter(); m_numbershortener = new ShortenNumberModifier(m_config->Read("lookup/replace_number_prefix").ToStdString()); asterisk->observable_descr = "asterisk"; m_mychanfilter->observable_descr = "mychanfilter"; m_intmsgfilter->observable_descr = "intmsgfilter"; asterisk->broadcast(*m_mychanfilter); asterisk->broadcast(*m_intmsgfilter); asterisk->broadcast(*m_chanstatuspool); m_mychanfilter->broadcast(*m_numbershortener); m_numbershortener->broadcast(*m_mainframe); m_intmsgfilter->broadcast(*m_mainframe); notificationFrame *notifyframe = new notificationFrame(m_mainframe, m_chanstatuspool, asterisk, m_lookuper); Executer *executer = new Executer(m_lookuper); m_events = new EventGenerator(m_config->Read("dialplan/exten").ToStdString()); m_events->broadcast(*m_mainframe); m_events->broadcast(*notifyframe); m_events->broadcast(*executer); m_numbershortener->broadcast(*m_events); m_intmsgfilter->broadcast(*m_events); wxIcon defaultIcon(ACTI_ICON("astercti")); wxIcon missedIcon(ACTI_ICON("astercti-missed")); m_mainframe->SetIcon(defaultIcon); m_taskbaricon = new MyTaskBarIcon(defaultIcon, missedIcon, "AsterCTI: " + m_config->Read("dialplan/exten")); m_taskbaricon->SetMainFrame(m_mainframe); m_mainframe->SetTaskBarIcon(m_taskbaricon); m_mainframe->Show(!start_iconified); SetTopWindow(m_mainframe); SetExitOnFrameDelete(true); if (!m_lookuper) { m_mainframe->Log(_("Lookup URL and Lookup command are both unconfigured.\nLookup disabled.")); } m_ipcServer = new IpcServer(); if (!m_ipcServer->Create(IPC_SERVICENAME)) wxLogMessage("Failure creating IPC Server %s", IPC_SERVICENAME); #ifndef __WXMSW__ wxHandleFatalExceptions(); #endif return true; }
bool PoeditApp::OnInit() { if (!wxApp::OnInit()) return false; #if defined(__WXMAC__) wxSystemOptions::SetOption(wxMAC_TEXTCONTROL_USE_SPELL_CHECKER, 1); #endif #ifdef __WXMAC__ SetExitOnFrameDelete(false); #endif #if defined(__UNIX__) && !defined(__WXMAC__) wxStandardPaths::Get().SetInstallPrefix(POEDIT_PREFIX); wxString home = wxGetHomeDir() + "/"; // create Poedit cfg dir, move ~/.poedit to ~/.poedit/config // (upgrade from older versions of Poedit which used ~/.poedit file) if (!wxDirExists(home + ".poedit")) { if (wxFileExists(home + ".poedit")) wxRenameFile(home + ".poedit", home + ".poedit2"); wxMkdir(home + ".poedit"); if (wxFileExists(home + ".poedit2")) wxRenameFile(home + ".poedit2", home + ".poedit/config"); } #endif SetVendorName("Vaclav Slavik"); SetAppName("Poedit"); #if defined(__WXMAC__) #define CFG_FILE (wxStandardPaths::Get().GetUserConfigDir() + "/net.poedit.Poedit.cfg") #elif defined(__UNIX__) #define CFG_FILE (home + ".poedit/config") #else #define CFG_FILE wxEmptyString #endif #ifdef __WXMAC__ // upgrade from the old location of config file: wxString oldcfgfile = wxStandardPaths::Get().GetUserConfigDir() + "/poedit.cfg"; if (wxFileExists(oldcfgfile) && !wxFileExists(CFG_FILE)) { wxRenameFile(oldcfgfile, CFG_FILE); } #endif wxConfigBase::Set( new wxConfig(wxEmptyString, wxEmptyString, CFG_FILE, wxEmptyString, wxCONFIG_USE_GLOBAL_FILE | wxCONFIG_USE_LOCAL_FILE)); wxConfigBase::Get()->SetExpandEnvVars(false); wxImage::AddHandler(new wxPNGHandler); wxXmlResource::Get()->InitAllHandlers(); #if defined(__WXMAC__) wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "/*.xrc"); #elif defined(__WXMSW__) wxStandardPaths::Get().DontIgnoreAppSubDir(); wxXmlResource::Get()->Load(wxStandardPaths::Get().GetResourcesDir() + "\\Resources\\*.xrc"); #else InitXmlResource(); #endif SetDefaultCfg(wxConfig::Get()); #if defined(__WXMAC__) || defined(__WXMSW__) u_setDataDirectory(wxStandardPaths::Get().GetResourcesDir().mb_str()); #endif #ifndef __WXMAC__ wxArtProvider::PushBack(new PoeditArtProvider); #endif SetupLanguage(); #ifdef __WXMAC__ wxMenuBar *bar = wxXmlResource::Get()->LoadMenuBar("mainmenu_mac_global"); TweakOSXMenuBar(bar); wxMenuBar::MacSetCommonMenuBar(bar); // so that help menu is correctly merged with system-provided menu // (see http://sourceforge.net/tracker/index.php?func=detail&aid=1600747&group_id=9863&atid=309863) s_macHelpMenuTitleName = _("&Help"); #endif FileHistory().Load(*wxConfig::Get()); // NB: It's important to do this before TM is used for the first time. if ( !MigrateLegacyTranslationMemory() ) return false; // NB: opening files or creating empty window is handled differently on // Macs, using MacOpenFiles() and MacNewFile(), so don't create empty // window if no files are given on command line; but still support // passing files on command line if (!gs_filesToOpen.empty()) { OpenFiles(gs_filesToOpen); gs_filesToOpen.clear(); } #ifndef __WXMAC__ else { OpenNewFile(); } #endif // !__WXMAC__ #ifdef USE_SPARKLE Sparkle_Initialize(CheckForBetaUpdates()); #endif // USE_SPARKLE #ifdef __WXMSW__ const char *appcast = "http://releases.poedit.net/appcast-win"; if ( CheckForBetaUpdates() ) { // Beta versions use unstable feed. appcast = "http://releases.poedit.net/appcast-win/beta"; } win_sparkle_set_appcast_url(appcast); win_sparkle_init(); #endif return true; }
bool hvApp::OnInit() { #ifdef __WXMOTIF__ delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used #endif // Don't exit on frame deletion, since the help window is programmed // to cause the app to exit even if it is still open. We need to have the app // close by other means. SetExitOnFrameDelete(false); wxArtProvider::Push(new AlternateArtProvider); #ifdef __WXMAC__ wxApp::s_macAboutMenuItemId = wxID_ABOUT; wxFileName::MacRegisterDefaultTypeAndCreator( wxT("htb") , 'HTBD' , 'HTBA' ) ; #endif int istyle = wxHF_DEFAULT_STYLE|wxHF_OPEN_FILES; wxString service, windowName, titleFormat, argStr; wxString book[10]; int bookCount = 0; int i; bool hasService = false; bool hasWindowName = false; bool createServer = false; #if wxUSE_IPC m_server = NULL; #endif // Help books are recognized by extension ".hhp" ".htb" or ".zip". // Service and window_name can occur anywhere in arguments, // but service must be first // Other arguments (topic?) could be added // modes of operation: // 1) no arguments - stand alone, prompt user for book // 2) books only - stand alone, open books // 3) "--server" as (any) arg - start connection with default service; // also open any books passed as other arguments // 4) at least one argument which is not book, and not "--server" - take first // such argument as service, second (if present) as window name, // start service, open any books for( i=1; i<argc; i++ ) { argStr = argv[i]; if ( argStr.Find( wxT(".hhp") ) >= 0 || argStr.Find( wxT(".htb") ) >= 0 || argStr.Find( wxT(".zip") ) >= 0 ) { book[bookCount] = argStr; bookCount++; } else if ( argStr == wxT("--server") ) { createServer = true; #if defined(__WXMSW__) service = wxT("generic_helpservice"); #elif defined(__UNIX__) service = wxT("/tmp/") + wxString(wxT("generic_helpservice")); #else service = wxT("4242"); #endif } else if ( !hasService ) { service = argStr; hasService = true; createServer = true; } else if ( !hasWindowName ) { windowName = argStr; hasWindowName = true; } else if ( argStr.Find( wxT("--Style") ) >= 0 ) { long i; wxString numb = argStr.AfterLast(wxT('e')); if ( !(numb.ToLong(&i) ) ) { wxLogError( wxT("Integer conversion failed for --Style") ); } else { istyle = i; } } else { //unknown - could be topic? } } // No book - query user; but not on Mac, since there // may be an AppleEvent to open a document on the way #ifndef __WXMAC__ if ( bookCount < 1 ) { wxString s = wxFileSelector( wxT("Open help file"), wxGetCwd(), wxEmptyString, wxEmptyString, wxT("Help books (*.htb)|*.htb|Help books (*.zip)|*.zip|HTML Help Project (*.hhp)|*.hhp"), wxFD_OPEN | wxFD_FILE_MUST_EXIST, NULL); if (!s.empty()) { book[0] = s; bookCount = 1; } } #endif #if wxUSE_IPC if ( createServer ) { // Create a new server m_server = new hvServer; if ( !m_server->Create(service) ) { wxString wxm = wxT("Server Create failed - service: "); wxString xxm = wxm << service; wxLogError( xxm ); //if MSW quits here, probably another copy already exists return false; } createServer = false; wxUnusedVar(createServer); } #endif // wxUSE_IPC //now add help wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); SetVendorName(wxT("wxWidgets") ); SetAppName(wxT("wxHTMLHelpServer") ); wxConfig::Get(); // create an instance m_helpController = new wxHtmlHelpController( istyle ); if ( !hasWindowName ) { titleFormat = wxT("Help: %s") ; } else { //remove underscores windowName.Replace( wxT("_"), wxT(" ") ); titleFormat = windowName; } m_helpController->SetTitleFormat( titleFormat ); for( i=0; i<bookCount; i++ ) { wxFileName fileName(book[i]); m_helpController->AddBook(fileName); } #ifdef __WXMOTIF__ delete wxLog::SetActiveTarget(new wxLogGui); #endif m_helpController->DisplayContents(); SetTopWindow(m_helpController->GetFrame()); m_exitIfNoMainWindow = true; return true; }
// The `main program' equivalent, creating the windows and returning the // main frame bool AudacityApp::OnInit() { // Unused strings that we want to be translated, even though // we're not using them yet... wxString future1 = _("Master Gain Control"); wxString future2 = _("Input Meter"); wxString future3 = _("Output Meter"); ::wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); InitPreferences(); #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__CYGWIN__) this->AssociateFileTypes(); #endif // // Paths: set search path and temp dir path // wxString home = wxGetHomeDir(); mAppHomeDir = home; // On Unix systems, the default temp dir is in /tmp. // Search path (in this order): // * The AUDACITY_PATH environment variable // * The current directory // * The user's .audacity-files directory in their home directory // * The "share" and "share/doc" directories in their install path #ifdef __WXGTK__ defaultTempDir.Printf(wxT("/tmp/audacity1.2-%s"), wxGetUserId().c_str()); wxString pathVar = wxGetenv(wxT("AUDACITY_PATH")); if (pathVar != wxT("")) AddMultiPathsToPathList(pathVar, audacityPathList); AddUniquePathToPathList(FROMFILENAME(::wxGetCwd()), audacityPathList); AddUniquePathToPathList(wxString::Format(wxT("%s/.audacity-files"), home.c_str()), audacityPathList); #ifdef AUDACITY_NAME AddUniquePathToPathList(wxString::Format(wxT("%s/share/%s"), wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)), audacityPathList); AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/%s"), wxT(INSTALL_PREFIX), wxT(AUDACITY_NAME)), audacityPathList); #else AddUniquePathToPathList(wxString::Format(wxT("%s/share/audacity"), wxT(INSTALL_PREFIX)), audacityPathList); AddUniquePathToPathList(wxString::Format(wxT("%s/share/doc/audacity"), wxT(INSTALL_PREFIX)), audacityPathList); #endif AddUniquePathToPathList(wxString::Format(wxT("%s/share/locale"), wxT(INSTALL_PREFIX)), audacityPathList); #endif wxFileName tmpFile; tmpFile.AssignTempFileName(wxT("nn")); wxString tmpDirLoc = tmpFile.GetPath(wxPATH_GET_VOLUME); ::wxRemoveFile(FILENAME(tmpFile.GetFullPath())); // On Mac and Windows systems, use the directory which contains Audacity. #ifdef __WXMSW__ // On Windows, the path to the Audacity program is in argv[0] wxString progPath = wxPathOnly(argv[0]); AddUniquePathToPathList(progPath, audacityPathList); AddUniquePathToPathList(progPath+wxT("\\Languages"), audacityPathList); defaultTempDir.Printf(wxT("%s\\audacity_1_2_temp"), tmpDirLoc.c_str()); #endif #ifdef __MACOSX__ // On Mac OS X, the path to the Audacity program is in argv[0] wxString progPath = wxPathOnly(argv[0]); AddUniquePathToPathList(progPath, audacityPathList); // If Audacity is a "bundle" package, then the root directory is // the great-great-grandparent of the directory containing the executable. AddUniquePathToPathList(progPath+wxT("/../../../"), audacityPathList); AddUniquePathToPathList(progPath+wxT("/Languages"), audacityPathList); AddUniquePathToPathList(progPath+wxT("/../../../Languages"), audacityPathList); defaultTempDir.Printf(wxT("%s/audacity1.2-%s"), tmpDirLoc.c_str(), wxGetUserId().c_str()); #endif #ifdef __MACOS9__ // On Mac OS 9, the initial working directory is the one that // contains the program. wxString progPath = wxGetCwd(); AddUniquePathToPathList(progPath, audacityPathList); AddUniquePathToPathList(progPath+wxT(":Languages"), audacityPathList); defaultTempDir.Printf(wxT("%s/audacity_1_2_temp"), tmpDirLoc.c_str()); #endif // BG: Create a temporary window to set as the top window wxFrame *temporarywindow = new wxFrame(NULL, -1, wxT("temporarytopwindow")); SetTopWindow(temporarywindow); // Locale // wxWindows 2.3 has a much nicer wxLocale API. We can make this code much // better once we move to wx 2.3/2.4. wxString lang = gPrefs->Read(wxT("/Locale/Language"), wxT("")); // Pop up a dialog the first time the program is run if (lang == wxT("")) lang = ChooseLanguage(NULL); #ifdef NOT_RQD //TIDY-ME: (CleanSpeech) Language prompt?? // The prompt for language only happens ONCE on a system. // I don't think we should disable it JKC wxString lang = gPrefs->Read(wxT("/Locale/Language"), "en"); //lda // Pop up a dialog the first time the program is run //lda if (lang == "") //lda lang = ChooseLanguage(NULL); #endif gPrefs->Write(wxT("/Locale/Language"), lang); if (lang != wxT("en")) { wxLogNull nolog; mLocale = new wxLocale(wxT(""), lang, wxT(""), true, true); for(unsigned int i=0; i<audacityPathList.GetCount(); i++) mLocale->AddCatalogLookupPathPrefix(audacityPathList[i]); #ifdef AUDACITY_NAME mLocale->AddCatalog(wxT(AUDACITY_NAME)); #else mLocale->AddCatalog(wxT("audacity")); #endif } else mLocale = NULL; // Initialize internationalisation (number formats etc.) // // This must go _after_ creating the wxLocale instance because // creating the wxLocale instance sets the application-wide locale. Internat::Init(); // Init DirManager, which initializes the temp directory // If this fails, we must exit the program. if (!InitTempDir()) { FinishPreferences(); return false; } // More initialization InitCleanSpeech(); InitDitherers(); InitAudioIO(); LoadEffects(); #ifdef __WXMAC__ // On the Mac, users don't expect a program to quit when you close the last window. // Create an offscreen frame with a menu bar. The frame should never // be visible, but when all other windows are closed, this menu bar should // become visible. gParentFrame = new wxFrame(NULL, -1, wxT("invisible"), wxPoint(5000, 5000), wxSize(100, 100)); wxMenu *fileMenu = new wxMenu(); fileMenu->Append(wxID_NEW, wxT("&New\tCtrl+N")); fileMenu->Append(wxID_OPEN, wxT("&Open...\tCtrl+O")); /* i18n-hint: Mac OS X shortcut should be Ctrl+, */ fileMenu->Append(wxID_PREFERENCES, _("&Preferences...\tCtrl+,")); wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, wxT("&File")); gParentFrame->SetMenuBar(menuBar); gParentFrame->Show(); SetTopWindow(gParentFrame); #endif SetExitOnFrameDelete(true); /////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// //Initiate pointers to toolbars here, and create //the toolbars that should be loaded at startup. gControlToolBarStub = LoadToolBar( wxT(""),true, gParentWindow,ControlToolBarID); gMixerToolBarStub = LoadToolBar( wxT("/GUI/EnableMixerToolBar"),true, gParentWindow,MixerToolBarID); gMeterToolBarStub = LoadToolBar( wxT("/GUI/EnableMeterToolBar"),true, gParentWindow,MeterToolBarID); gEditToolBarStub = LoadToolBar( wxT("/GUI/EnableEditToolBar"),true, gParentWindow,EditToolBarID); gTranscriptionToolBarStub = LoadToolBar( wxT("/GUI/EnableTranscriptionToolBar"),false, gParentWindow,TranscriptionToolBarID); /// ToolBar Initiation Complete. //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// AudacityProject *project = CreateNewAudacityProject(gParentWindow); SetTopWindow(project); delete temporarywindow; // Can't handle command-line args on Mac OS X yet... // Cygwin command-line parser below... #if !defined(__MACOSX__) && !defined(__CYGWIN__) // Parse command-line arguments if (argc > 1) { for (int option = 1; option < argc; option++) { if (!argv[option]) continue; bool handled = false; if (!wxString(wxT("-help")).CmpNoCase(argv[option])) { wxPrintf(/* i18n-hint: '-help', '-test' and '-blocksize' need to stay in English. */ _("Command-line options supported:\n -help (this message)\n -test (run self diagnostics)\n -blocksize ### (set max disk block size in bytes)\n\nIn addition, specify the name of an audio file or Audacity project\nto open it.\n\n")); exit(0); } if (option < argc - 1 && argv[option + 1] && !wxString(wxT("-blocksize")).CmpNoCase(argv[option])) { long theBlockSize; if (wxString(argv[option + 1]).ToLong(&theBlockSize)) { if (theBlockSize >= 256 && theBlockSize < 100000000) { wxFprintf(stderr, _("Using block size of %ld\n"), theBlockSize); Sequence::SetMaxDiskBlockSize(theBlockSize); } } option++; handled = true; } if (!handled && !wxString(wxT("-test")).CmpNoCase(argv[option])) { RunBenchmark(NULL); exit(0); } if (argv[option][0] == wxT('-') && !handled) { wxPrintf(_("Unknown command line option: %s\n"), argv[option]); exit(0); } if (!handled) project->OpenFile(argv[option]); } // for option... } // if (argc>1) #endif // not Mac OS X // Cygwin command line parser (by Dave Fancella) #if defined(__CYGWIN__) if (argc > 1) { int optionstart = 1; bool startAtOffset = false; // Scan command line arguments looking for trouble for (int option = 1; option < argc; option++) { if (!argv[option]) continue; // Check to see if argv[0] is copied across other arguments. // This is the reason Cygwin gets its own command line parser. if (wxString(argv[option]).Lower().Contains(wxString(wxT("audacity.exe")))) { startAtOffset = true; optionstart = option + 1; } } for (int option = optionstart; option < argc; option++) { if (!argv[option]) continue; bool handled = false; bool openThisFile = false; wxString fileToOpen; if (!wxString(wxT("-help")).CmpNoCase(argv[option])) { wxPrintf(/* i18n-hint: '-help', '-test' and '-blocksize' need to stay in English. */ _("Command-line options supported:\n" " -help (this message)\n" " -test (run self diagnostics)\n" " -blocksize ### (set max disk block size in bytes)\n" "\n" "In addition, specify the name of an audio file or " "Audacity project\n" "to open it.\n" "\n")); exit(0); } if (option < argc - 1 && argv[option + 1] && !wxString(wxT("-blocksize")).CmpNoCase(argv[option])) { long theBlockSize; if (wxString(argv[option + 1]).ToLong(&theBlockSize)) { if (theBlockSize >= 256 && theBlockSize < 100000000) { wxFprintf(stderr, _("Using block size of %ld\n"), theBlockSize); Sequence::SetMaxDiskBlockSize(theBlockSize); } } option++; handled = true; } if (!handled && !wxString(wxT("-test")).CmpNoCase(argv[option])) { RunBenchmark(NULL); exit(0); } if (argv[option][0] == wxT('-') && !handled) { wxPrintf(_("Unknown command line option: %s\n"), argv[option]); exit(0); } if(handled) fileToOpen.Clear(); if (!handled) fileToOpen = fileToOpen + wxT(" ") + argv[option]; if(wxString(argv[option]).Lower().Contains(wxT(".aup"))) openThisFile = true; if(openThisFile) { openThisFile = false; project->OpenFile(fileToOpen); } } // for option... } // if (argc>1) #endif // Cygwin command-line parser gInited = true; return TRUE; }
bool pulseTest::OnInit() { initWxTraceTags(); wxString tmp; wxConfigBase::Get()->Read(wxT("Config/SystemNxDir"), &tmp); m_cLocale.AddCatalogLookupPathPrefix(tmp + wxFileName::GetPathSeparator() + wxT("share") + wxFileName::GetPathSeparator() + wxT("locale")); m_cLocale.AddCatalogLookupPathPrefix(wxT("locale")); m_cLocale.Init(); m_cLocale.AddCatalog(wxT("opennx")); // Win: Don't remap bitmaps to system colors wxSystemOptions::SetOption(wxT("msw.remap"), 0); #ifdef __WXMSW__ wxString ldpath; if (::wxGetEnv(wxT("PATH"), &ldpath)) ldpath += wxT(";"); ldpath = tmp + wxT("\\bin"); if (!::wxSetEnv(wxT("PATH"), ldpath)) { ::wxLogSysError(wxT("Can not set PATH")); return false; } #endif #ifdef __UNIX__ # ifdef __WXMAC__ # define LD_LIBRARY_PATH wxT("DYLD_LIBRARY_PATH") # else # define LD_LIBRARY_PATH wxT("LD_LIBRARY_PATH") # endif wxString ldpath; if (::wxGetEnv(LD_LIBRARY_PATH, &ldpath)) ldpath += wxT(":"); # if defined(__x86_64) || defined(__IA64__) ldpath += tmp + wxT("/lib64"); # else ldpath += tmp + wxT("/lib"); # endif # ifdef __WXMAC__ ldpath += wxT(":/Library/OpenSC/lib"); # endif if (!::wxSetEnv(LD_LIBRARY_PATH, ldpath)) { ::wxLogSysError(wxT("Can not set LD_LIBRARY_PATH")); return false; } #endif if (!wxApp::OnInit()) return false; if (::wxGetEnv(wxT("WXTRACE"), &tmp)) { CheckAllTrace(tmp); wxStringTokenizer t(tmp, wxT(",:")); while (t.HasMoreTokens()) { wxString tag = t.GetNextToken(); if (allTraceTags.Index(tag) != wxNOT_FOUND) { ::myLogDebug(wxT("Trace for '%s' enabled"), tag.c_str()); wxLog::AddTraceMask(tag); } } } PulseAudio pa; if (pa.IsAvailable()) { pa.ActivateEsound(12345); } SetExitOnFrameDelete(true); return false; }
// The `main program' equivalent, creating the windows and returning the // main frame bool AudacityApp::OnInit() { // mChecker = new wxSingleInstanceChecker(GetAppName()); ::wxInitAllImageHandlers(); wxFileSystem::AddHandler(new wxZipFSHandler); #ifdef __WXMSW__ //BG: On Windows, associate the aup file type with Audacity { wxRegKey associateFileTypes; associateFileTypes.SetName("HKCR\\.AUP"); associateFileTypes.Create(true); associateFileTypes = "Audacity.Project"; associateFileTypes.SetName("HKCR\\Audacity.Project"); associateFileTypes.Create(true); associateFileTypes = "Audacity Project File"; associateFileTypes.SetName("HKCR\\Audacity.Project\\shell"); associateFileTypes.Create(true); associateFileTypes = ""; associateFileTypes.SetName("HKCR\\Audacity.Project\\shell\\open"); associateFileTypes.Create(true); associateFileTypes.SetName("HKCR\\Audacity.Project\\shell\\open\\command"); associateFileTypes.Create(true); associateFileTypes = (wxString)argv[0] + (wxString)" %1"; } #endif InitPreferences(); InitAudioIO(); // Locale // wxWindows 2.3 has a much nicer wxLocale API. We can make this code much // better once we move to wx 2.3/2.4. wxString lang = gPrefs->Read("/Locale/Language", "en"); if (lang != "en") { wxLogNull nolog; mLocale = new wxLocale("", lang, "", true, true); mLocale->AddCatalog("audacity"); } else mLocale = NULL; LoadEffects(wxPathOnly(argv[0])); #ifdef __WXMAC__ // Install AppleEvent handlers (allows us to open documents // that are dragged to our application's icon) AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(AEOpenFiles), 0, 0); AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, NewAEEventHandlerUPP(AEQuit), 0, 0); // On the Mac, users don't expect a program to quit when you close the last window. // Create an offscreen frame with a menu bar. The frame should never // be visible, but when all other windows are closed, this menu bar should // become visible. gParentFrame = new wxFrame(NULL, -1, "invisible", wxPoint(5000, 5000), wxSize(100, 100)); wxMenu *fileMenu = new wxMenu(); fileMenu->Append(NewID, "&New\tCtrl+N"); fileMenu->Append(OpenID, "&Open...\tCtrl+O"); fileMenu->AppendSeparator(); fileMenu->Append(PreferencesID, "&Preferences...\tCtrl+P"); fileMenu->AppendSeparator(); fileMenu->Append(ExitID, "Quit\tCtrl+Q"); wxMenu *helpMenu = new wxMenu(); helpMenu->Append(AboutID, "About Audacity..."); wxApp::s_macAboutMenuItemId = AboutID; wxMenuBar *menuBar = new wxMenuBar(); menuBar->Append(fileMenu, "&File"); menuBar->Append(helpMenu, "&Help"); gParentFrame->SetMenuBar(menuBar); gParentFrame->Show(); SetTopWindow(gParentFrame); #endif SetExitOnFrameDelete(true); //Initiate pointers to toolbars here, and create //the toolbars that should be loaded at startup. //Initiate globally-held toolbar stubs here. gControlToolBarStub = new ToolBarStub(gParentWindow, ControlToolBarID); // Changing the following to NULL will make the application // load without the toolbar in memory at all. bool editToolBar; gPrefs->Read("/GUI/EnableEditToolBar", &editToolBar, true); if(editToolBar) gEditToolBarStub = new ToolBarStub(gParentWindow, EditToolBarID); else gEditToolBarStub = NULL; InitFreqWindow(gParentWindow); AudacityProject *project = CreateNewAudacityProject(gParentWindow); SetTopWindow(project); // Can't handle command-line args on Mac OS X yet... #ifndef __MACOSX__ // Parse command-line arguments if (argc > 1) { for (int option = 1; option < argc; option++) { if (!argv[option]) continue; bool handled = false; if (!wxString("-help").CmpNoCase(argv[option])) { printf(_("Command-line options supported:\n" " -help (this message)\n" " -test (run self diagnostics)\n" " -blocksize ### (set max disk block size in bytes)\n" "\n" "In addition, specify the name of an audio file or " "Audacity project\n" "to open it.\n" "\n")); exit(0); } if (option < argc - 1 && argv[option + 1] && !wxString("-blocksize").CmpNoCase(argv[option])) { long theBlockSize; if (wxString(argv[option + 1]).ToLong(&theBlockSize)) { if (theBlockSize >= 256 && theBlockSize < 100000000) { fprintf(stderr, _("Using block size of %ld\n"), theBlockSize); Sequence::SetMaxDiskBlockSize(theBlockSize); } } option++; handled = true; } if (!handled && !wxString("-test").CmpNoCase(argv[option])) { RunBenchmark(NULL); exit(0); } if (argv[option][0] == '-' && !handled) { printf(_("Unknown command line option: %s\n"), argv[option]); exit(0); } if (!handled) project->OpenFile(argv[option]); } // for option... } // if (argc>1) #endif // not Mac OS X return TRUE; }
bool App::OnInit() { _dlgPrefPtr = nullptr; //Re direction des logs ver la sorti standard. wxLog* logger = new wxLogStream(&std::cout); wxLog::SetActiveTarget(logger); //Changement du préfixe seulement sous unix #if defined(__UNIX__) wxStandardPaths::Get().SetInstallPrefix("/usr"); #endif //Chemin vair le fichier d'instance du programme. wxString fileSingleInstance = wxStandardPaths::Get().GetTempDir()+'/'+PROJECT_NAME+'-'+wxGetUserId(); //Si le fichier existe ceci veux dire qu'il y a une autre instances de ce //programme en cour d'exécution. if(wxFileExists(fileSingleInstance)) { //On lis le pid de l'autre instances. int pid; wxFile file(fileSingleInstance); file.Read(&pid, sizeof pid); file.Close(); //Et on luis envois le signale USER1. if(wxKill(pid, (wxSignal)SIGUSR1) == 0) { wxLogMessage(PROJECT_NAME" is already running ..."); return false; } } //Si le fichier n'existe pas, alors on le crée avec le pid de //cette instances. int pid = getpid(); wxFile file(fileSingleInstance, wxFile::write); file.Write(&pid, sizeof pid); file.Close(); //Installassions du gestionnaire de signale. //Pour récupère le signale USER1. std::signal(SIGUSR1, signal_user1); evtHandlerMain = this; //Init général wxInitAllImageHandlers(); SetExitOnFrameDelete(false); //Création de tout les managers. Manager::createManagers(); //Chargement de la confige de tous les manager. Manager::loadManagers(); //Bind. Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onQuit, this, ID_QUIT); Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onAbout, this, ID_ABOUT); Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onPreferences, this, ID_PREFERENCES); Bind(wxEVT_COMMAND_MENU_SELECTED, &App::onEnableShortcuts, this, ID_ENABLE_SHORTKUT); #ifdef DEV_RUN_START_PREFERENCES //Envoi d'un évènement pour afficher les préférences. wxCommandEvent *event = new wxCommandEvent(wxEVT_COMMAND_MENU_SELECTED, ID_PREFERENCES); wxQueueEvent(this, event); #endif return true; }