void AskExit() { if(CheckIfModified()==TRUE) { SetColor(LIGHTWHITE); SetBackColor(RED); OpenWindow(10,24,5,32); SetColor(YELLOW); Print_At(11,29,"Apply Changes on Exit?"); SetColor(BLUE); SetBackColor(WHITE); SetBlink(ON); Print_At(13,32," <Yes> "); Print_At(13,42," <No> "); SetBlink(OFF); GetKey(); } CloseAllWindows(); VideoReset(); if(keycode!=ESC && keychar!='n' && keychar!='N') if(WriteHeader(&id32)!=0) { printf("%s could not write to file\n" ,errstr); exit(1); } CloseFile(); exit(0); }
NS_IMETHODIMP nsAppStartup::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData) { NS_ASSERTION(mAppShell, "appshell service notified before appshell built"); if (!strcmp(aTopic, "quit-application-forced")) { mShuttingDown = PR_TRUE; } else if (!strcmp(aTopic, "profile-change-teardown")) { if (!mShuttingDown) { EnterLastWindowClosingSurvivalArea(); CloseAllWindows(); ExitLastWindowClosingSurvivalArea(); } } else if (!strcmp(aTopic, "xul-window-registered")) { EnterLastWindowClosingSurvivalArea(); } else if (!strcmp(aTopic, "xul-window-destroyed")) { ExitLastWindowClosingSurvivalArea(); } else if (!strcmp(aTopic, "sessionstore-windows-restored")) { gRestoredTimestamp = PR_Now(); } else { NS_ERROR("Unexpected observer topic."); } return NS_OK; }
void SCCircuitDocument::OpenSomething ( const JCharacter* fileName ) { JString fullName; if (fileName != NULL && fileName[0] != '\0') { if (JFileExists(fileName)) { fullName = fileName; } else { return; } } else if (!(JGetChooseSaveFile())->ChooseFile("File to open:", NULL, &fullName)) { return; } std::ifstream input(fullName); const FileStatus status = CanReadFile(input); JXFileDocument* doc; if (status == kFileReadable && !(JXGetDocumentManager())->FileDocumentIsOpen(fullName, &doc) && OKToClose()) { CloseAllWindows(); FileChanged(fullName, kJTrue); ReadFile(input); } else if (status == kNeedNewerVersion) { (JGetUserNotification())->ReportError( "This notebook was created by a newer version of Symcir. " "You need the newest version in order to open it."); } else if (status == kNotMyFile && OKToClose()) { input.close(); CloseAllWindows(); ReadNetlist(fullName); } }
/** \brief Closes all windows. \author dcofer \date 3/25/2011 **/ void SimulationWindowMgr::Close() { if(m_lpHudMgr) { m_lpHudMgr->Reset(); delete m_lpHudMgr; m_lpHudMgr = NULL; } CloseAllWindows(); }
void ApplyExit() { CloseAllWindows(); VideoReset(); if(WriteHeader(&id32)!=0) { printf("%s could not write to file\n", errstr); exit(1); } CloseFile(); exit(0); }
void SCCircuitDocument::DiscardChanges() { JBoolean onDisk; const JString fullName = GetFullName(&onDisk); if (onDisk) { CloseAllWindows(); std::ifstream input(fullName); ReadFile(input); } else { assert( 0 /* "New file" not supported! */ ); } DataReverted(); }
JBoolean JXDockDirector::Close() { JXApplication* app = JXGetApplication(); JXDockManager* mgr = JXGetDockManager(); if (mgr->IsLastDock(this) && !app->IsQuitting() && HasWindows()) { app->Quit(); return kJFalse; } else { // We must close all windows before closing ourselves because // otherwise, we will get a Draw event after partially destructing // if a document needs to ask the user whether or not to close. return JI2B( CloseAllWindows() && JXWindowDirector::Close() ); } }
void CheckIfLocked() { if((id32.dos32a_misc2&0x40)==0x40) { SetColor(LIGHTWHITE); SetBackColor(RED); OpenWindow(10,24,5,32); SetColor(YELLOW); Print_At(11,28,"Configuration is Locked!"); SetColor(BLUE); SetBackColor(WHITE); SetBlink(ON); Print_At(13,27," Press any key to exit... "); SetBlink(OFF); GetKey(); CloseAllWindows(); VideoReset(); exit(0); } }
void TTracker::MessageReceived(BMessage *message) { if (HandleScriptingMessage(message)) return; switch (message->what) { case kGetInfo: OpenInfoWindows(message); break; case kMoveToTrash: MoveRefsToTrash(message); break; case kCloseWindowAndChildren: { const node_ref *itemNode; int32 bytes; message->FindData("node_ref", B_RAW_TYPE, (const void **)&itemNode, &bytes); CloseWindowAndChildren(itemNode); break; } case kCloseAllWindows: CloseAllWindows(); break; case kFindButton: (new FindWindow())->Show(); break; case kEditQuery: EditQueries(message); break; case kUnmountVolume: // When the user attempts to unmount a volume from the mount // context menu, this is where the message gets received. Save // pose locations and forward this to the automounter SaveAllPoseLocations(); fAutoMounter->PostMessage(message); break; case kRunAutomounterSettings: AutomountSettingsDialog::RunAutomountSettings(fAutoMounter); break; case kShowSplash: { // The AboutWindow was moved out of the Tracker in preparation // for when we open source it. The AboutBox contains important // credit and license issues that shouldn't be modified, and // therefore shouldn't be open sourced. However, there is a public // API for 3rd party apps to tell the Tracker to open the AboutBox. run_be_about(); break; } case kAddPrinter: // show the addprinter window run_add_printer_panel(); break; case kMakeActivePrinter: // get the current selection SetDefaultPrinter(message); break; #ifdef MOUNT_MENU_IN_DESKBAR case 'gmtv': { // Someone (probably the deskbar) has requested a list of // mountable volumes. BMessage reply; AutoMounterLoop()->EachMountableItemAndFloppy(&AddMountableItemToMessage, &reply); message->SendReply(&reply); break; } #endif case kMountVolume: case kMountAllNow: AutoMounterLoop()->PostMessage(message); break; case kRestoreBackgroundImage: { BDeskWindow *desktop = GetDeskWindow(); AutoLock<BWindow> lock(desktop); desktop->UpdateDesktopBackgroundImages(); } break; case kShowSettingsWindow: ShowSettingsWindow(); break; case kFavoriteCountChangedExternally: SendNotices(kFavoriteCountChangedExternally, message); break; case kStartWatchClipboardRefs: { BMessenger messenger; message->FindMessenger("target", &messenger); if (messenger.IsValid()) fClipboardRefsWatcher->AddToNotifyList(messenger); break; } case kStopWatchClipboardRefs: { BMessenger messenger; message->FindMessenger("target", &messenger); if (messenger.IsValid()) fClipboardRefsWatcher->RemoveFromNotifyList(messenger); break; } default: _inherited::MessageReceived(message); break; } }
void TTracker::MessageReceived(BMessage *message) { if (HandleScriptingMessage(message)) return; switch (message->what) { case kGetInfo: OpenInfoWindows(message); break; case kMoveToTrash: MoveRefsToTrash(message); break; case kCloseWindowAndChildren: { const node_ref *itemNode; int32 bytes; message->FindData("node_ref", B_RAW_TYPE, (const void **)&itemNode, &bytes); CloseWindowAndChildren(itemNode); break; } case kCloseAllWindows: CloseAllWindows(); break; case kCloseAllInWorkspace: CloseAllInWorkspace(); break; case kFindButton: (new FindWindow())->Show(); break; case kEditQuery: EditQueries(message); break; case kShowSplash: run_be_about(); break; case kAddPrinter: // show the addprinter window run_add_printer_panel(); break; case kMakeActivePrinter: // get the current selection SetDefaultPrinter(message); break; #ifdef MOUNT_MENU_IN_DESKBAR case 'gmtv': { // Someone (probably the deskbar) has requested a list of // mountable volumes. BMessage reply; AutoMounterLoop()->EachMountableItemAndFloppy(&AddMountableItemToMessage, &reply); message->SendReply(&reply); break; } #endif case kUnmountVolume: // When the user attempts to unmount a volume from the mount // context menu, this is where the message gets received. // Save pose locations and forward this to the automounter SaveAllPoseLocations(); // Fall through... case kMountVolume: case kMountAllNow: MountServer().SendMessage(message); break; case kRunAutomounterSettings: AutomountSettingsDialog::RunAutomountSettings(MountServer()); break; case kRestoreBackgroundImage: { BDeskWindow *desktop = GetDeskWindow(); AutoLock<BWindow> lock(desktop); desktop->UpdateDesktopBackgroundImages(); break; } case kShowSettingsWindow: ShowSettingsWindow(); break; case kFavoriteCountChangedExternally: SendNotices(kFavoriteCountChangedExternally, message); break; case kStartWatchClipboardRefs: { BMessenger messenger; message->FindMessenger("target", &messenger); if (messenger.IsValid()) fClipboardRefsWatcher->AddToNotifyList(messenger); break; } case kStopWatchClipboardRefs: { BMessenger messenger; message->FindMessenger("target", &messenger); if (messenger.IsValid()) fClipboardRefsWatcher->RemoveFromNotifyList(messenger); break; } case kFSClipboardChanges: fClipboardRefsWatcher->UpdatePoseViews(message); break; case kShowVolumeSpaceBar: case kSpaceBarColorChanged: gPeriodicUpdatePoses.DoPeriodicUpdate(true); break; case B_LOCALE_CHANGED: { BLocaleRoster::Default()->Refresh(); bool localize; if (message->FindBool("filesys", &localize) == B_OK) gLocalizedNamePreferred = localize; break; } default: _inherited::MessageReceived(message); break; } }
View::~View( void ) { CloseAllWindows(); delete sfont; delete lfont; delete sys_icons; }
NS_IMETHODIMP nsAppStartup::Quit(PRUint32 aMode) { PRUint32 ferocity = (aMode & 0xF); // Quit the application. We will asynchronously call the appshell's // Exit() method via nsAppExitEvent to allow one last pass // through any events in the queue. This guarantees a tidy cleanup. nsresult rv = NS_OK; PRBool postedExitEvent = PR_FALSE; if (mShuttingDown) return NS_OK; // If we're considering quitting, we will only do so if: if (ferocity == eConsiderQuit) { if (mConsiderQuitStopper == 0) { // there are no windows... ferocity = eAttemptQuit; } #ifdef XP_MACOSX else if (mConsiderQuitStopper == 1) { // ... or there is only a hiddenWindow left, and it's useless: nsCOMPtr<nsIAppShellService> appShell (do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); // Failure shouldn't be fatal, but will abort quit attempt: if (!appShell) return NS_OK; PRBool usefulHiddenWindow; appShell->GetApplicationProvidedHiddenWindow(&usefulHiddenWindow); nsCOMPtr<nsIXULWindow> hiddenWindow; appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); // If the one window is useful, we won't quit: if (!hiddenWindow || usefulHiddenWindow) return NS_OK; ferocity = eAttemptQuit; } #endif } nsCOMPtr<nsIObserverService> obsService; if (ferocity == eAttemptQuit || ferocity == eForceQuit) { nsCOMPtr<nsISimpleEnumerator> windowEnumerator; nsCOMPtr<nsIWindowMediator> mediator (do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); if (mediator) { mediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)); if (windowEnumerator) { PRBool more; while (windowEnumerator->HasMoreElements(&more), more) { nsCOMPtr<nsISupports> window; windowEnumerator->GetNext(getter_AddRefs(window)); nsCOMPtr<nsPIDOMWindow> domWindow(do_QueryInterface(window)); if (domWindow) { if (!domWindow->CanClose()) return NS_OK; } } } } mShuttingDown = PR_TRUE; if (!mRestart) { mRestart = (aMode & eRestart) != 0; gRestartMode = (aMode & 0xF0); } if (mRestart) { // Firefox-restarts reuse the process. Process start-time isn't a useful indicator of startup time PR_SetEnv(PR_smprintf("MOZ_APP_RESTART=%lld", (PRInt64) PR_Now() / PR_USEC_PER_MSEC)); } obsService = mozilla::services::GetObserverService(); if (!mAttemptingQuit) { mAttemptingQuit = PR_TRUE; #ifdef XP_MACOSX // now even the Mac wants to quit when the last window is closed ExitLastWindowClosingSurvivalArea(); #endif if (obsService) obsService->NotifyObservers(nsnull, "quit-application-granted", nsnull); } /* Enumerate through each open window and close it. It's important to do this before we forcequit because this can control whether we really quit at all. e.g. if one of these windows has an unload handler that opens a new window. Ugh. I know. */ CloseAllWindows(); if (mediator) { if (ferocity == eAttemptQuit) { ferocity = eForceQuit; // assume success /* Were we able to immediately close all windows? if not, eAttemptQuit failed. This could happen for a variety of reasons; in fact it's very likely. Perhaps we're being called from JS and the window->Close method hasn't had a chance to wrap itself up yet. So give up. We'll return (with eConsiderQuit) as the remaining windows are closed. */ mediator->GetEnumerator(nsnull, getter_AddRefs(windowEnumerator)); if (windowEnumerator) { PRBool more; while (windowEnumerator->HasMoreElements(&more), more) { /* we can't quit immediately. we'll try again as the last window finally closes. */ ferocity = eAttemptQuit; nsCOMPtr<nsISupports> window; windowEnumerator->GetNext(getter_AddRefs(window)); nsCOMPtr<nsIDOMWindowInternal> domWindow(do_QueryInterface(window)); if (domWindow) { PRBool closed = PR_FALSE; domWindow->GetClosed(&closed); if (!closed) { rv = NS_ERROR_FAILURE; break; } } } } } } } if (ferocity == eForceQuit) { // do it! // No chance of the shutdown being cancelled from here on; tell people // we're shutting down for sure while all services are still available. if (obsService) { NS_NAMED_LITERAL_STRING(shutdownStr, "shutdown"); NS_NAMED_LITERAL_STRING(restartStr, "restart"); obsService->NotifyObservers(nsnull, "quit-application", mRestart ? restartStr.get() : shutdownStr.get()); } if (!mRunning) { postedExitEvent = PR_TRUE; } else { // no matter what, make sure we send the exit event. If // worst comes to worst, we'll do a leaky shutdown but we WILL // shut down. Well, assuming that all *this* stuff works ;-). nsCOMPtr<nsIRunnable> event = new nsAppExitEvent(this); rv = NS_DispatchToCurrentThread(event); if (NS_SUCCEEDED(rv)) { postedExitEvent = PR_TRUE; } else { NS_WARNING("failed to dispatch nsAppExitEvent"); } } } // turn off the reentrancy check flag, but not if we have // more asynchronous work to do still. if (!postedExitEvent) mShuttingDown = PR_FALSE; return rv; }