diff --git a/src/kits/tracker/DirMenu.cpp b/src/kits/tracker/DirMenu.cpp index f324cf2d22..34de92726a 100644 --- a/src/kits/tracker/DirMenu.cpp +++ b/src/kits/tracker/DirMenu.cpp @@ -217,7 +217,7 @@ BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow, } if (addShortcuts) { - if (FSIsDeskDir(entry)) + if (model.IsDesktop()) item->SetShortcut('D', B_COMMAND_KEY); else if (FSIsHomeDir(entry)) item->SetShortcut('H', B_COMMAND_KEY); diff --git a/src/kits/tracker/FSClipboard.cpp b/src/kits/tracker/FSClipboard.cpp index 3864e3ed5e..f8501a6bac 100644 --- a/src/kits/tracker/FSClipboard.cpp +++ b/src/kits/tracker/FSClipboard.cpp @@ -229,7 +229,7 @@ FSClipboardAddPoses(const node_ref *directory, PoseList *list, uint32 moveMode, if (model->IsVolume() || model->IsRoot() || model->IsTrash() - || FSIsDeskDir(&entry)) + || model->IsDesktop()) continue; MakeRefName(refName, node); diff --git a/src/kits/tracker/FilePanelPriv.cpp b/src/kits/tracker/FilePanelPriv.cpp index 2291668016..5ad1767e36 100644 --- a/src/kits/tracker/FilePanelPriv.cpp +++ b/src/kits/tracker/FilePanelPriv.cpp @@ -1251,8 +1251,7 @@ TFilePanel::CanOpenParent() const { if (TrackerSettings().DesktopFilePanelRoot()) { // don't allow opening Desktop folder's parent - BEntry entry(TargetModel()->EntryRef()); - if (FSIsDeskDir(&entry)) + if (TargetModel()->IsDesktop()) return false; } @@ -1504,11 +1503,9 @@ TFilePanel::WindowActivated(bool active) BFilePanelPoseView::BFilePanelPoseView(Model *model, BRect frame, uint32 resizeMask) - : BPoseView(model, frame, kListMode, resizeMask) + : BPoseView(model, frame, kListMode, resizeMask), + fIsDesktop(model->IsDesktop()) { - BEntry entry; - model->GetEntry(&entry); - fIsDesktop = FSIsDeskDir(&entry); } diff --git a/src/kits/tracker/Model.cpp b/src/kits/tracker/Model.cpp index 6e16e2bebb..843c38a89a 100644 --- a/src/kits/tracker/Model.cpp +++ b/src/kits/tracker/Model.cpp @@ -339,6 +339,9 @@ Model::Name() const case kTrashNode: return "Trash"; + + case kDesktopNode: + return "Desktop"; default: break; @@ -411,6 +414,7 @@ Model::OpenNodeCommon(bool writable) case kVolumeNode: case kRootNode: case kTrashNode: + case kDesktopNode: if (!IsNodeOpen()) fNode = new BDirectory(&fEntryRef); @@ -598,8 +602,12 @@ Model::FinishSettingUpType() switch (fBaseType) { case kDirectoryNode: entry.SetTo(&fEntryRef); - if (entry.InitCheck() == B_OK && FSIsTrashDir(&entry)) - fBaseType = kTrashNode; + if (entry.InitCheck() == B_OK) { + if (FSIsTrashDir(&entry)) + fBaseType = kTrashNode; + else if (FSIsDeskDir(&entry)) + fBaseType = kDesktopNode; + } fMimeType = B_DIR_MIMETYPE; // should use a shared string here if (IsNodeOpen()) { @@ -687,7 +695,7 @@ Model::ResetIconFrom() // mirror the logic from FinishSettingUpType if ((fBaseType == kDirectoryNode || fBaseType == kVolumeNode - || fBaseType == kTrashNode) + || fBaseType == kTrashNode || fBaseType == kDesktopNode) && !CheckNodeIconHintPrivate(fNode, dynamic_cast(be_app) == NULL)) { if (WellKnowEntryList::Match(NodeRef()) > (directory_which)-1) { fIconFrom = kTrackerSupplied; @@ -1265,6 +1273,7 @@ Model::PrintToStream(int32 level, bool deep) case kDirectoryNode: case kTrashNode: + case kDesktopNode: PRINT(("dir\n")); break; diff --git a/src/kits/tracker/Model.h b/src/kits/tracker/Model.h index 12a3cc08ae..398860dc05 100644 --- a/src/kits/tracker/Model.h +++ b/src/kits/tracker/Model.h @@ -136,6 +136,7 @@ class Model { bool IsSymLink() const; bool IsRoot() const; bool IsTrash() const; + bool IsDesktop() const; bool IsVolume() const; IconSource IconFrom() const; @@ -229,6 +230,7 @@ class Model { kVolumeNode, kRootNode, kTrashNode, + kDesktopNode, kUnknownNode }; @@ -382,7 +384,8 @@ Model::IsDirectory() const return fBaseType == kDirectoryNode || fBaseType == kVolumeNode || fBaseType == kRootNode - || fBaseType == kTrashNode; + || fBaseType == kTrashNode + || fBaseType == kDesktopNode; } @@ -423,6 +426,13 @@ Model::IsTrash() const } +inline bool +Model::IsDesktop() const +{ + return fBaseType == kDesktopNode; +} + + inline bool Model::IsExecutable() const { diff --git a/src/kits/tracker/NavMenu.cpp b/src/kits/tracker/NavMenu.cpp index 4e20ae86e1..8eece1fe33 100644 --- a/src/kits/tracker/NavMenu.cpp +++ b/src/kits/tracker/NavMenu.cpp @@ -408,7 +408,7 @@ BNavMenu::StartBuildingItemList() if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); - else if (FSIsDeskDir(&entry)) { + else if (startModel.IsDesktop()) { fIteratingDesktop = true; fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef()); AddRootItemsIfNeeded(); diff --git a/src/kits/tracker/SlowContextPopup.cpp b/src/kits/tracker/SlowContextPopup.cpp index 3353306459..439b40382e 100644 --- a/src/kits/tracker/SlowContextPopup.cpp +++ b/src/kits/tracker/SlowContextPopup.cpp @@ -259,11 +259,12 @@ BSlowContextMenu::StartBuildingItemList() if (startModel.IsQuery()) fContainer = new QueryEntryListCollection(&startModel); - else if (FSIsDeskDir(&entry)) { + else if (startModel.IsDesktop()) { fIteratingDesktop = true; fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef()); AddRootItemsIfNeeded(); + AddTrashItem(); } else fContainer = new DirectoryEntryList(*dynamic_cast (startModel.Node())); @@ -299,6 +300,18 @@ BSlowContextMenu::AddRootItemsIfNeeded() } +void +BSlowContextMenu::AddTrashItem() +{ + BPath path; + if (find_directory(B_TRASH_DIRECTORY, &path) == B_OK) { + BEntry entry(path.Path()); + Model model(&entry); + AddOneItem(&model); + } +} + + bool BSlowContextMenu::AddNextItem() { diff --git a/src/kits/tracker/SlowContextPopup.h b/src/kits/tracker/SlowContextPopup.h index 3d6d267a58..2f980f3845 100644 --- a/src/kits/tracker/SlowContextPopup.h +++ b/src/kits/tracker/SlowContextPopup.h @@ -83,6 +83,7 @@ protected: void AddOneItem(Model *); void AddRootItemsIfNeeded(); + void AddTrashItem(); static void SetTrackingHookDeep(BMenu *, bool (*)(BMenu *, void *), void *); bool fMenuBuilt;