bool LprSetupView::UpdateViewData() { if (*fServer->Text() && *fQueue->Text()) { try { LpsClient lpr(fServer->Text()); lpr.connect(); } catch (LPSException &err) { BAlert *alert = new BAlert("", err.what(), "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return false; } fDir->WriteAttr(LPR_SERVER_NAME, B_STRING_TYPE, 0, fServer->Text(), strlen(fServer->Text()) + 1); fDir->WriteAttr(LPR_QUEUE_NAME, B_STRING_TYPE, 0, fQueue->Text(), strlen(fQueue->Text()) + 1); return true; } BAlert *alert = new BAlert("", "Please enter server address and printer" "queue name.", "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return false; }
bool SetupView::CheckSetup() { if (*fServerAddress->Text() && *fQueuePort->Text()) { BNetEndpoint* ep = new BNetEndpoint(SOCK_STREAM); if (ep->InitCheck() == B_NO_ERROR) { uint16 port = atoi(fQueuePort->Text()); if (! port) port = 9100; if (ep->Connect(fServerAddress->Text(), port) != B_OK) { BString text; text << "Failed to connect to " << fServerAddress->Text() << ":" << (int) port << "!"; BAlert* alert = new BAlert("", text.String(), "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return false; }; char str[256]; sprintf(str, "%s:%d", fServerAddress->Text(), port); fPrinterDirectory->WriteAttr("transport_address", B_STRING_TYPE, 0, str, strlen(str) + 1); return true; }; }; BAlert* alert = new BAlert("", "Please input parameters.", "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return false; }
extern "C" void process_refs(entry_ref directoryRef, BMessage *msg, void *) { BDirectory directory(&directoryRef); if (directory.InitCheck() != B_OK) return; int32 errors = 0; entry_ref ref; int32 index; for (index = 0; msg->FindRef("refs", index, &ref) == B_OK; index ++) { BSymLink link(&ref); if (link.InitCheck() != B_OK || !link.IsSymLink()) { errors++; continue; } BEntry targetEntry; BPath path; if (link.MakeLinkedPath(&directory, &path) < B_OK || targetEntry.SetTo(path.Path()) != B_OK || targetEntry.GetParent(&targetEntry) != B_OK) { BAlert* alert = new BAlert("Open Target Folder", "Cannot open target folder. Maybe this link is broken?", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); continue; } // create Tracker message... entry_ref target; targetEntry.GetRef(&target); BMessage message(B_REFS_RECEIVED); message.AddRef("refs", &target); // ...and send it BMessenger messenger("application/x-vnd.Be-TRAK"); messenger.SendMessage(&message); // TODO: select entry via scripting? } if (errors) { BAlert* alert = new BAlert("Open Target Folder", "This add-on can only be used on symbolic links.\n" "It opens the folder of the link target in Tracker.", "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } }
void Window::MessageReceived(BMessage* message) { switch (message->what) { case kMsgShowAlert: { int32 count = fCountSlider->Value(); BAlert* alert = new BAlert("Test title", "Lorem ipsum dolor sit " "amet, consectetur adipiscing elit. Suspendisse vel iaculis " "quam. Donec faucibus erat nunc, ac ullamcorper justo sodales.", "short 1", count > 1 ? "a bit longer 2" : NULL, count > 2 ? "very very long button 3" : NULL, _ButtonWidth(), _ButtonSpacing(), _AlertType()); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); int result = alert->Go(); if (result < 0) { fLastStringView->SetText("Canceled alert"); } else { fLastStringView->SetText(BString().SetToFormat( "Pressed button %d", result + 1).String()); } break; } default: BWindow::MessageReceived(message); } }
bool ScreenWindow::QuitRequested() { fSettings->SetWindowFrame(Frame()); // Write mode of workspace 0 (the boot workspace) to the vesa settings file screen_mode vesaMode; if (fBootWorkspaceApplied && fScreenMode.Get(vesaMode, 0) == B_OK) { status_t status = _WriteVesaModeFile(vesaMode); if (status < B_OK) { BString warning = B_TRANSLATE("Could not write VESA mode settings" " file:\n\t"); warning << strerror(status); BAlert* alert = new BAlert(B_TRANSLATE("Warning"), warning.String(), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } be_app->PostMessage(B_QUIT_REQUESTED); return BWindow::QuitRequested(); }
void SyslogDaemon::AboutRequested() { BPath path; find_directory(B_SYSTEM_LOG_DIRECTORY, &path); path.Append("syslog"); BString name(B_TRANSLATE("Syslog Daemon")); BString message; snprintf(message.LockBuffer(512), 512, B_TRANSLATE("%s\n\nThis daemon is responsible for collecting " "all system messages and write them to the system-wide log " "at \"%s\".\n\n"), name.String(), path.Path()); message.UnlockBuffer(); BAlert *alert = new BAlert(name.String(), message.String(), B_TRANSLATE("OK")); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(21); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, name.Length(), &font); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); }
void DiskProbe::RefsReceived(BMessage* message) { bool traverseLinks = (modifiers() & B_SHIFT_KEY) == 0; int32 index = 0; entry_ref ref; while (message->FindRef("refs", index++, &ref) == B_OK) { const char* attribute = NULL; if (message->FindString("attributes", index - 1, &attribute) == B_OK) traverseLinks = false; BEntry entry; status_t status = entry.SetTo(&ref, traverseLinks); if (status == B_OK) status = Probe(entry, attribute); if (status != B_OK) { char buffer[1024]; snprintf(buffer, sizeof(buffer), B_TRANSLATE_COMMENT("Could not open \"%s\":\n" "%s", "Opening of entry reference buffer for a DiskProbe " "request Alert message. The name of entry reference and " "error message is shown."), ref.name, strerror(status)); BAlert* alert = new BAlert(B_TRANSLATE("DiskProbe request"), buffer, B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } } }
void LoginApp::ReadyToRun() { BScreen screen; if (fEditShelfMode) { BAlert* alert = new BAlert(B_TRANSLATE("Info"), B_TRANSLATE("You can " "customize the desktop shown behind the Login application by " "dropping replicants onto it.\n\n" "When you are finished just quit the application (Cmd-Q)."), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } else { BRect frame(0, 0, 450, 150); frame.OffsetBySelf(screen.Frame().Width()/2 - frame.Width()/2, screen.Frame().Height()/2 - frame.Height()/2); fLoginWindow = new LoginWindow(frame); fLoginWindow->Show(); } fDesktopWindow = new DesktopWindow(screen.Frame(), fEditShelfMode); fDesktopWindow->Show(); // TODO: add a shelf with Activity Monitor replicant :) }
static int ShowMessage(char* string) { BAlert *alert = new BAlert("Message", string, "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); return alert->Go(); }
void NotificationWindow::_LoadSettings(bool startMonitor) { BPath path; BMessage settings; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return; path.Append(kSettingsFile); BFile file(path.Path(), B_READ_ONLY | B_CREATE_FILE); settings.Unflatten(&file); _LoadGeneralSettings(settings); _LoadDisplaySettings(settings); _LoadAppFilters(settings); if (startMonitor) { node_ref nref; BEntry entry(path.Path()); entry.GetNodeRef(&nref); if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) { BAlert* alert = new BAlert(B_TRANSLATE("Warning"), B_TRANSLATE("Couldn't start general settings monitor.\n" "Live filter changes disabled."), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } } }
void HWindow::AboutRequested() { const char* aboutText = AboutText(); if (aboutText == NULL) return; BAlert *about = new BAlert("About", aboutText, "Cool"); BTextView *v = about->TextView(); if (v) { rgb_color red = {255, 0, 51, 255}; rgb_color blue = {0, 102, 255, 255}; v->SetStylable(true); char *text = (char*)v->Text(); char *s = text; // set all Be in blue and red while ((s = strstr(s, "Be")) != NULL) { int32 i = s - text; v->SetFontAndColor(i, i+1, NULL, 0, &blue); v->SetFontAndColor(i+1, i+2, NULL, 0, &red); s += 2; } // first text line s = strchr(text, '\n'); BFont font; v->GetFontAndColor(0, &font); font.SetSize(12); // font.SetFace(B_OUTLINED_FACE); v->SetFontAndColor(0, s-text+1, &font, B_FONT_SIZE); }; about->SetFlags(about->Flags() | B_CLOSE_ON_ESCAPE); about->Go(); }
CDPlayer::CDPlayer(BRect frame, const char *name, uint32 resizeMask, uint32 flags) : BView(frame, name, resizeMask, flags | B_FRAME_EVENTS), fCDQuery("freedb.freedb.org") { SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fVolume = 255; BuildGUI(); if (fCDDrive.CountDrives() < 1) { BAlert *alert = new BAlert("CDPlayer", B_TRANSLATE( "It appears that there are no CD" " drives on your computer or there is no system software to " "support one. Sorry."), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } fWindowState = fCDDrive.GetState(); fVolumeSlider->SetValue(fCDDrive.GetVolume()); if (fVolumeSlider->Value() <= 2) { fCDDrive.SetVolume(255); fVolumeSlider->SetValue(255); } _WatchCDState(); }
void ConfigWindow::_RevertToLastSettings() { // revert general settings BMailSettings settings; status_t status = _SetToGeneralSettings(&settings); if (status != B_OK) { char text[256]; sprintf(text, B_TRANSLATE( "\nThe general settings couldn't be reverted.\n\n" "Error retrieving general settings:\n%s\n"), strerror(status)); BAlert* alert = new BAlert(B_TRANSLATE("Error"), text, B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } // revert account data if (fAccountsListView->CurrentSelection() != -1) _ReplaceConfigView(_BuildHowToView()); for (int32 i = 0; i < fAccounts.CountItems(); i++) { BMailAccountSettings* account = fAccounts.ItemAt(i); _RemoveAccountFromListView(account); delete account; } fAccounts.MakeEmpty(); _LoadAccounts(); }
void PulseApp::ShowAbout(bool asApplication) { // static version to be used in replicant mode BString name; if (asApplication) name = B_TRANSLATE_SYSTEM_NAME("Pulse"); else name = B_TRANSLATE("Pulse"); BString message = B_TRANSLATE( "%s\n\nBy David Ramsey and Arve Hjønnevåg\n" "Revised by Daniel Switkin\n"); message.ReplaceFirst("%s", name); BAlert *alert = new BAlert(B_TRANSLATE("Info"), message.String(), B_TRANSLATE("OK")); BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(18); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, name.Length(), &font); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); // Use the asynchronous version so we don't block the window's thread alert->Go(NULL); }
void SnowView::MessageReceived(BMessage *msg) { BAlert *info; //msg->PrintToStream(); switch (msg->what) { case MSG_PULSE_ME: if (Parent()) { Calc(); InvalFlakes(); } break; case B_ABOUT_REQUESTED: info = new BAlert("BSnow info", "BSnow, just in case you don't have real one...\n" "" B_UTF8_COPYRIGHT " 2003, François Revol.", "Where is Santa ??"); info->SetFeel(B_NORMAL_WINDOW_FEEL); info->SetLook(B_FLOATING_WINDOW_LOOK); info->SetFlags(info->Flags()|B_NOT_ZOOMABLE); info->Go(NULL); break; default: //#ifdef FORWARD_TO_PARENT /* if (fAttached && Parent()) Parent()->MessageReceived(msg); else */ //#endif BView::MessageReceived(msg); } }
void HEventList::SelectionChanged() { BColumnListView::SelectionChanged(); HEventRow* row = (HEventRow*)CurrentSelection(); if (row != NULL) { entry_ref ref; BMediaFiles().GetRefFor(fType, row->Name(), &ref); BPath path(&ref); if (path.InitCheck() == B_OK || ref.name == NULL || strcmp(ref.name, "") == 0) { row->SetPath(path.Path()); UpdateRow(row); } else { printf("name %s\n", ref.name); BMediaFiles().RemoveRefFor(fType, row->Name(), ref); BAlert* alert = new BAlert("alert", B_TRANSLATE("No such file or directory"), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return; } BMessage msg(M_EVENT_CHANGED); msg.AddString("name", row->Name()); msg.AddString("path", row->Path()); Window()->PostMessage(&msg); } }
void AutoMounter::_MountVolume(const BMessage* message) { int32 id; if (message->FindInt32("id", &id) != B_OK) return; BDiskDeviceRoster roster; BPartition *partition; BDiskDevice device; if (roster.GetPartitionWithID(id, &device, &partition) != B_OK) return; uint32 mountFlags; if (!_SuggestMountFlags(partition, &mountFlags)) return; status_t status = partition->Mount(NULL, mountFlags); if (status < B_OK) { char text[512]; snprintf(text, sizeof(text), B_TRANSLATE("Error mounting volume:\n\n%s"), strerror(status)); BAlert* alert = new BAlert(B_TRANSLATE("Mount error"), text, B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } }
void AGMSBayesianSpamFilterConfig::ShowSpamServerConfigurationWindow () { status_t errorCode = B_OK; BMessage maximizeCommand; BMessenger messengerToServer; BMessage replyMessage; // Make sure the server is running. if (!be_roster->IsRunning (kServerSignature)) { errorCode = be_roster->Launch (kServerSignature); if (errorCode != B_OK) { BPath path; entry_ref ref; directory_which places[] = { B_SYSTEM_NONPACKAGED_BIN_DIRECTORY, B_SYSTEM_BIN_DIRECTORY }; for (int32 i = 0; i < 2; i++) { find_directory(places[i],&path); path.Append("spamdbm"); if (!BEntry(path.Path()).Exists()) continue; get_ref_for_path(path.Path(),&ref); if ((errorCode = be_roster->Launch (&ref)) == B_OK) break; } if (errorCode != B_OK) goto ErrorExit; } } // Set up the messenger to the database server. messengerToServer = BMessenger (kServerSignature); if (!messengerToServer.IsValid ()) goto ErrorExit; // Wait for the server to finish starting up, and for it to create the window. snooze (2000000); // Tell it to show its main window, in case it is hidden in server mode. maximizeCommand.what = B_SET_PROPERTY; maximizeCommand.AddBool ("data", false); maximizeCommand.AddSpecifier ("Minimize"); maximizeCommand.AddSpecifier ("Window", (int32)0); errorCode = messengerToServer.SendMessage (&maximizeCommand, &replyMessage); if (errorCode != B_OK) goto ErrorExit; return; // Successful. ErrorExit: BAlert* alert = new BAlert ("SpamFilterConfig Error", B_TRANSLATE("Sorry, " "unable to launch the spamdbm program to let you edit the server " "settings."), B_TRANSLATE("Close")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go (); return; }
IppTransport::~IppTransport() { string error_msg; if (!__error && __fs.good()) { DBGMSG(("create IppContent\n")); IppContent *request = new IppContent; request->setOperationId(IPP_PRINT_JOB); request->setDelimiter(IPP_OPERATION_ATTRIBUTES_TAG); request->setCharset("attributes-charset", "utf-8"); request->setNaturalLanguage("attributes-natural-language", "en-us"); request->setURI("printer-uri", __url); request->setMimeMediaType("document-format", "application/octet-stream"); request->setNameWithoutLanguage("requesting-user-name", __user); // request->setNameWithoutLanguage("job-name", __file); // optional request->setDelimiter(IPP_END_OF_ATTRIBUTES_TAG); long fssize = __fs.tellg(); __fs.seekg(0, ios::beg); request->setRawData(__fs, fssize); URL url(__url); IppURLConnection conn(url); conn.setIppRequest(request); conn.setRequestProperty("Connection", "close"); DBGMSG(("do connect\n")); HTTP_RESPONSECODE response_code = conn.getResponseCode(); if (response_code == HTTP_OK) { const char *content_type = conn.getContentType(); if (content_type && !strncasecmp(content_type, "application/ipp", 15)) { const IppContent *ipp_response = conn.getIppResponse(); if (ipp_response->fail()) { __error = true; error_msg = ipp_response->getStatusMessage(); } } else { __error = true; error_msg = "cannot get a IPP response."; } } else if (response_code != HTTP_UNKNOWN) { __error = true; error_msg = conn.getResponseMessage(); } else { __error = true; error_msg = "cannot connect to the IPP server."; } } unlink(__file); if (__error) { BAlert *alert = new BAlert("", error_msg.c_str(), "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } }
void MainWindow::Open(const BMessenger& externalObserver, const uint8* data, size_t size) { if (!_CheckSaveIcon(CurrentMessage())) return; if (!externalObserver.IsValid()) return; Icon* icon = new (nothrow) Icon(); if (!icon) return; if (data && size > 0) { // try to open the icon from the provided data FlatIconImporter flatImporter; status_t ret = flatImporter.Import(icon, const_cast<uint8*>(data), size); // NOTE: the const_cast is a bit ugly, but no harm is done // the reason is that the LittleEndianBuffer knows read and write // mode, in this case it is used read-only, and it does not assume // ownership of the buffer if (ret < B_OK) { // inform user of failure at this point BString helper(B_TRANSLATE("Opening the icon failed!")); helper << "\n\n" << B_TRANSLATE("Error: ") << strerror(ret); BAlert* alert = new BAlert( B_TRANSLATE_CONTEXT("bad news", "Title of error alert"), helper.String(), B_TRANSLATE_CONTEXT("Bummer", "Cancel button - error alert"), NULL, NULL); // launch alert asynchronously alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); delete icon; return; } } AutoWriteLocker locker(fDocument); SetIcon(NULL); // incorporate the loaded icon into the document // (either replace it or append to it) fDocument->MakeEmpty(); fDocument->SetIcon(icon); fDocument->SetNativeSaver(new MessengerSaver(externalObserver)); locker.Unlock(); SetIcon(icon); }
void DataTranslationsWindow::_ShowInfoAlert(int32 id) { const char* name = NULL; const char* info = NULL; BPath path; int32 version = 0; _GetTranslatorInfo(id, name, info, version, path); const char* labels[] = { B_TRANSLATE("Name:"), B_TRANSLATE("Version:"), B_TRANSLATE("Info:"), B_TRANSLATE("Path:"), NULL }; int offsets[4]; BString message; BString temp; offsets[0] = 0; temp.SetToFormat("%s %s\n", labels[0], name); message.Append(temp); offsets[1] = message.Length(); // Convert the version number into a readable format temp.SetToFormat("%s %" B_PRId32 ".%" B_PRId32 ".%" B_PRId32 "\n\n", labels[1], B_TRANSLATION_MAJOR_VERSION(version), B_TRANSLATION_MINOR_VERSION(version), B_TRANSLATION_REVISION_VERSION(version)); message.Append(temp); offsets[2] = message.Length(); temp.SetToFormat("%s\n%s\n\n", labels[2], info); message.Append(temp); offsets[3] = message.Length(); temp.SetToFormat("%s %s\n", labels[3], path.Path()); message.Append(temp); BAlert* alert = new BAlert(B_TRANSLATE("Info"), message.String(), B_TRANSLATE("OK")); BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetFace(B_BOLD_FACE); for (int32 i = 0; labels[i]; i++) { view->SetFontAndColor(offsets[i], offsets[i] + strlen(labels[i]), &font); } alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
void PoorManWindow::DefaultSettings() { BAlert* serverAlert = new BAlert(B_TRANSLATE("Error Server"), STR_ERR_CANT_START, B_TRANSLATE("OK")); serverAlert->SetFlags(serverAlert->Flags() | B_CLOSE_ON_ESCAPE); BAlert* dirAlert = new BAlert(B_TRANSLATE("Error Dir"), STR_ERR_WEB_DIR, B_TRANSLATE("Cancel"), B_TRANSLATE("Select"), B_TRANSLATE("Create public_html"), B_WIDTH_AS_USUAL, B_OFFSET_SPACING); dirAlert->SetShortcut(0, B_ESCAPE); int32 buttonIndex = dirAlert->Go(); switch (buttonIndex) { case 0: if (Lock()) Quit(); be_app_messenger.SendMessage(B_QUIT_REQUESTED); break; case 1: fPrefWindow = new PoorManPreferencesWindow( fSetwindowFrame, STR_WIN_NAME_PREF); fPrefWindow->ShowWebDirFilePanel(); break; case 2: if (create_directory(STR_DEFAULT_WEB_DIRECTORY, 0755) != B_OK) { serverAlert->Go(); if (Lock()) Quit(); be_app_messenger.SendMessage(B_QUIT_REQUESTED); break; } BAlert* dirCreatedAlert = new BAlert(B_TRANSLATE("Dir Created"), STR_DIR_CREATED, B_TRANSLATE("OK")); dirCreatedAlert->SetFlags(dirCreatedAlert->Flags() | B_CLOSE_ON_ESCAPE); dirCreatedAlert->Go(); SetWebDir(STR_DEFAULT_WEB_DIRECTORY); be_app->PostMessage(kStartServer); break; } }
bool ShortcutsWindow::QuitRequested() { bool ret = true; if (fKeySetModified) { BAlert* alert = new BAlert(WARNING, B_TRANSLATE("Save changes before closing?"), B_TRANSLATE("Cancel"), B_TRANSLATE("Don't save"), B_TRANSLATE("Save")); alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(1, 'd'); alert->SetShortcut(2, 's'); switch(alert->Go()) { case 0: ret = false; break; case 1: ret = true; break; case 2: // Save: automatically if possible, otherwise go back and open // up the file requester if (fLastSaved.InitCheck() == B_OK) { if (_SaveKeySet(fLastSaved) == false) { BAlert* alert = new BAlert(ERROR, B_TRANSLATE("Shortcuts was unable to save your " "KeySet file!"), B_TRANSLATE("Oh no")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); ret = true; //quit anyway } } else { PostMessage(SAVE_KEYSET); ret = false; } break; } } if (ret) { fColumnListView->DeselectAll(); // Save the window position. entry_ref ref; if (_GetWindowSettingsFile(&ref)) { BEntry entry(&ref); _SaveWindowSettings(entry); } } return ret; }
void MainWin::SelectInterface(int i) { printf("MainWin::SelectInterface %d\n", i); printf(" CurrentInterface %d\n", fController->CurrentInterface()); printf(" CurrentChannel %d\n", fController->CurrentChannel()); // i = -1 means "None" if (i < 0) { fController->DisconnectInterface(); goto done; } if (!fController->IsInterfaceAvailable(i)) { BString s; s << B_TRANSLATE("Error, interface is busy:\n\n"); s << gDeviceRoster->DeviceName(i); BAlert* alert = new BAlert("error", s.String(), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return; } fController->DisconnectInterface(); if (fController->ConnectInterface(i) != B_OK) { BString s; s << B_TRANSLATE("Error, connecting to interface failed:\n\n"); s << gDeviceRoster->DeviceName(i); BAlert* alert = new BAlert("error", s.String(), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } done: printf("MainWin::SelectInterface done:\n"); printf(" CurrentInterface %d\n", fController->CurrentInterface()); printf(" CurrentChannel %d\n", fController->CurrentChannel()); SetInterfaceMenuMarker(); SetupChannelMenu(); SetChannelMenuMarker(); }
void JoyWin::_ShowNoDeviceConnectedMessage(const char* joy, const char* port) { BString str("There does not appear to be a "); str << joy << " device connected to the port '" << port << "'."; BAlert *alert = new BAlert("test1", str.String(), "Stop"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
void LoginApp::MessageReceived(BMessage *message) { bool reboot = false; switch (message->what) { case kAttemptLogin: message->PrintToStream(); TryLogin(message); // TODO break; #ifdef __HAIKU__ case kHaltAction: reboot = false; // FALLTHROUGH case kRebootAction: { BRoster roster; BRoster::Private rosterPrivate(roster); status_t error = rosterPrivate.ShutDown(reboot, false, false); if (error < B_OK) { BString msg(B_TRANSLATE("Error: %1")); msg.ReplaceFirst("%1", strerror(error)); BAlert* alert = new BAlert(("Error"), msg.String(), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } break; } case kSuspendAction: { BAlert* alert = new BAlert(B_TRANSLATE("Error"), B_TRANSLATE("Unimplemented"), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); break; } #endif default: BApplication::MessageReceived(message); } }
void BApplication::AboutRequested() { thread_info info; if (get_thread_info(Thread(), &info) == B_OK) { BAlert* alert = new BAlert("_about_", info.name, "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } }
static void Error(BView *view, status_t status, bool unlock=false) { BAlert *alert; if (view && unlock) view->UnlockLooper(); BString s(strerror(status)); alert = new BAlert("Error", s.String(), "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
void LookAndFeelSettingsView::MessageReceived(BMessage *msg) { switch (msg->what) { case kMsgSetDecor: { BString newDecor; if (msg->FindString("decor", &newDecor) == B_OK) _SetDecor(newDecor); break; } case kMsgDecorInfo: { DecorInfo* decor = fDecorUtility.FindDecorator(fCurrentDecor); if (decor == NULL) break; BString authorsText(decor->Authors().String()); authorsText.ReplaceAll(", ", "\n\t"); BString infoText(B_TRANSLATE("%decorName\n\n" "Authors:\n\t%decorAuthors\n\n" "URL: %decorURL\n" "License: %decorLic\n\n" "%decorDesc\n")); infoText.ReplaceFirst("%decorName", decor->Name().String()); infoText.ReplaceFirst("%decorAuthors", authorsText.String()); infoText.ReplaceFirst("%decorLic", decor->LicenseName().String()); infoText.ReplaceFirst("%decorURL", decor->SupportURL().String()); infoText.ReplaceFirst("%decorDesc", decor->ShortDescription().String()); BAlert *infoAlert = new BAlert(B_TRANSLATE("About decorator"), infoText.String(), B_TRANSLATE("OK")); infoAlert->SetFlags(infoAlert->Flags() | B_CLOSE_ON_ESCAPE); infoAlert->Go(); break; } case kMsgArrowStyleSingle: _SetDoubleScrollBarArrows(false); break; case kMsgArrowStyleDouble: _SetDoubleScrollBarArrows(true); break; default: BView::MessageReceived(msg); break; } }
void JoyWin::_ShowNoCompatibleJoystickMessage() { BString str("There were no compatible joysticks detected on this game"); str << " port. Try another port, or ask the manufacturer of your joystick"; str << " for a driver designed for Haiku or BeOS."; BAlert *alert = new BAlert("test1", str.String(), "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }