void PersonWindow::SaveAs() { char name[B_FILE_NAME_LENGTH]; _GetDefaultFileName(name); if (fPanel == NULL) { BMessenger target(this); fPanel = new BFilePanel(B_SAVE_PANEL, &target); BPath path; find_directory(B_USER_DIRECTORY, &path, true); BDirectory dir; dir.SetTo(path.Path()); BEntry entry; if (dir.FindEntry("people", &entry) == B_OK || (dir.CreateDirectory("people", &dir) == B_OK && dir.GetEntry(&entry) == B_OK)) { fPanel->SetPanelDirectory(&entry); } } if (fPanel->Window()->Lock()) { fPanel->SetSaveText(name); if (fPanel->Window()->IsHidden()) fPanel->Window()->Show(); else fPanel->Window()->Activate(); fPanel->Window()->Unlock(); } }
void PersonWindow::SaveAs(int32 format) { if (format == 0) format = B_PERSON_FORMAT; char name[B_FILE_NAME_LENGTH]; _GetDefaultFileName(name); if (fPanel == NULL) { BPath path; BMessenger target(this); BMessage msg(B_SAVE_REQUESTED); msg.AddInt32("format", format); fPanel = new BFilePanel(B_SAVE_PANEL, &target, NULL, 0, true, &msg); find_directory(B_USER_DIRECTORY, &path, true); BDirectory dir; dir.SetTo(path.Path()); BEntry entry; if (dir.FindEntry("people", &entry) == B_OK || (dir.CreateDirectory("people", &dir) == B_OK && dir.GetEntry(&entry) == B_OK)) { fPanel->SetPanelDirectory(&entry); } } if (fPanel->Window()->Lock()) { fPanel->SetSaveText(name); if (fPanel->Window()->IsHidden()) fPanel->Window()->Show(); else fPanel->Window()->Activate(); fPanel->Window()->Unlock(); } }