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; }
int ScalarAttributeText::Compare(WidgetAttributeText& attr, BPoseView*) { ScalarAttributeText* compareTo = dynamic_cast<ScalarAttributeText*>(&attr); ThrowOnAssert(compareTo != NULL); if (fValueDirty) fValue = ReadValue(); return fValue >= compareTo->Value() ? (fValue == compareTo->Value() ? 0 : 1) : -1; }
int StringAttributeText::Compare(WidgetAttributeText& attr, BPoseView* view) { StringAttributeText* compareTo = dynamic_cast<StringAttributeText*>(&attr); ThrowOnAssert(compareTo != NULL); if (fValueDirty) ReadValue(&fFullValueText); return NaturalCompare(fFullValueText.String(), compareTo->ValueAsText(view)); }
int NameAttributeText::Compare(WidgetAttributeText& attr, BPoseView* view) { NameAttributeText* compareTo = dynamic_cast<NameAttributeText*>(&attr); ThrowOnAssert(compareTo != NULL); if (fValueDirty) ReadValue(&fFullValueText); if (NameAttributeText::sSortFolderNamesFirst) return fModel->CompareFolderNamesFirst(attr.TargetModel()); return NaturalCompare(fFullValueText.String(), compareTo->ValueAsText(view)); }
void DesktopPoseView::AdaptToVolumeChange(BMessage* message) { TTracker* tracker = dynamic_cast<TTracker*>(be_app); ThrowOnAssert(tracker != NULL); 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 != NULL) { 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 != NULL) deskWindow->PostMessage(&entryMessage, deskWindow->PoseView()); } ShowVolumes(mountVolumesOnDesktop, mountSharedVolumesOntoDesktop); }
EntryListBase* DesktopPoseView::InitDesktopDirentIterator(BPoseView* nodeMonitoringTarget, const entry_ref* ref) { // the desktop dirent iterator knows how to iterate over all the volumes, // integrated onto the desktop Model sourceModel(ref, false, true); if (sourceModel.InitCheck() != B_OK) return NULL; CachedEntryIteratorList* result = new CachedEntryIteratorList(); ASSERT(!sourceModel.IsQuery()); ASSERT(!sourceModel.IsVirtualDirectory()); ASSERT(sourceModel.Node() != NULL); BDirectory* sourceDirectory = dynamic_cast<BDirectory*>(sourceModel.Node()); ThrowOnAssert(sourceDirectory != NULL); // build an iterator list, start with boot EntryListBase* perDesktopIterator = new CachedDirectoryEntryList(*sourceDirectory); result->AddItem(perDesktopIterator); if (nodeMonitoringTarget != NULL) { TTracker::WatchNode(sourceModel.NodeRef(), B_WATCH_DIRECTORY | B_WATCH_NAME | B_WATCH_STAT | B_WATCH_ATTR, nodeMonitoringTarget); } if (result->Rewind() != B_OK) { delete result; if (nodeMonitoringTarget != NULL) nodeMonitoringTarget->HideBarberPole(); return NULL; } return result; }
int GenericAttributeText::Compare(WidgetAttributeText& attr, BPoseView*) { GenericAttributeText* compareTo = dynamic_cast<GenericAttributeText*>(&attr); ThrowOnAssert(compareTo != NULL); if (fValueDirty) ReadValue(&fFullValueText); if (compareTo->fValueDirty) compareTo->ReadValue(&compareTo->fFullValueText); // sort undefined values last, regardless of the other value if (!fValueIsDefined) return compareTo->fValueIsDefined ? 1 : 0; if (!compareTo->fValueIsDefined) return -1; switch (fColumn->AttrType()) { case B_STRING_TYPE: return fFullValueText.ICompare(compareTo->fFullValueText); case B_CHAR_TYPE: { char vStr[2] = { static_cast<char>(fValue.uint8t), 0 }; char cStr[2] = { static_cast<char>(compareTo->fValue.uint8t), 0}; BString valueStr(vStr); BString compareToStr(cStr); return valueStr.ICompare(compareToStr); } case B_FLOAT_TYPE: return fValue.floatt >= compareTo->fValue.floatt ? (fValue.floatt == compareTo->fValue.floatt ? 0 : 1) : -1; case B_DOUBLE_TYPE: return fValue.doublet >= compareTo->fValue.doublet ? (fValue.doublet == compareTo->fValue.doublet ? 0 : 1) : -1; case B_BOOL_TYPE: return fValue.boolt >= compareTo->fValue.boolt ? (fValue.boolt == compareTo->fValue.boolt ? 0 : 1) : -1; case B_UINT8_TYPE: return fValue.uint8t >= compareTo->fValue.uint8t ? (fValue.uint8t == compareTo->fValue.uint8t ? 0 : 1) : -1; case B_INT8_TYPE: return fValue.int8t >= compareTo->fValue.int8t ? (fValue.int8t == compareTo->fValue.int8t ? 0 : 1) : -1; case B_UINT16_TYPE: return fValue.uint16t >= compareTo->fValue.uint16t ? (fValue.uint16t == compareTo->fValue.uint16t ? 0 : 1) : -1; case B_INT16_TYPE: return fValue.int16t >= compareTo->fValue.int16t ? (fValue.int16t == compareTo->fValue.int16t ? 0 : 1) : -1; case B_UINT32_TYPE: return fValue.uint32t >= compareTo->fValue.uint32t ? (fValue.uint32t == compareTo->fValue.uint32t ? 0 : 1) : -1; case B_TIME_TYPE: // time_t typedef'd to a long, i.e. a int32 case B_INT32_TYPE: return fValue.int32t >= compareTo->fValue.int32t ? (fValue.int32t == compareTo->fValue.int32t ? 0 : 1) : -1; case B_OFF_T_TYPE: // off_t typedef'd to a long long, i.e. a int64 case B_INT64_TYPE: return fValue.int64t >= compareTo->fValue.int64t ? (fValue.int64t == compareTo->fValue.int64t ? 0 : 1) : -1; case B_UINT64_TYPE: default: return fValue.uint64t >= compareTo->fValue.uint64t ? (fValue.uint64t == compareTo->fValue.uint64t ? 0 : 1) : -1; } return 0; }
bool SearchForSignatureEntryList::CanOpenWithFilter(const Model* appModel, const BMessage* entriesToOpen, const entry_ref* preferredApp) { ThrowOnAssert(appModel != NULL); if (!appModel->IsExecutable() || !appModel->Node()) { // weed out non-executable #if xDEBUG BPath path; BEntry entry(appModel->EntryRef()); entry.GetPath(&path); PRINT(("filtering out %s- not executable \n", path.Path())); #endif return false; } if (strcasecmp(appModel->MimeType(), B_APP_MIME_TYPE) != 0) { // filter out pe containers on PPC etc. return false; } BFile* file = dynamic_cast<BFile*>(appModel->Node()); ASSERT(file != NULL); char signature[B_MIME_TYPE_LENGTH]; if (GetAppSignatureFromAttr(file, signature) == B_OK && strcasecmp(signature, kTrackerSignature) == 0) { // special case the Tracker - make sure only the running copy is // in the list app_info trackerInfo; if (*appModel->EntryRef() != trackerInfo.ref) { // this is an inactive copy of the Tracker, remove it #if xDEBUG BPath path1; BPath path2; BEntry entry(appModel->EntryRef()); entry.GetPath(&path1); BEntry entry2(&trackerInfo.ref); entry2.GetPath(&path2); PRINT(("filtering out %s, sig %s, active Tracker at %s, " "result %s, refName %s\n", path1.Path(), signature, path2.Path(), strerror(be_roster->GetActiveAppInfo(&trackerInfo)), trackerInfo.ref.name)); #endif return false; } } if (FSInTrashDir(appModel->EntryRef())) return false; if (ShowAllApplications()) { // don't check for these if we didn't look for every single app // to not slow filtering down uint32 flags; BAppFileInfo appFileInfo(dynamic_cast<BFile*>(appModel->Node())); if (appFileInfo.GetAppFlags(&flags) != B_OK) return false; if ((flags & B_BACKGROUND_APP) || (flags & B_ARGV_ONLY)) return false; if (!signature[0]) // weed out apps with empty signatures return false; } int32 relation = Relation(entriesToOpen, appModel, preferredApp, 0); if (relation == kNoRelation && !ShowAllApplications()) { #if xDEBUG BPath path; BEntry entry(appModel->EntryRef()); entry.GetPath(&path); PRINT(("filtering out %s, does not handle any of opened files\n", path.Path())); #endif return false; } if (relation != kNoRelation && relation != kSuperhandler && !fGenericFilesOnly) { // we hit at least one app that is not a superhandler and // handles the document fFoundOneNonSuperHandler = true; } return true; }