void ParameterWindow::MessageReceived( BMessage *message) { D_MESSAGE(("ParameterWindow::MessageReceived()\n")); switch (message->what) { case M_START_CONTROL_PANEL: { D_MESSAGE((" -> M_START_CONTROL_PANEL\n")); status_t error = _startControlPanel(); if (error) { BString s = "Could not start control panel"; s << " (" << strerror(error) << ")"; BAlert *alert = new BAlert("", s.String(), "OK", 0, 0, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->Go(0); } bool replace = false; if ((message->FindBool("replace", &replace) == B_OK) && (replace == true)) { PostMessage(B_QUIT_REQUESTED); } break; } case M_THEME_SELECTED: { D_MESSAGE((" -> M_THEME_SELECTED\n")); int32 themeID; if (message->FindInt32("themeID", &themeID) != B_OK) { return; } // not yet implemented break; } case B_MEDIA_WEB_CHANGED: { D_MESSAGE((" -> B_MEDIA_WEB_CHANGED\n")); _updateParameterView(); _constrainToScreen(); break; } default: { BWindow::MessageReceived(message); } } }
int Error::ShowError(string_slice msg1, string_slice msg2, int err) { qstring msg = msg1; msg += msg2; if (err != 0) { msg += " ("; const char* errStr = ErrorString(err); if (errStr != NULL) msg += errStr; else msg += err; msg += ")"; } BAlert* alert = new BAlert("Error alert", msg.c_str(), "OK"); alert->SetShortcut(0, ' '); alert->Go(); return err; }
// CreateExistingProject -- Saves only the necessary bits - asks if you to recreate void NewProjectWindow::CreateExistingProject(void) { char tmp[256]; //char cmd[256]; BAlert *alert; long result; sprintf(tmp,"Would you like to Recreate your Project \"%s\".\n\nPlease note this means all the existing files will be overwritten.\n\nIf you are unsure, click No.",ProjectName.String()); alert = new BAlert("", tmp, " Yes ", " No ", NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); result = alert->Go(); if (result == B_OK) { // right - do the lot CreateNewProject(); } else { // Only save necessary bits like project ptrFileWindow->SaveProject(); } }
bool MainWindow::QuitRequested() { int32 padWindowCount = 0; for (int32 i = 0; BWindow* window = be_app->WindowAt(i); i++) { if (dynamic_cast<MainWindow*>(window)) padWindowCount++; } if (padWindowCount == 1) { be_app->PostMessage(B_QUIT_REQUESTED); return false; } else { BAlert* alert = new BAlert("last chance", "Really close this pad?\n" "(The pad will not be remembered.)", "Close", "Cancel", NULL); if (alert->Go() == 1) return false; } return true; }
void App::_CheckPackageDaemonRuns() { while (!be_roster->IsRunning(kPackageDaemonSignature)) { BAlert* alert = new BAlert("start_package_daemon", B_TRANSLATE("HaikuDepot needs the package daemon to function, " "and it appears to be not running.\n" "Would you like to start it now?"), B_TRANSLATE("No, quit HaikuDepot"), B_TRANSLATE("Start package daemon"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->SetShortcut(0, B_ESCAPE); if (alert->Go() == 0) exit(1); if (!_LaunchPackageDaemon()) break; } }
void WorkspacesView::_AboutRequested() { BAlert *alert = new BAlert("about", "Workspaces\n" "written by François Revol, Axel Dörfler, and Matt Madia.\n\n" "Copyright 2002-2008, Antares.\n\n" "Send windows behind using the Option key. " "Move windows to front using the Control key.\n", "OK"); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(18); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, 10, &font); alert->Go(); }
void OverlayView::OverlayAboutRequested() { BAlert *alert = new BAlert("about", "OverlayImage\n" "Copyright 1999-2010\n\n\t" "originally by Seth Flaxman\n\t" "modified by Hartmuth Reh\n\t" "further modified by Humdinger\n", "OK"); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(font.Size() + 7.0f); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, 12, &font); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
void AppWindow::AboutRequested() { PRINT(("AppWindow::AboutRequested()\n")); BString msg; msg = APPLICATION " " VERSION "\n\n" "Created by Jason Burgess of now defunct FlipSide Software. " "His former website has since been taken over by " "another company by the same name.\n\n" "The FlipSide Software applications are hosted by HaikuArchives at github.com/Haiku/Archives\n\n" MAINTAINER " is the current maintainer.\n" "To request new features, or to report bugs, file a new issue at:\n" "http://github.com/HaikuArchives/ArmyKnife/issues"; BAlert* alert = new BAlert("AboutBox", msg.String(), ABOUT_BTN); alert->Go(NULL); }
int32 ShowAlert(const char *message, const char *button1, const char *button2, const char *button3, alert_type type) { int32 result; if (gBuildMode) { printf("%s\n", message); result = -1; } else { BString label1 = button1 ? button1 : "OK"; BAlert *alert = new BAlert("Paladin", message, label1.String(), button2, button3, B_WIDTH_AS_USUAL, type); result = alert->Go(); } return result; }
status_t DisplayView::Save() { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return B_ERROR; path.Append(kSettingsDirectory); path.Append(kDisplaySettings); BMessage settings; float width = atof(fWindowWidth->Text()); settings.AddFloat(kWidthName, width); icon_size iconSize = kDefaultIconSize; switch (fIconSize->IndexOf(fIconSize->FindMarked())) { case 0: iconSize = B_MINI_ICON; break; default: iconSize = B_LARGE_ICON; } settings.AddInt32(kIconSizeName, (int32)iconSize); // Save settings file BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); status_t ret = settings.Flatten(&file); if (ret != B_OK) { BAlert* alert = new BAlert("", B_TRANSLATE("Can't save preferenes, you probably don't have " "write access to the settings directory or the disk is full."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); (void)alert->Go(); return ret; } return B_OK; }
void PasswordWindow::MessageReceived(BMessage *message) { switch (message->what) { case kMsgDone: fSettings.SetLockMethod(fUseCustom->Value() ? "custom" : "network"); if (fUseCustom->Value()) { if (strcmp(fPasswordControl->Text(), fConfirmControl->Text())) { BAlert *alert = new BAlert("noMatch", "Passwords don't match. Please try again.","OK"); alert->Go(); break; } const char *salt = _SanitizeSalt(fPasswordControl->Text()); fSettings.SetPassword(crypt(fPasswordControl->Text(), salt)); delete salt; } else { fSettings.SetPassword(""); } fPasswordControl->SetText(""); fConfirmControl->SetText(""); fSettings.Save(); Hide(); break; case B_CANCEL: fPasswordControl->SetText(""); fConfirmControl->SetText(""); Hide(); break; case kMsgPasswordTypeChanged: fSettings.SetLockMethod(fUseCustom->Value() > 0 ? "custom" : "network"); Update(); break; default: BWindow::MessageReceived(message); break; } }
void ScreenshotWindow::_ShowSettings(bool activate) { if (!fSettingsWindow && !activate) return; // Find a translator translator_id translator; if (fUtility.FindTranslator(fImageFileType, translator) != B_OK) return; // Create a window with a configuration view BView* view; BRect rect(0, 0, 239, 239); status_t status = BTranslatorRoster::Default()->MakeConfigurationView( translator, NULL, &view, &rect); if (status != B_OK || view == NULL) { // TODO: proper translation, better error dialog BAlert* alert = new BAlert(NULL, strerror(status), "OK"); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } else if (fSettingsWindow != NULL) { fSettingsWindow->RemoveChild(fSettingsWindow->ChildAt(0)); float width, height; view->GetPreferredSize(&width, &height); fSettingsWindow->ResizeTo(width, height); fSettingsWindow->AddChild(view); if (activate) fSettingsWindow->Activate(); } else { fSettingsWindow = new BWindow(rect, B_TRANSLATE("Translator Settings"), B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_RESIZABLE); fSettingsWindow->AddFilter(new QuitMessageFilter(this)); fSettingsWindow->AddChild(view); fSettingsWindow->CenterOnScreen(); fSettingsWindow->Show(); } }
void TTracker::InstallTemporaryBackgroundImages() { // make the large Haiku Logo the default background BPath path; status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path); if (status < B_OK) { // TODO: this error shouldn't be shown to the regular user BString errorMessage(B_TRANSLATE("At %func \nfind_directory() " "failed. \nReason: %error")); errorMessage.ReplaceFirst("%func", __PRETTY_FUNCTION__); errorMessage.ReplaceFirst("%error", strerror(status)); BAlert* alert = new BAlert("AlertError", errorMessage.String(), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); return; } path.Append("artwork"); BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png"); BDirectory dir; if (FSGetBootDeskDir(&dir) == B_OK) { // install a default background if there is no background defined yet attr_info info; if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) { BScreen screen(B_MAIN_SCREEN_ID); BPoint logoPos; logoPos.x = floorf((screen.Frame().Width() - 605) * (sqrtf(5) - 1) / 2); logoPos.y = floorf((screen.Frame().Height() - 190) * 0.9); BMessage message; AddTemporaryBackgroundImages(&message, (BString(path.Path()) << defaultBackgroundImage).String(), BackgroundImage::kAtOffset, logoPos, 0xffffffff, false); ::InstallTemporaryBackgroundImages(&dir, &message); } } }
void TPeopleApp::MessageReceived(BMessage* message) { switch (message->what) { case M_NEW: case B_SILENT_RELAUNCH: _NewWindow(); break; case M_WINDOW_QUITS: _SavePreferences(message); fWindowCount--; if (fWindowCount < 1) PostMessage(B_QUIT_REQUESTED); break; case M_CONFIGURE_ATTRIBUTES: { const char* arguments[] = { "-type", B_PERSON_MIMETYPE, 0 }; status_t ret = be_roster->Launch( "application/x-vnd.Haiku-FileTypes", sizeof(arguments) / sizeof(const char*) - 1, const_cast<char**>(arguments)); if (ret != B_OK && ret != B_ALREADY_RUNNING) { BString errorMsg(B_TRANSLATE("Launching the FileTypes " "preflet to configure Person attributes has failed." "\n\nError: ")); errorMsg << strerror(ret); BAlert* alert = new BAlert(B_TRANSLATE("Error"), errorMsg.String(), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); } break; } default: BApplication::MessageReceived(message); } }
void NotificationWindow::_LoadGeneralSettings(bool startMonitor) { BPath path; BMessage settings; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return; path.Append(kSettingsDirectory); if (create_directory(path.Path(), 0755) == B_OK) { path.Append(kGeneralSettings); BFile file(path.Path(), B_READ_ONLY); settings.Unflatten(&file); } if (settings.FindInt32(kTimeoutName, &fTimeout) != B_OK) fTimeout = kDefaultTimeout; // Notify the view about the change views_t::iterator it; for (it = fViews.begin(); it != fViews.end(); ++it) { NotificationView* view = (*it); view->SetText(view->Application(), view->Title(), view->Text()); view->Invalidate(); } 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->Go(); } } }
void NetworkWindow::_ShowReplicant(bool show) { if (show) { const char* argv[] = {"--deskbar", NULL}; status_t status = be_roster->Launch(kNetworkStatusSignature, 1, argv); if (status != B_OK) { BString errorMessage; errorMessage.SetToFormat( B_TRANSLATE("Installing NetworkStatus in Deskbar failed: %s"), strerror(status)); BAlert* alert = new BAlert(B_TRANSLATE("launch error"), errorMessage, B_TRANSLATE("Ok")); alert->Go(NULL); } } else { BDeskbar deskbar; deskbar.RemoveItem("NetworkStatus"); } }
void FileTypes::AboutRequested() { BString aboutText(B_TRANSLATE("FileTypes")); int32 titleLength = aboutText.Length(); aboutText << "\n"; aboutText << B_TRANSLATE("\twritten by Axel Dörfler\n" "\tCopyright 2006-2007, Haiku.\n"); BAlert *alert = new BAlert("about", aboutText.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, titleLength, &font); alert->Go(); }
void StatusView::_OpenPreferences() { status_t ret = be_roster->Launch(kPrefSignature); if (ret == B_ALREADY_RUNNING) { app_info info; ret = be_roster->GetAppInfo(kPrefSignature, &info); if (ret == B_OK) ret = be_roster->ActivateApp(info.team); } if (ret < B_OK) { BString errorMessage(B_TRANSLATE( "Launching the CPU frequency preflet failed.\n\nError: ")); errorMessage << strerror(ret); BAlert* alert = new BAlert("launch error", errorMessage.String(), "Ok"); // asynchronous alert in order to not block replicant host // application alert->Go(NULL); } }
status_t GeneralView::Load() { BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) return B_ERROR; path.Append(kSettingsDirectory); if (create_directory(path.Path(), 0755) != B_OK) { BAlert* alert = new BAlert("", B_TRANSLATE("There was a problem saving the preferences.\n" "It's possible you don't have write access to the " "settings directory."), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); (void)alert->Go(); } path.Append(kGeneralSettings); BMessage settings; BFile file(path.Path(), B_READ_ONLY); settings.Unflatten(&file); char buffer[255]; bool autoStart; if (settings.FindBool(kAutoStartName, &autoStart) != B_OK) autoStart = kDefaultAutoStart; fAutoStart->SetValue(autoStart ? B_CONTROL_ON : B_CONTROL_OFF); int32 timeout; if (settings.FindInt32(kTimeoutName, &timeout) != B_OK) timeout = kDefaultTimeout; (void)sprintf(buffer, "%ld", timeout); fTimeout->SetText(buffer); return B_OK; }
void MidiPlayerWindow::LoadFile(entry_ref* ref) { if (playing) { scopeView->SetPlaying(false); scopeView->Invalidate(); UpdateIfNeeded(); StopSynth(); } synth.UnloadFile(); if (synth.LoadFile(ref) == B_OK) { // Ideally, we would call SetVolume() in InitControls(), // but for some reason that doesn't work: BMidiSynthFile // will use the default volume instead. So we do it here. synth.SetVolume(volume / 100.0f); playButton->SetEnabled(true); playButton->SetLabel(B_TRANSLATE("Stop")); scopeView->SetHaveFile(true); scopeView->SetPlaying(true); scopeView->Invalidate(); StartSynth(); } else { playButton->SetEnabled(false); playButton->SetLabel(B_TRANSLATE("Play")); scopeView->SetHaveFile(false); scopeView->SetPlaying(false); scopeView->Invalidate(); BAlert* alert = new BAlert(NULL, B_TRANSLATE("Could not load song"), B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); } }
Preferences::~Preferences() { if (fSavePreferences) { BFile file; status_t set = B_ERROR; if (fSettingsFile) file.SetTo(fSettingsFile, B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); else { BPath prefpath; if (find_directory(B_USER_SETTINGS_DIRECTORY, &prefpath, true) == B_OK) { BDirectory prefdir(prefpath.Path()); set = prefdir.CreateFile(fName, &file, false); } } if (file.InitCheck () == B_OK) { Flatten(&file); if (fSignature) { file.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0, fSignature, strlen(fSignature) + 1); } } else { // implement saving somewhere else! BString error; snprintf(error.LockBuffer(256), 256, B_TRANSLATE("Your setting file could not be saved!\n(%s)"), strerror(file.InitCheck())); error.UnlockBuffer(); BAlert *alert = new BAlert(B_TRANSLATE("Error saving file"), error.String(), B_TRANSLATE("Damned!"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT); alert->SetShortcut(0, B_ESCAPE); alert->Go(); } } delete fSettingsFile; free(fName); free(fSignature); }
bool BeHappy::CheckAddOn(const char *path,bool alert,BString *pName) { image_id addOnImage = load_add_on(path); void *instFunc; const char **projName; const uint16 *BHVersion,*BHVLastCompatible; bool ok = false; BPath aoPath(path); BString alTxt(aoPath.Leaf()); // chaîne utilisée pour générer des alertes d'erreur if ((addOnImage>=0) && (get_image_symbol(addOnImage,"InstantiateProject",B_SYMBOL_TYPE_ANY,&instFunc) == B_OK) && (get_image_symbol(addOnImage,"projectName",B_SYMBOL_TYPE_ANY,(void**)&projName) == B_OK) && (get_image_symbol(addOnImage,"BHVersion",B_SYMBOL_TYPE_ANY,(void**)&BHVersion) == B_OK) && (get_image_symbol(addOnImage,"BHVLastCompatible",B_SYMBOL_TYPE_ANY,(void**)&BHVLastCompatible) == B_OK)) { if ((*BHVLastCompatible) > bhv_application) { if (alert) { alTxt << " " << T("isn't compatible with this (old) version of BeHappy. Please download a more recent version of BeHappy."); BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK", NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT); myAlert->Go(); } } else if ((*BHVersion) < bhv_last_addon) { if (alert) { alTxt << " " << T("is too old, and isn't compatible with this version of BeHappy. Please find a more recent version of the add-on."); BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK", NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT); myAlert->Go(); } } else { ok = true; if (pName != NULL) *pName=*projName; } } else { if (alert) { alTxt << " " << T("is an invalid BeHappy add-on."); BAlert *myAlert = new BAlert("BeHappy",alTxt.String(),"OK", NULL,NULL,B_WIDTH_AS_USUAL,B_WARNING_ALERT); myAlert->Go(); } } if (addOnImage>=0) unload_add_on(addOnImage); return ok; }
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 PersonView::Reload(const entry_ref* ref) { if (fReloading == true) return; else fReloading = true; BAlert* panel = new BAlert( "", "The file has been modified by another application\n" "Do you want to reload it?\n\n", "Reload", "No"); int32 index = panel->Go(); if (index == 1) { fSaved = false; fReloading = false; return; } if (ref != NULL) { delete fContactFile; fContactFile = new BFile(ref, B_READ_WRITE); fContact->Append(new BRawContact(B_CONTACT_ANY, fContactFile)); } fContact->Reload(); for (int i = 0; i < fControls.CountItems(); i++) { ContactFieldTextControl* control = fControls.ItemAt(i); fControls.RemoveItem(control); RemoveChild(control); delete control; } _LoadFieldsFromContact(); fSaved = true; fReloading = false; }
void ExpanderApp::AboutRequested() { BString appName = B_TRANSLATE("Expander"); int nameLength = appName.CountChars(); BAlert* alert = new BAlert("about", appName.Append(B_TRANSLATE("\n\twritten by Jérôme Duval\n" "\tCopyright 2004-2006, Haiku Inc.\n\noriginal Be version by \n" "Dominic, Hiroshi, Peter, Pavel and Robert\n")), 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, nameLength, &font); alert->Go(); }
bool LoadInDeskbar() { PulseApp *pulseapp = (PulseApp *)be_app; BDeskbar *deskbar = new BDeskbar(); // Don't allow two copies in the Deskbar at once if (deskbar->HasItem("DeskbarPulseView")) { delete deskbar; return false; } // Must be 16 pixels high, the width is retrieved from the Prefs class int width = pulseapp->prefs->deskbar_icon_width; int min_width = GetMinimumViewWidth(); if (width < min_width) { pulseapp->prefs->deskbar_icon_width = min_width; width = min_width; } float height = deskbar->MaxItemHeight(); BRect rect(0, 0, width - 1, height - 1); DeskbarPulseView *replicant = new DeskbarPulseView(rect); status_t err = deskbar->AddItem(replicant); delete replicant; delete deskbar; if (err != B_OK) { BString message; snprintf(message.LockBuffer(512), 512, B_TRANSLATE("Installing in Deskbar failed\n%s"), strerror(err)); message.UnlockBuffer(); BAlert *alert = new BAlert(B_TRANSLATE("Error"), message.String(), B_TRANSLATE("OK")); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); return false; } return true; }
void DataTranslationsWindow::_ShowInfoAlert(int32 id) { const char* name = NULL; const char* info = NULL; BPath path; int32 version = 0; _GetTranslatorInfo(id, name, info, version, path); BString message; // Convert the version number into a readable format snprintf(message.LockBuffer(2048), 2048, B_TRANSLATE("Name: %s \nVersion: %ld.%ld.%ld\n\n" "Info:\n%s\n\nPath:\n%s\n"), name, B_TRANSLATION_MAJOR_VERSION(version), B_TRANSLATION_MINOR_VERSION(version), B_TRANSLATION_REVISION_VERSION(version), info, path.Path()); message.UnlockBuffer(); 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); const char* labels[] = { B_TRANSLATE("Name:"), B_TRANSLATE("Version:"), B_TRANSLATE("Info:"), B_TRANSLATE("Path:"), NULL }; for (int32 i = 0; labels[i]; i++) { int32 index = message.FindFirst(labels[i]); view->SetFontAndColor(index, index + strlen(labels[i]), &font); } alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(); }
bool ShortcutsWindow::QuitRequested() { bool ret = true; if (fKeySetModified) { BAlert* alert = new BAlert(WARNING, "Really quit without saving your changes?", "Don't save", "Cancel", "Save"); switch(alert->Go()) { case 1: ret = false; break; case 2: // Save: automatically if possible, otherwise go back and open // up the file requester if (fLastSaved.InitCheck() == B_NO_ERROR) { if (_SaveKeySet(fLastSaved) == false) { (new BAlert(ERROR, "Shortcuts was unable to save your KeySet file!", "Oh no"))->Go(); ret = true; //quit anyway } } else { PostMessage(SAVE_KEYSET); ret = false; } break; default: ret = true; break; } } if (ret) fColumnListView->DeselectAll(); return ret; }
HPJetDirectPort::HPJetDirectPort(BDirectory* printer, BMessage *msg) : fPort(9100), fEndpoint(NULL), fReady(B_ERROR) { fHost[0] = '\0'; const char *spool_path = msg->FindString("printer_file"); if (spool_path && *spool_path) { BDirectory dir(spool_path); dir.ReadAttr("hp_jetdirect:host", B_STRING_TYPE, 0, fHost, sizeof(fHost)); if (fHost[0] == '\0') { SetupWindow *setup = new SetupWindow(&dir); if (setup->Go() == B_ERROR) return; } dir.ReadAttr("hp_jetdirect:host", B_STRING_TYPE, 0, fHost, sizeof(fHost)); dir.ReadAttr("hp_jetdirect:port", B_UINT16_TYPE, 0, &fPort, sizeof(fPort)); } fEndpoint = new BNetEndpoint(SOCK_STREAM); if ((fReady = fEndpoint->InitCheck()) != B_OK) { BAlert *alert = new BAlert("", "Fail to create the NetEndpoint!", "OK"); alert->Go(); return; } if (fEndpoint->Connect(fHost, fPort) == B_OK) { printf("Connected to HP JetDirect printer port at %s:%d\n", fHost, fPort); fReady = B_OK; } else { BAlert *alert = new BAlert("", "Can't connect to HP JetDirect printer port!", "OK"); alert->Go(); fReady = B_ERROR; } }
bool ApplicationTypeWindow::QuitRequested() { if (_NeedsSaving(CHECK_ALL) != 0) { BAlert* alert = new BAlert("Save request", "Do you want to save " "the changes?", "Quit, don't save", "Cancel", "Save", B_WIDTH_AS_USUAL, B_WARNING_ALERT); int32 choice = alert->Go(); switch (choice) { case 0: break; case 1: return false; case 2: _Save(); break; } } be_app->PostMessage(kMsgTypeWindowClosed); return true; }