BHandler *PApp::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier, int32 form, const char *property) { BHandler *result = NULL; try { PDoc *doc = NULL; if (strcmp(property, "Window") == 0 && form == B_NAME_SPECIFIER) { msg->PopSpecifier(); entry_ref file; const char *fileName; FailOSErr(specifier->FindString("name", &fileName)); if (get_ref_for_path(fileName, &file) == B_OK) { doc = dynamic_cast<PDoc*>(CDoc::FindDoc(file)); if (doc == NULL) doc = dynamic_cast<PDoc*>(OpenWindow(file, true)); } } if (doc) doc->PostMessage(msg); else result = BApplication::ResolveSpecifier(msg, index, specifier, form, property); } catch (HErr& e) { BMessage reply; reply.AddString("Error", e); msg->SendReply(&reply); } return result; } /* PApp::ResolveSpecifier */
void PApp::MessageReceived(BMessage *msg) { try { switch (msg->what) { case msg_SaveAll: { const doclist& lst = CDoc::DocList(); doclist::const_iterator di; for (di = lst.begin(); di != lst.end(); di++) { BWindow *w = dynamic_cast<PDoc*>(*di); if (w) w->PostMessage(msg_Save); } break; } case msg_CloseAll: { const doclist& lst = CDoc::DocList(); doclist::const_reverse_iterator di; for (di = lst.rbegin(); di != lst.rend(); di++) { PDoc *doc = dynamic_cast<PDoc*>(*di); if (doc && ! doc->IsWorksheet() && doc->Lock()) { if (doc->QuitRequested()) doc->Quit(); else { doc->Unlock(); break; } } } break; } case B_NODE_MONITOR: { CDoc::HandleFolderNodeMonitorMsg(msg); break; } case msg_OpenSelected: DialogCreator<COpenSelection>::CreateDialog(NULL); break; case msg_OpenInclude: { const char *i; FailOSErr(msg->FindString("include", &i)); const char *src = NULL; msg->FindString("from-source", &src); FindAndOpen(i, src); break; } case msg_FindCmd: { int c = 1 << current_workspace(); if (gPrefs->GetPrefInt(prf_I_SmartWorkspaces, 1)) FindDialog()->SetWorkspaces(c); FindDialog()->SetCaller(PDoc::TopWindow()); FindDialog()->Show(); FindDialog()->Activate(true); break; } case B_REFS_RECEIVED: case 'OpFi': RefsReceived(msg); break; case msg_About: { AboutWindow *abwin = new AboutWindow(); abwin->Show(); break; } case msg_IdeBringToFront: PDoc::IDEBringToFront(); break; case msg_IdeProjectToGroup: PDoc::IDEProject2Group(); break; case msg_FindDifferences: { BRect r(100,100,500,250); new CDiffWindow(r, "Differences"); break; } case msg_Open: { if (fOpenPanel->IsShowing()) { fOpenPanel->Window()->SetWorkspaces(1 << current_workspace()); fOpenPanel->Window()->Activate(); } else { BEntry entry; gCWD.GetEntry(&entry); BAutolock lock(fOpenPanel->Window()); entry_ref ref; entry.GetRef(&ref); fOpenPanel->SetPanelDirectory(&ref); fOpenPanel->Window()->SetWorkspaces(1 << current_workspace()); if (gPrefs->GetPrefInt(prf_I_ZoomOpenPanel, 0)) { BRect r = BScreen().Frame(); fOpenPanel->Window()->MoveTo(r.left + 80, r.top + 40); fOpenPanel->Window()->ResizeTo(480, r.Height() - 50); } fOpenPanel->Show(); } break; } case msg_CommandLineOpen: { entry_ref doc; FailOSErr (msg->FindRef("refs", &doc)); CDocWindow *w; BEntry e; if (e.SetTo(&doc) == B_OK && e.Exists()) w = dynamic_cast<CDocWindow*>(OpenWindow(doc)); else { w = NewWindow(NULL); w->SetEntryRef(&doc); } long lineNr; if (w && msg->FindInt32("line", &lineNr) == B_OK) { BMessage m(msg_SelectLines); FailOSErr(m.AddInt32("from", lineNr)); FailOSErr(m.AddInt32("to", lineNr - 1)); w->PostMessage(&m, w->PreferredHandler()); } if (w) { BMessage reply; reply.AddInt32("thread", w->Thread()); msg->SendReply(&reply); } break; } case B_SILENT_RELAUNCH: case msg_New: if (be_roster->IsRunning("application/x-vnd.dw-Paladin")) { BMessage newMsg(PALADIN_SHOW_ADD_NEW_PANEL); BMessenger msgr("application/x-vnd.dw-Paladin"); msgr.SendMessage(&newMsg); } else NewWindow(); break; case msg_Select: { PDoc *doc; if ((doc = PDoc::TopWindow()) != NULL) { BMessage copy(*msg); doc->PostMessage(©); } break; } case msg_DocClosed: if (CDoc::CountDocs() == 0) Quit(); break; case msg_Tile: PDoc::Tile(); break; case msg_Stack: PDoc::Stack(); break; case msg_Zoom: if (PDoc::TopWindow()) PDoc::TopWindow()->Zoom(); break; case msg_Worksheet: OpenWorksheet(); break; case msg_NewGroup: new PGroupWindow; break; case 1: puts(rcsid); break; case msg_Quit: PostMessage(B_QUIT_REQUESTED); break; case msg_Preferences: { long l; if (fPrefOpener) wait_for_thread(fPrefOpener, &l); fPrefOpener = (thread_id)NULL; if (fPrefsDialog) { BAutolock lock(fPrefsDialog); if (!lock.IsLocked()) { THROW(("Preferences panel failed to lock")); break; } int c = 1 << current_workspace(); if (gPrefs->GetPrefInt(prf_I_SmartWorkspaces, 1)) fPrefsDialog->SetWorkspaces(c); if (fPrefsDialog->IsHidden()) { fPrefsDialog->Show(); } fPrefsDialog->Activate(true); } else THROW(("Preferences panel failed to open")); break; } default: BApplication::MessageReceived(msg); } } catch (HErr& e) { e.DoError(); } } /* PApp::MessageReceived */