BNavMenu::BNavMenu(const char *title, uint32 message, const BMessenger &messenger, BWindow *parentWindow, const BObjectList<BString> *list) : BSlowMenu(title), fMessage(message), fMessenger(messenger), fParentWindow(parentWindow), fFlags(0), fItemList(0), fContainer(0), fTypesList(list) { InitIconPreloader(); SetFont(be_plain_font); // add the parent window to the invocation message so that it // can be closed if option modifier held down during invocation BContainerWindow *originatingWindow = dynamic_cast<BContainerWindow *>(fParentWindow); if (originatingWindow) fMessage.AddData("nodeRefsToClose", B_RAW_TYPE, originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref)); // too long to have triggers SetTriggersEnabled(false); }
void BTitleView::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage) { BContainerWindow* window = dynamic_cast<BContainerWindow*>(Window()); if (window == NULL) return; if (fTrackingState != NULL) { int32 buttons = 0; if (Looper() != NULL && Looper()->CurrentMessage() != NULL) Looper()->CurrentMessage()->FindInt32("buttons", &buttons); fTrackingState->MouseMoved(where, buttons); return; } switch (code) { default: if (InColumnResizeArea(where) && window->IsActive()) SetViewCursor(&fHorizontalResizeCursor); else SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); break; case B_EXITED_VIEW: SetViewCursor(B_CURSOR_SYSTEM_DEFAULT); break; } _inherited::MouseMoved(where, code, dragMessage); }
bool TTracker::CloseParentWaitingForChild(const entry_ref *child, const node_ref *parent) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow *parentWindow = FindContainerWindow(parent); if (!parentWindow) // parent window already closed, give up return true; // If child is a symbolic link, dereference it, so that // FindContainerWindow will succeed. BEntry entry(child, true); entry_ref resolvedChild; if (entry.GetRef(&resolvedChild) != B_OK) resolvedChild = *child; BContainerWindow *window = FindContainerWindow(&resolvedChild); if (window) { AutoLock<BWindow> lock(window); if (!window->IsHidden()) return CloseParentWindowCommon(parentWindow); } return false; }
void TTracker::MoveRefsToTrash(const BMessage *message) { int32 count; uint32 type; message->GetInfo("refs", &type, &count); if (count <= 0) return; BObjectList<entry_ref> *srcList = new BObjectList<entry_ref>(count, true); for (int32 index = 0; index < count; index++) { entry_ref ref; ASSERT(message->FindRef("refs", index, &ref) == B_OK); if (message->FindRef("refs", index, &ref) != B_OK) continue; AutoLock<WindowList> lock(&fWindowList); BContainerWindow *window = FindParentContainerWindow(&ref); if (window) // if we have a window open for this entry, ask the pose to // delete it, this will select the next entry window->PoseView()->MoveEntryToTrash(&ref); else // add all others to a list that gets deleted separately srcList->AddItem(new entry_ref(ref)); } if (srcList->CountItems()) // async move to trash FSMoveToTrash(srcList); }
void TTracker::SelectPoseAtLocationInParent(node_ref parent, BPoint pointInPose) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow *parentWindow = FindContainerWindow(&parent); if (parentWindow) { AutoLock<BWindow> lock(parentWindow); parentWindow->PoseView()->SelectPoseAtLocation(pointInPose); } }
void BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow, bool atEnd, bool addShortcuts, bool navMenuEntries) { Model model(entry); if (model.InitCheck() != B_OK) return; BMessage* message = new BMessage(fCommand); message->AddRef(fEntryName.String(), model.EntryRef()); // add reference to the container windows model so that we can // close the window if BContainerWindow* window = originatingWindow ? dynamic_cast<BContainerWindow*>(originatingWindow) : 0; if (window) message->AddData("nodeRefsToClose", B_RAW_TYPE, window->TargetModel()->NodeRef(), sizeof (node_ref)); ModelMenuItem* item; if (navMenuEntries) { BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED, fTarget, window); entry_ref ref; entry->GetRef(&ref); subMenu->SetNavDir(&ref); item = new ModelMenuItem(&model, subMenu); item->SetLabel(model.Name()); item->SetMessage(message); } else { item = new ModelMenuItem(&model, model.Name(), message); } if (addShortcuts) { if (model.IsDesktop()) item->SetShortcut('D', B_COMMAND_KEY); else if (FSIsHomeDir(entry)) item->SetShortcut('H', B_COMMAND_KEY); } if (atEnd) AddItem(item); else AddItem(item, 0); item->SetTarget(fTarget); if (fMenuBar) { ModelMenuItem* menu = dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0)); if (menu) { ThrowOnError(menu->SetEntry(entry)); item->SetMarked(true); } } }
static filter_result TextViewFilter(BMessage* message, BHandler**, BMessageFilter* filter) { uchar key; if (message->FindInt8("byte", (int8*)&key) != B_OK) return B_DISPATCH_MESSAGE; ThrowOnAssert(filter != NULL); BContainerWindow* window = dynamic_cast<BContainerWindow*>( filter->Looper()); ThrowOnAssert(window != NULL); BPoseView* poseView = window->PoseView(); ThrowOnAssert(poseView != NULL); if (key == B_RETURN || key == B_ESCAPE) { poseView->CommitActivePose(key == B_RETURN); return B_SKIP_MESSAGE; } if (key == B_TAB) { if (poseView->ActivePose()) { if (message->FindInt32("modifiers") & B_SHIFT_KEY) poseView->ActivePose()->EditPreviousWidget(poseView); else poseView->ActivePose()->EditNextWidget(poseView); } return B_SKIP_MESSAGE; } // the BTextView doesn't respect window borders when resizing itself; // we try to work-around this "bug" here. // find the text editing view BView* scrollView = poseView->FindView("BorderView"); if (scrollView != NULL) { BTextView* textView = dynamic_cast<BTextView*>( scrollView->FindView("WidgetTextView")); if (textView != NULL) { BRect rect = scrollView->Frame(); if (rect.right + 3 > poseView->Bounds().right || rect.left - 3 < 0) textView->MakeResizable(true, NULL); } } return B_DISPATCH_MESSAGE; }
void TTracker::SaveAllPoseLocations() { int32 numWindows = fWindowList.CountItems(); for (int32 windowIndex = 0; windowIndex < numWindows; windowIndex++) { BContainerWindow* window = dynamic_cast<BContainerWindow*>( fWindowList.ItemAt(windowIndex)); if (window != NULL) { AutoLock<BWindow> lock(window); BDeskWindow* deskWindow = dynamic_cast<BDeskWindow*>(window); if (deskWindow != NULL) deskWindow->SaveDesktopPoseLocations(); else window->PoseView()->SavePoseLocations(); } } }
BContainerWindow * TTracker::FindContainerWindow(const entry_ref *entry, int32 number) const { ASSERT(fWindowList.IsLocked()); int32 count = fWindowList.CountItems(); int32 windowsFound = 0; for (int32 index = 0; index < count; index++) { BContainerWindow *window = dynamic_cast<BContainerWindow *> (fWindowList.ItemAt(index)); if (window && window->IsShowing(entry) && number == windowsFound++) return window; } return NULL; }
bool TTracker::SelectChildInParent(const entry_ref *parent, const node_ref *child) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow *window = FindContainerWindow(parent); if (!window) // parent window already closed, give up return false; AutoLock<BWindow> windowLock(window); if (windowLock.IsLocked()) { BPoseView *view = window->PoseView(); int32 index; BPose *pose = view->FindPose(child, &index); if (pose) { view->SelectPose(pose, index); return true; } } return false; }
BContainerWindow * TTracker::FindParentContainerWindow(const entry_ref *ref) const { BEntry entry(ref); BEntry parent; if (entry.GetParent(&parent) != B_OK) return NULL; entry_ref parentRef; parent.GetRef(&parentRef); ASSERT(fWindowList.IsLocked()); int32 count = fWindowList.CountItems(); for (int32 index = 0; index < count; index++) { BContainerWindow *window = dynamic_cast<BContainerWindow *> (fWindowList.ItemAt(index)); if (window && window->IsShowing(&parentRef)) return window; } return NULL; }
void DesktopPoseView::AdaptToVolumeChange(BMessage* message) { TTracker* tracker = dynamic_cast<TTracker*>(be_app); if (!tracker) return; bool showDisksIcon = false; bool mountVolumesOnDesktop = true; bool mountSharedVolumesOntoDesktop = false; message->FindBool("ShowDisksIcon", &showDisksIcon); message->FindBool("MountVolumesOntoDesktop", &mountVolumesOnDesktop); message->FindBool("MountSharedVolumesOntoDesktop", &mountSharedVolumesOntoDesktop); BEntry entry("/"); Model model(&entry); if (model.InitCheck() == B_OK) { BMessage entryMessage; entryMessage.what = B_NODE_MONITOR; if (showDisksIcon) entryMessage.AddInt32("opcode", B_ENTRY_CREATED); else { entryMessage.AddInt32("opcode", B_ENTRY_REMOVED); entry_ref ref; if (entry.GetRef(&ref) == B_OK) { BContainerWindow* disksWindow = tracker->FindContainerWindow(&ref); if (disksWindow) { disksWindow->Lock(); disksWindow->Close(); } } } entryMessage.AddInt32("device", model.NodeRef()->device); entryMessage.AddInt64("node", model.NodeRef()->node); entryMessage.AddInt64("directory", model.EntryRef()->directory); entryMessage.AddString("name", model.EntryRef()->name); BContainerWindow* deskWindow = dynamic_cast<BContainerWindow*>(Window()); if (deskWindow) deskWindow->PostMessage(&entryMessage, deskWindow->PoseView()); } ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); }
void TTracker::CloseWindowAndChildren(const node_ref *node) { BDirectory dir(node); if (dir.InitCheck() != B_OK) return; AutoLock<WindowList> lock(&fWindowList); BObjectList<BContainerWindow> closeList; // make a list of all windows to be closed // count from end to beginning so we can remove items safely for (int32 index = fWindowList.CountItems() - 1; index >= 0; index--) { BContainerWindow *window = dynamic_cast<BContainerWindow *> (fWindowList.ItemAt(index)); if (window && window->TargetModel()) { BEntry wind_entry; wind_entry.SetTo(window->TargetModel()->EntryRef()); if ((*window->TargetModel()->NodeRef() == *node) || dir.Contains(&wind_entry)) { // ToDo: // get rid of the Remove here, BContainerWindow::Quit does it fWindowList.RemoveItemAt(index); closeList.AddItem(window); } } } // now really close the windows int32 numItems = closeList.CountItems(); for (int32 index = 0; index < numItems; index++) { BContainerWindow *window = closeList.ItemAt(index); window->PostMessage(B_CLOSE_REQUESTED); } }
void BTitleView::MouseDown(BPoint where) { if (!Window()->IsActive()) { // wasn't active, just activate and bail Window()->Activate(); return; } // finish any pending edits fPoseView->CommitActivePose(); BColumnTitle *title = FindColumnTitle(where); BColumnTitle *resizedTitle = InColumnResizeArea(where); uint32 buttons; GetMouse(&where, &buttons); // Check if the user clicked the secondary mouse button. // if so, display the attribute menu: if (buttons & B_SECONDARY_MOUSE_BUTTON) { BContainerWindow *window = dynamic_cast<BContainerWindow *> (Window()); BPopUpMenu *menu = new BPopUpMenu("Attributes", false, false); menu->SetFont(be_plain_font); window->NewAttributeMenu(menu); window->AddMimeTypesToMenu(menu); window->MarkAttributeMenu(menu); menu->SetTargetForItems(window->PoseView()); menu->Go(ConvertToScreen(where), true, false); return; } bigtime_t doubleClickSpeed; get_click_speed(&doubleClickSpeed); if (resizedTitle) { bool force = static_cast<bool>(buttons & B_TERTIARY_MOUSE_BUTTON); if (force || buttons & B_PRIMARY_MOUSE_BUTTON) { if (force || fPreviouslyClickedColumnTitle != 0) { if (force || system_time() - fPreviousLeftClickTime < doubleClickSpeed) { if (fPoseView->ResizeColumnToWidest(resizedTitle->Column())) { Invalidate(); return; } } } fPreviousLeftClickTime = system_time(); fPreviouslyClickedColumnTitle = resizedTitle; } } else if (!title) return; SetMouseEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY | B_LOCK_WINDOW_FOCUS); // track the mouse if (resizedTitle) { fTrackingState = new ColumnResizeState(this, resizedTitle, where, system_time() + doubleClickSpeed); } else { fTrackingState = new ColumnDragState(this, title, where, system_time() + doubleClickSpeed); } }
void TTracker::OpenContainerWindow(Model *model, BMessage *originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, const BMessage *stateMessage) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow *window = NULL; if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) // find out if window already open window = FindContainerWindow(model->NodeRef()); bool someWindowActivated = false; uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; while (window) { // At least one window open, just pull to front // make sure we don't jerk workspaces around uint32 windowWorkspaces = window->Workspaces(); if (windowWorkspaces & workspace) { window->Activate(); someWindowActivated = true; } window = FindContainerWindow(model->NodeRef(), ++windowCount); } if (someWindowActivated) { delete model; return; } // If no window was actiated, (none in the current workspace // we open a new one. if (openSelector == kRunOpenWithWindow) { BMessage *refList = NULL; if (!originalRefsList) { // when passing just a single model, stuff it's entry in a single // element list anyway ASSERT(model); refList = new BMessage; refList->AddRef("refs", model->EntryRef()); delete model; model = NULL; } else // clone the message, window adopts it for it's own use refList = new BMessage(*originalRefsList); window = new OpenWithContainerWindow(refList, &fWindowList); } else if (model->IsRoot()) { // window will adopt the model window = new BVolumeWindow(&fWindowList, openFlags); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); } else // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); if (model) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); if (stateMessage) restoreStateMessage.AddMessage("state", stateMessage); window->PostMessage(&restoreStateMessage); }
TTracker::TTracker() : BApplication(kTrackerSignature), fMimeTypeList(NULL), fClipboardRefsWatcher(NULL), fTrashWatcher(NULL), fTaskLoop(NULL), fNodeMonitorCount(-1), fWatchingInterface(new WatchingInterface), fSettingsWindow(NULL) { BPathMonitor::SetWatchingInterface(fWatchingInterface); // set the cwd to /boot/home, anything that's launched // from Tracker will automatically inherit this BPath homePath; if (find_directory(B_USER_DIRECTORY, &homePath) == B_OK) chdir(homePath.Path()); // ask for a bunch more file descriptors so that nested copying works well struct rlimit rl; rl.rlim_cur = 512; rl.rlim_max = RLIM_SAVED_MAX; setrlimit(RLIMIT_NOFILE, &rl); fNodeMonitorCount = DEFAULT_MON_NUM; gLocalizedNamePreferred = BLocaleRoster::Default()->IsFilesystemTranslationPreferred(); #ifdef CHECK_OPEN_MODEL_LEAKS InitOpenModelDumping(); #endif InitIconPreloader(); #ifdef LEAK_CHECKING SetNewLeakChecking(true); SetMallocLeakChecking(true); #endif // This is how often it should update the free space bar on the // volume icons SetPulseRate(1000000); gLaunchLooper = new LaunchLooper(); gLaunchLooper->Run(); // open desktop window BContainerWindow* deskWindow = NULL; BDirectory deskDir; if (FSGetDeskDir(&deskDir) == B_OK) { // create desktop BEntry entry; deskDir.GetEntry(&entry); Model* model = new Model(&entry, true); if (model->InitCheck() == B_OK) { AutoLock<WindowList> lock(&fWindowList); deskWindow = new BDeskWindow(&fWindowList); AutoLock<BWindow> windowLock(deskWindow); deskWindow->CreatePoseView(model); deskWindow->Init(); if (TrackerSettings().ShowDisksIcon()) { // create model for root of everything BEntry entry("/"); Model model(&entry); if (model.InitCheck() == B_OK) { // add the root icon to desktop window BMessage message; message.what = B_NODE_MONITOR; message.AddInt32("opcode", B_ENTRY_CREATED); message.AddInt32("device", model.NodeRef()->device); message.AddInt64("node", model.NodeRef()->node); message.AddInt64("directory", model.EntryRef()->directory); message.AddString("name", model.EntryRef()->name); deskWindow->PostMessage(&message, deskWindow->PoseView()); } } } else delete model; } }
bool TTracker::QuitRequested() { // don't allow user quitting if (CurrentMessage() && CurrentMessage()->FindBool("shortcut")) return false; gStatusWindow->AttemptToQuit(); // try quitting the copy/move/empty trash threads BVolume bootVolume; DEBUG_ONLY(status_t err =) BVolumeRoster().GetBootVolume(&bootVolume); ASSERT(err == B_OK); BMessage message; AutoLock<WindowList> lock(&fWindowList); // save open windows in a message inside an attribute of the desktop int32 count = fWindowList.CountItems(); for (int32 i = 0; i < count; i++) { BContainerWindow *window = dynamic_cast<BContainerWindow *> (fWindowList.ItemAt(i)); if (window && window->TargetModel() && !window->PoseView()->IsDesktopWindow()) { if (window->TargetModel()->IsRoot()) message.AddBool("open_disks_window", true); else { BEntry entry; BPath path; const entry_ref *ref = window->TargetModel()->EntryRef(); if (entry.SetTo(ref) == B_OK && entry.GetPath(&path) == B_OK) { int8 flags = window->IsMinimized() ? kOpenWindowMinimized : kOpenWindowNoFlags; uint32 deviceFlags = GetVolumeFlags(window->TargetModel()); // save state for every window which is // a) already open on another workspace // b) on a volume not capable of writing attributes if (window != FindContainerWindow(ref) || (deviceFlags & (B_FS_HAS_ATTR | B_FS_IS_READONLY)) != B_FS_HAS_ATTR) { BMessage stateMessage; window->SaveState(stateMessage); window->SetSaveStateEnabled(false); // This is to prevent its state to be saved to the node when closed. message.AddMessage("window state", &stateMessage); flags |= kOpenWindowHasState; } const char *target; bool pathAlreadyExists = false; for (int32 index = 0;message.FindString("paths", index, &target) == B_OK;index++) { if (!strcmp(target,path.Path())) { pathAlreadyExists = true; break; } } if (!pathAlreadyExists) message.AddString("paths", path.Path()); message.AddInt8(path.Path(), flags); } } } } lock.Unlock(); // write windows to open on disk BDirectory deskDir; if (!BootedInSafeMode() && FSGetDeskDir(&deskDir, bootVolume.Device()) == B_OK) { // if message is empty, delete the corresponding attribute if (message.CountNames(B_ANY_TYPE)) { size_t size = (size_t)message.FlattenedSize(); char *buffer = new char[size]; message.Flatten(buffer, (ssize_t)size); deskDir.WriteAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, size); delete [] buffer; } else deskDir.RemoveAttr(kAttrOpenWindows); } for (int32 count = 0; count == 50; count++) { // wait 5 seconds for the copiing/moving to quit if (gStatusWindow->AttemptToQuit()) break; snooze(100000); } return _inherited::QuitRequested(); }
void TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList, OpenSelector openSelector, uint32 openFlags, bool checkAlreadyOpen, const BMessage* stateMessage) { AutoLock<WindowList> lock(&fWindowList); BContainerWindow* window = NULL; const node_ref* modelNodeRef = model->NodeRef(); if (checkAlreadyOpen && openSelector != kRunOpenWithWindow) { // find out if window already open window = FindContainerWindow(modelNodeRef); } bool someWindowActivated = false; uint32 workspace = (uint32)(1 << current_workspace()); int32 windowCount = 0; while (window != NULL) { if ((window->Workspaces() & workspace) != 0 && (dynamic_cast<BDeskWindow*>(window) == NULL || !TrackerSettings().SingleWindowBrowse())) { // We found at least one window that is open and is not Desktop // or we're in spatial mode, activate it and make sure we don't // jerk the workspaces around. window->Activate(); someWindowActivated = true; } window = FindContainerWindow(model->NodeRef(), ++windowCount); } if (someWindowActivated) { delete model; return; } // If no window was activated (none in the current workspace), // we open a new one. if (openSelector == kRunOpenWithWindow) { BMessage* refList = NULL; if (originalRefsList == NULL) { // when passing just a single model, stuff it's entry in a single // element list anyway ASSERT(model != NULL); refList = new BMessage; refList->AddRef("refs", model->EntryRef()); delete model; model = NULL; } else { // clone the message, window adopts it for it's own use refList = new BMessage(*originalRefsList); } window = new OpenWithContainerWindow(refList, &fWindowList); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); } else if (model->IsVirtualDirectory()) { // window will adopt the model window = new VirtualDirectoryWindow(&fWindowList, openFlags); } else { // window will adopt the model window = new BContainerWindow(&fWindowList, openFlags); } if (model != NULL) window->CreatePoseView(model); BMessage restoreStateMessage(kRestoreState); if (stateMessage != NULL) restoreStateMessage.AddMessage("state", stateMessage); window->PostMessage(&restoreStateMessage); }
void OpenWithMenu::DoneBuildingItemList() { // sort by app name fSupportingAppList->SortItems(SortByRelationAndName, this); // check if each app is unique bool isUnique = true; int32 count = fSupportingAppList->CountItems(); for (int32 index = 0; index < count - 1; index++) { // the list is sorted, just compare two adjacent models if (strcmp(fSupportingAppList->ItemAt(index)->fModel->Name(), fSupportingAppList->ItemAt(index + 1)->fModel->Name()) == 0) { isUnique = false; break; } } // add apps as menu items BFont font; GetFont(&font); int32 lastRelation = -1; for (int32 index = 0; index < count ; index++) { RelationCachingModelProxy* modelProxy = fSupportingAppList->ItemAt(index); Model* model = modelProxy->fModel; BMessage* message = new BMessage(fEntriesToOpen); message->AddRef("handler", model->EntryRef()); BContainerWindow* window = dynamic_cast<BContainerWindow*>(fParentWindow); if (window != NULL) { message->AddData("nodeRefsToClose", B_RAW_TYPE, window->TargetModel()->NodeRef(), sizeof(node_ref)); } BString result; if (isUnique) { // just use the app name result = model->Name(); } else { // get a truncated full path BPath path; BEntry entry(model->EntryRef()); if (entry.GetPath(&path) != B_OK) { PRINT(("stale entry ref %s\n", model->Name())); delete message; continue; } result = path.Path(); font.TruncateString(&result, B_TRUNCATE_MIDDLE, kMaxMenuWidth); } #if DEBUG BString relationDescription; fIterator->RelationDescription(&fEntriesToOpen, model, &relationDescription); result += " ("; result += relationDescription; result += ")"; #endif // divide different relations of opening with a separator int32 relation = modelProxy->Relation(fIterator, &fEntriesToOpen); if (lastRelation != -1 && relation != lastRelation) AddSeparatorItem(); lastRelation = relation; ModelMenuItem* item = new ModelMenuItem(model, result.String(), message); AddItem(item); // mark item if it represents the preferred app if (fHaveCommonPreferredApp && *(model->EntryRef()) == fPreferredRef) { //PRINT(("marking item for % as preferred", model->Name())); item->SetMarked(true); } } // target the menu if (target != NULL) SetTargetForItems(target); else SetTargetForItems(fMessenger); if (CountItems() == 0) { BMenuItem* item = new BMenuItem(B_TRANSLATE("no supporting apps"), 0); item->SetEnabled(false); AddItem(item); } }
void TTracker::ReadyToRun() { gStatusWindow = new BStatusWindow(); InitMimeTypes(); InstallDefaultTemplates(); InstallIndices(); InstallTemporaryBackgroundImages(); fTrashWatcher = new BTrashWatcher(); fTrashWatcher->Run(); fClipboardRefsWatcher = new BClipboardRefsWatcher(); fClipboardRefsWatcher->Run(); fTaskLoop = new StandAloneTaskLoop(true); // open desktop window BContainerWindow *deskWindow = NULL; BDirectory deskDir; if (FSGetDeskDir(&deskDir) == B_OK) { // create desktop BEntry entry; deskDir.GetEntry(&entry); Model *model = new Model(&entry, true); if (model->InitCheck() == B_OK) { AutoLock<WindowList> lock(&fWindowList); deskWindow = new BDeskWindow(&fWindowList); AutoLock<BWindow> windowLock(deskWindow); deskWindow->CreatePoseView(model); deskWindow->Init(); if (TrackerSettings().ShowDisksIcon()) { // create model for root of everything BEntry entry("/"); Model model(&entry); if (model.InitCheck() == B_OK) { // add the root icon to desktop window BMessage message; message.what = B_NODE_MONITOR; message.AddInt32("opcode", B_ENTRY_CREATED); message.AddInt32("device", model.NodeRef()->device); message.AddInt64("node", model.NodeRef()->node); message.AddInt64("directory", model.EntryRef()->directory); message.AddString("name", model.EntryRef()->name); deskWindow->PostMessage(&message, deskWindow->PoseView()); } } } else delete model; } // kick off building the mime type list for find panels, etc. fMimeTypeList = new MimeTypeList(); if (!BootedInSafeMode()) { // kick of transient query killer DeleteTransientQueriesTask::StartUpTransientQueryCleaner(); // the mount_server will have mounted the previous volumes already. _OpenPreviouslyOpenedWindows(); } }
void TTracker::ReadyToRun() { gStatusWindow = new BStatusWindow(); InitMimeTypes(); InstallDefaultTemplates(); InstallIndices(); HideVarDir(); fTrashWatcher = new BTrashWatcher(); fTrashWatcher->Run(); fClipboardRefsWatcher = new BClipboardRefsWatcher(); fClipboardRefsWatcher->Run(); fAutoMounter = new AutoMounter(); fAutoMounter->Run(); fTaskLoop = new StandAloneTaskLoop(true); bool openDisksWindow = false; // open desktop window BContainerWindow *deskWindow = NULL; BVolume bootVol; BVolumeRoster().GetBootVolume(&bootVol); BDirectory deskDir; if (FSGetDeskDir(&deskDir, bootVol.Device()) == B_OK) { // create desktop BEntry entry; deskDir.GetEntry(&entry); Model *model = new Model(&entry); if (model->InitCheck() == B_OK) { AutoLock<WindowList> lock(&fWindowList); deskWindow = new BDeskWindow(&fWindowList); AutoLock<BWindow> windowLock(deskWindow); deskWindow->CreatePoseView(model); deskWindow->Init(); } else delete model; // open previously open windows attr_info attrInfo; if (!BootedInSafeMode() && deskDir.GetAttrInfo(kAttrOpenWindows, &attrInfo) == B_OK) { char *buffer = (char *)malloc((size_t)attrInfo.size); BMessage message; if (deskDir.ReadAttr(kAttrOpenWindows, B_MESSAGE_TYPE, 0, buffer, (size_t)attrInfo.size) == attrInfo.size && message.Unflatten(buffer) == B_OK) { node_ref nodeRef; deskDir.GetNodeRef(&nodeRef); int32 stateMessageCounter = 0; const char *path; for (int32 outer = 0;message.FindString("paths", outer, &path) == B_OK;outer++) { int8 flags = 0; for (int32 inner = 0;message.FindInt8(path, inner, &flags) == B_OK;inner++) { BEntry entry(path, true); if (entry.InitCheck() == B_OK) { Model *model = new Model(&entry); if (model->InitCheck() == B_OK && model->IsContainer()) { BMessage state; bool restoreStateFromMessage = false; if ((flags & kOpenWindowHasState) != 0 && message.FindMessage("window state", stateMessageCounter++, &state) == B_OK) restoreStateFromMessage = true; if (restoreStateFromMessage) OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U), false, &state); else OpenContainerWindow(model, 0, kOpen, kRestoreWorkspace | (flags & kOpenWindowMinimized ? kIsHidden : 0U)); } else delete model; } } } if (message.HasBool("open_disks_window")) openDisksWindow = true; } free(buffer); } } // create model for root of everything if (deskWindow) { BEntry entry("/"); Model model(&entry); if (model.InitCheck() == B_OK) { if (TrackerSettings().ShowDisksIcon()) { // add the root icon to desktop window BMessage message; message.what = B_NODE_MONITOR; message.AddInt32("opcode", B_ENTRY_CREATED); message.AddInt32("device", model.NodeRef()->device); message.AddInt64("node", model.NodeRef()->node); message.AddInt64("directory", model.EntryRef()->directory); message.AddString("name", model.EntryRef()->name); deskWindow->PostMessage(&message, deskWindow->PoseView()); } if (openDisksWindow) OpenContainerWindow(new Model(model), 0, kOpen, kRestoreWorkspace); } } // kick off building the mime type list for find panels, etc. fMimeTypeList = new MimeTypeList(); if (!BootedInSafeMode()) // kick of transient query killer DeleteTransientQueriesTask::StartUpTransientQueryCleaner(); }