Tracker: Allow draggable container icon on Root, Trash and Printers
Use new DraggableContainerIcon name when invalidating icon. Create a ShouldHaveDraggableFolderIcon() method on BContainerWindow to consolidate the gating logic to a method. We alert if you try and copy, move or create link to any of these directories, however you may drag the icon in some instances such as to change the directory in a file panel or to open the directory up in FileTypes. You may create a link to the printers directory. Set the Printer icon on the printers directory. Fixes #3385 Tracker: Disks menu in CountView * Open Disks directory on click. * Skip volumes with no capacity (e.g. system, config) from Root and Desktop menus (still shown in Home and volumes though). * No Trash on volumes, add only to Desktop. * Declare some variables outside loop. * Rename originatingWindow to source. Fixes #3549 Change-Id: I66318d2485a5a8405f5459c355a467f34e19ecc5 Reviewed-on: https://review.haiku-os.org/c/haiku/+/9499 Reviewed-by: John Scipione <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -49,11 +49,11 @@ public:
|
||||
const char* entryName = 0);
|
||||
virtual ~BDirMenu();
|
||||
|
||||
void Populate(const BEntry* startDir, BWindow* originatingWindow,
|
||||
void Populate(const BEntry* startDir, BWindow* source,
|
||||
bool includeStartDir = false, bool select = false,
|
||||
bool reverse = false, bool addShortcuts = false,
|
||||
bool navMenuEntries = false);
|
||||
void AddItemToDirMenu(const BEntry*, BWindow* originatingWindow,
|
||||
void AddItemToDirMenu(const BEntry*, BWindow* source,
|
||||
bool atEnd, bool addShortcuts, bool navMenuEntries = false);
|
||||
void AddDisksIconToMenu(bool reverse = false);
|
||||
|
||||
|
||||
@@ -761,7 +761,7 @@ BContainerWindow::Init(const BMessage* message)
|
||||
fMenuContainer->GroupLayout()->AddView(fMenuBar);
|
||||
AddMenus();
|
||||
|
||||
if (!TargetModel()->IsRoot() && !TargetModel()->IsTrash())
|
||||
if (ShouldHaveDraggableFolderIcon())
|
||||
_AddFolderIcon();
|
||||
} else {
|
||||
// add equivalents of the menu shortcuts to the menuless
|
||||
@@ -997,8 +997,7 @@ BContainerWindow::SwitchDirectory(const entry_ref* ref)
|
||||
SetSingleWindowBrowseShortcuts(settings.SingleWindowBrowse());
|
||||
|
||||
// Update draggable folder icon
|
||||
if (fMenuBar != NULL) {
|
||||
if (!TargetModel()->IsRoot() && !TargetModel()->IsTrash()) {
|
||||
if (ShouldHaveDraggableFolderIcon()) {
|
||||
// Folder icon should be visible, but in single
|
||||
// window navigation, it might not be.
|
||||
if (fDraggableIcon != NULL) {
|
||||
@@ -1010,11 +1009,9 @@ BContainerWindow::SwitchDirectory(const entry_ref* ref)
|
||||
// draggable icon visible
|
||||
_AddFolderIcon();
|
||||
}
|
||||
} else if (fDraggableIcon != NULL) {
|
||||
// hide for Root or Trash
|
||||
} else if (fMenuBar != NULL && fDraggableIcon != NULL) {
|
||||
fDraggableIcon->Hide();
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
}
|
||||
@@ -3153,6 +3150,13 @@ BContainerWindow::ShouldHaveAddOnMenus()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
BContainerWindow::ShouldHaveDraggableFolderIcon()
|
||||
{
|
||||
return fMenuBar != NULL;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - BContainerWindow private methods
|
||||
|
||||
|
||||
|
||||
@@ -301,6 +301,10 @@ protected:
|
||||
bool ShouldHaveNewFolderItem();
|
||||
bool ShouldHaveAddOnMenus();
|
||||
|
||||
public:
|
||||
virtual bool ShouldHaveDraggableFolderIcon();
|
||||
|
||||
protected:
|
||||
BGroupLayout* fRootLayout;
|
||||
BGroupView* fMenuContainer;
|
||||
BGridView* fPoseContainer;
|
||||
|
||||
@@ -74,8 +74,13 @@ BCountView::BCountView(BPoseView* view)
|
||||
fTypeAheadString(""),
|
||||
fFilterString("")
|
||||
{
|
||||
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE,
|
||||
R_BarberPoleBitmap, &fBarberPoleMap);
|
||||
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, R_BarberPoleBitmap, &fBarberPoleMap);
|
||||
|
||||
SetFont(be_plain_font);
|
||||
SetFontSize(std::max(kMinFontSize, ceilf(be_plain_font->Size() * 0.75f)));
|
||||
|
||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
SetLowUIColor(ViewUIColor());
|
||||
}
|
||||
|
||||
|
||||
@@ -291,35 +296,28 @@ BCountView::MouseDown(BPoint)
|
||||
if (fPoseView->IsFilePanel() || fPoseView->TargetModel() == NULL)
|
||||
return;
|
||||
|
||||
if (!window->TargetModel()->IsRoot()) {
|
||||
BDirMenu* menu = new BDirMenu(NULL, be_app, B_REFS_RECEIVED);
|
||||
if (window->TargetModel()->IsRoot())
|
||||
return;
|
||||
|
||||
BDirMenu menu(NULL, be_app, B_REFS_RECEIVED);
|
||||
BEntry entry;
|
||||
if (entry.SetTo(window->TargetModel()->EntryRef()) == B_OK)
|
||||
menu->Populate(&entry, Window(), false, false, true, false, true);
|
||||
menu.Populate(&entry, Window(), false, false, true, false, true);
|
||||
else
|
||||
menu->Populate(NULL, Window(), false, false, true, false, true);
|
||||
menu.Populate(NULL, Window(), false, false, true, false, true);
|
||||
|
||||
BPoint point = Bounds().LeftBottom();
|
||||
point.y += 3;
|
||||
ConvertToScreen(&point);
|
||||
BRect clickToOpenRect(Bounds());
|
||||
ConvertToScreen(&clickToOpenRect);
|
||||
menu->Go(point, true, true, clickToOpenRect);
|
||||
delete menu;
|
||||
}
|
||||
menu.Go(point, true, true, clickToOpenRect);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
BCountView::AttachedToWindow()
|
||||
{
|
||||
SetFont(be_plain_font);
|
||||
SetFontSize(std::max(kMinFontSize,
|
||||
ceilf(be_plain_font->Size() * 0.75f)));
|
||||
|
||||
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
|
||||
SetLowUIColor(ViewUIColor());
|
||||
|
||||
CheckCount();
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ public:
|
||||
|
||||
void SaveDesktopPoseLocations();
|
||||
|
||||
virtual bool ShouldHaveDraggableFolderIcon() { return false; };
|
||||
|
||||
protected:
|
||||
virtual BPoseView* NewPoseView(Model*, uint32);
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ BDirMenu::~BDirMenu()
|
||||
|
||||
|
||||
void
|
||||
BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
BDirMenu::Populate(const BEntry* startEntry, BWindow* source,
|
||||
bool includeStartEntry, bool select, bool reverse, bool addShortcuts,
|
||||
bool navMenuEntries)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
|
||||
ModelMenuItem* menu = NULL;
|
||||
|
||||
if (fMenuBar) {
|
||||
if (fMenuBar != NULL) {
|
||||
menu = new ModelMenuItem(&model, this, true, true);
|
||||
fMenuBar->AddItem(menu);
|
||||
}
|
||||
@@ -115,8 +115,7 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
BDirectory parent;
|
||||
BDirectory dir(&entry);
|
||||
|
||||
if (!showDesktop && dir.InitCheck() == B_OK
|
||||
&& dir.IsRootDirectory()) {
|
||||
if (!showDesktop && dir.InitCheck() == B_OK && dir.IsRootDirectory()) {
|
||||
// if we're at the root directory skip "mnt" and
|
||||
// go straight to "/"
|
||||
parent.SetTo("/");
|
||||
@@ -143,8 +142,7 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
bool hitRoot = false;
|
||||
|
||||
BDirectory dir(&entry);
|
||||
if (!showDesktop && dir.InitCheck() == B_OK
|
||||
&& dir.IsRootDirectory()) {
|
||||
if (!showDesktop && dir.InitCheck() == B_OK && dir.IsRootDirectory()) {
|
||||
// if we're at the root directory skip "mnt" and
|
||||
// go straight to "/"
|
||||
hitRoot = true;
|
||||
@@ -167,8 +165,7 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
|
||||
if (result == kReadAttrFailed || !info.fInvisible
|
||||
|| (showDesktop && desktopEntry == entry)) {
|
||||
AddItemToDirMenu(&entry, originatingWindow, reverse,
|
||||
addShortcuts, navMenuEntries);
|
||||
AddItemToDirMenu(&entry, source, reverse, addShortcuts, navMenuEntries);
|
||||
}
|
||||
|
||||
if (hitRoot) {
|
||||
@@ -186,8 +183,7 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
if (!select)
|
||||
return;
|
||||
|
||||
ModelMenuItem* item
|
||||
= dynamic_cast<ModelMenuItem*>(ItemAt(CountItems() - 1));
|
||||
ModelMenuItem* item = dynamic_cast<ModelMenuItem*>(ItemAt(CountItems() - 1));
|
||||
if (item != NULL) {
|
||||
item->SetMarked(true);
|
||||
if (menu) {
|
||||
@@ -207,7 +203,7 @@ BDirMenu::Populate(const BEntry* startEntry, BWindow* originatingWindow,
|
||||
|
||||
|
||||
void
|
||||
BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
|
||||
BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* source,
|
||||
bool atEnd, bool addShortcuts, bool navMenuEntries)
|
||||
{
|
||||
Model model(entry);
|
||||
@@ -219,16 +215,14 @@ BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
|
||||
|
||||
// add reference to the container windows model so that we can
|
||||
// close the window if
|
||||
BContainerWindow* window = originatingWindow ?
|
||||
dynamic_cast<BContainerWindow*>(originatingWindow) : 0;
|
||||
BContainerWindow* window = dynamic_cast<BContainerWindow*>(source);
|
||||
if (window != NULL) {
|
||||
message->AddData("nodeRefsToClose", B_RAW_TYPE,
|
||||
window->TargetModel()->NodeRef(), sizeof (node_ref));
|
||||
window->TargetModel()->NodeRef(), sizeof(node_ref));
|
||||
}
|
||||
ModelMenuItem* item;
|
||||
if (navMenuEntries) {
|
||||
BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED,
|
||||
fTarget, window);
|
||||
BNavMenu* subMenu = new BNavMenu(model.Name(), fCommand, fTarget, source);
|
||||
entry_ref ref;
|
||||
entry->GetRef(&ref);
|
||||
subMenu->SetNavDir(&ref);
|
||||
@@ -254,8 +248,7 @@ BDirMenu::AddItemToDirMenu(const BEntry* entry, BWindow* originatingWindow,
|
||||
item->SetTarget(fTarget);
|
||||
|
||||
if (fMenuBar != NULL) {
|
||||
ModelMenuItem* menu
|
||||
= dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
|
||||
ModelMenuItem* menu = dynamic_cast<ModelMenuItem*>(fMenuBar->ItemAt(0));
|
||||
if (menu != NULL) {
|
||||
ThrowOnError(menu->SetEntry(entry));
|
||||
item->SetMarked(true);
|
||||
@@ -272,13 +265,21 @@ BDirMenu::AddDisksIconToMenu(bool atEnd)
|
||||
if (model.InitCheck() != B_OK)
|
||||
return;
|
||||
|
||||
entry_ref ref;
|
||||
entry.GetRef(&ref);
|
||||
BMessage* message = new BMessage(fCommand);
|
||||
message->AddRef(fEntryName.String(), model.EntryRef());
|
||||
message->AddRef(fEntryName.String(), &ref);
|
||||
|
||||
BNavMenu* subMenu = new BNavMenu(model.Name(), fCommand, fTarget);
|
||||
subMenu->SetNavDir(&ref);
|
||||
ModelMenuItem* item = new ModelMenuItem(&model, subMenu);
|
||||
item->SetLabel(model.Name());
|
||||
item->SetMessage(message);
|
||||
|
||||
ModelMenuItem* item = new ModelMenuItem(&model,
|
||||
B_TRANSLATE(B_DISKS_DIR_NAME), message);
|
||||
if (atEnd)
|
||||
AddItem(item);
|
||||
else
|
||||
AddItem(item, 0);
|
||||
|
||||
item->SetTarget(fTarget);
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ DraggableContainerIcon::MouseDown(BPoint where)
|
||||
if (window == NULL)
|
||||
return;
|
||||
|
||||
// we don't like the Trash icon (because it cannot be moved)
|
||||
if (window->TargetModel()->IsTrash() || window->TargetModel()->IsPrintersDir())
|
||||
if (!window->ShouldHaveDraggableFolderIcon())
|
||||
return;
|
||||
|
||||
if (window->CurrentMessage() == NULL)
|
||||
|
||||
@@ -624,7 +624,7 @@ ConfirmChangeIfWellKnownDirectory(const BEntry* entry, DestructiveAction action,
|
||||
if (confirmedAlready && *confirmedAlready == kConfirmedAll)
|
||||
return true;
|
||||
|
||||
if (FSIsDeskDir(entry) || FSIsTrashDir(entry) || FSIsRootDir(entry))
|
||||
if (FSIsDeskDir(entry) || FSIsPrintersDir(entry) || FSIsRootDir(entry) || FSIsTrashDir(entry))
|
||||
return false;
|
||||
|
||||
if ((!DirectoryMatchesOrContains(entry, B_SYSTEM_DIRECTORY)
|
||||
@@ -891,26 +891,44 @@ InitCopy(CopyLoopControl* loopControl, uint32 moveMode,
|
||||
BEntry entry((entry_ref*)srcList->ItemAt(index));
|
||||
if (FSIsRootDir(&entry)) {
|
||||
BString errorStr;
|
||||
if (moveMode == kCreateLink) {
|
||||
errorStr.SetTo(
|
||||
B_TRANSLATE("You cannot create a link to the root "
|
||||
"directory."));
|
||||
} else {
|
||||
errorStr.SetTo(
|
||||
B_TRANSLATE("You cannot copy or move the root "
|
||||
"directory."));
|
||||
}
|
||||
if (moveMode == kCreateLink || moveMode == kCreateRelativeLink)
|
||||
errorStr.SetTo(B_TRANSLATE("You cannot create a link to the root directory."));
|
||||
else
|
||||
errorStr.SetTo(B_TRANSLATE("You cannot copy or move the root directory."));
|
||||
|
||||
BAlert* alert = new BAlert("", errorStr.String(),
|
||||
B_TRANSLATE("Cancel"), 0, 0, B_WIDTH_AS_USUAL,
|
||||
B_WARNING_ALERT);
|
||||
BAlert* alert = new BAlert("", errorStr.String(), B_TRANSLATE("Cancel"), 0, 0,
|
||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
alert->Go();
|
||||
|
||||
return B_ERROR;
|
||||
} else if (FSIsTrashDir(&entry)) {
|
||||
BString errorStr;
|
||||
if (moveMode == kCreateLink || moveMode == kCreateRelativeLink)
|
||||
errorStr.SetTo(B_TRANSLATE("You cannot create a link to the Trash directory."));
|
||||
else
|
||||
errorStr.SetTo(B_TRANSLATE("You cannot copy or move the Trash directory."));
|
||||
|
||||
BAlert* alert = new BAlert("", errorStr.String(), B_TRANSLATE("Cancel"), 0, 0,
|
||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
alert->Go();
|
||||
|
||||
return B_ERROR;
|
||||
} else if (FSIsPrintersDir(&entry)
|
||||
&& (moveMode == kCopySelectionTo || moveMode == kMoveSelectionTo)) {
|
||||
BString errorStr(B_TRANSLATE("You cannot copy or move the Printers directory."));
|
||||
|
||||
BAlert* alert = new BAlert("", errorStr.String(), B_TRANSLATE("Cancel"), 0, 0,
|
||||
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
|
||||
alert->Go();
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (moveMode == kMoveSelectionTo
|
||||
&& !ConfirmChangeIfWellKnownDirectory(&entry, kMove,
|
||||
false, &askOnceOnly)) {
|
||||
&& !ConfirmChangeIfWellKnownDirectory(&entry, kMove, false, &askOnceOnly)) {
|
||||
return B_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +104,8 @@ public:
|
||||
// a default state file the last time it ran.
|
||||
bool DefaultStateRestored() const { return fDefaultStateRestored; }
|
||||
|
||||
virtual bool ShouldHaveDraggableFolderIcon() { return false; };
|
||||
|
||||
protected:
|
||||
BPoseView* NewPoseView(Model* model, uint32);
|
||||
virtual void Init(const BMessage* message = NULL);
|
||||
|
||||
@@ -667,6 +667,22 @@ IconCache::GetRootIcon(AutoLock<SimpleIconCache>*,
|
||||
}
|
||||
|
||||
|
||||
IconCacheEntry*
|
||||
IconCache::GetPrinterIcon(AutoLock<SimpleIconCache>*,
|
||||
AutoLock<SimpleIconCache>* sharedCacheLocker,
|
||||
AutoLock<SimpleIconCache>** resultingOpenCache,
|
||||
Model*, IconSource &source, IconDrawMode mode,
|
||||
BSize size, LazyBitmapAllocator* lazyBitmap)
|
||||
{
|
||||
*resultingOpenCache = sharedCacheLocker;
|
||||
(*resultingOpenCache)->Lock();
|
||||
|
||||
source = kTrackerSupplied;
|
||||
|
||||
return GetIconFromMetaMime(B_PRINTER_MIMETYPE, mode, size, lazyBitmap, 0);
|
||||
}
|
||||
|
||||
|
||||
IconCacheEntry*
|
||||
IconCache::GetWellKnownIcon(AutoLock<SimpleIconCache>*,
|
||||
AutoLock<SimpleIconCache>* sharedCacheLocker,
|
||||
@@ -945,6 +961,10 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
|
||||
&resultingOpenCache, model, source, mode,
|
||||
size, &lazyBitmap);
|
||||
}
|
||||
} else if (model->IsPrintersDir()) {
|
||||
entry = GetPrinterIcon(nodeCacheLocker, sharedCacheLocker,
|
||||
&resultingOpenCache, model, source, mode, size, &lazyBitmap);
|
||||
ASSERT(entry != NULL);
|
||||
} else {
|
||||
if (source == kUnknownSource) {
|
||||
// look for node icons first
|
||||
@@ -1001,6 +1021,11 @@ IconCache::Preload(AutoLock<SimpleIconCache>* nodeCacheLocker,
|
||||
&resultingOpenCache, model, source, mode, size,
|
||||
&lazyBitmap);
|
||||
break;
|
||||
} else if (model->IsPrintersDir()) {
|
||||
entry = GetPrinterIcon(nodeCacheLocker, sharedCacheLocker,
|
||||
&resultingOpenCache, model, source, mode, size,
|
||||
&lazyBitmap);
|
||||
break;
|
||||
} else {
|
||||
entry = GetWellKnownIcon(nodeCacheLocker,
|
||||
sharedCacheLocker, &resultingOpenCache, model,
|
||||
|
||||
@@ -446,6 +446,11 @@ private:
|
||||
AutoLock<SimpleIconCache>** resultingLockedCache,
|
||||
Model*, IconSource&, IconDrawMode mode,
|
||||
BSize size, LazyBitmapAllocator*);
|
||||
IconCacheEntry* GetPrinterIcon(AutoLock<SimpleIconCache>* nodeCache,
|
||||
AutoLock<SimpleIconCache>* sharedCache,
|
||||
AutoLock<SimpleIconCache>** resultingLockedCache,
|
||||
Model*, IconSource&, IconDrawMode mode,
|
||||
BSize size, LazyBitmapAllocator*);
|
||||
IconCacheEntry* GetWellKnownIcon(AutoLock<SimpleIconCache> *nodeCache,
|
||||
AutoLock<SimpleIconCache>* sharedCache,
|
||||
AutoLock<SimpleIconCache>** resultingLockedCache,
|
||||
|
||||
@@ -280,11 +280,10 @@ BNavMenu::BNavMenu(const char* title, uint32 message, const BHandler* target,
|
||||
|
||||
// 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 != NULL) {
|
||||
BContainerWindow* source = dynamic_cast<BContainerWindow*>(fParentWindow);
|
||||
if (source != NULL) {
|
||||
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
|
||||
originatingWindow->TargetModel()->NodeRef(), sizeof(node_ref));
|
||||
source->TargetModel()->NodeRef(), sizeof(node_ref));
|
||||
}
|
||||
|
||||
// too long to have triggers
|
||||
@@ -313,11 +312,10 @@ BNavMenu::BNavMenu(const char* title, uint32 message,
|
||||
|
||||
// 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 != NULL) {
|
||||
BContainerWindow* source = dynamic_cast<BContainerWindow*>(fParentWindow);
|
||||
if (source != NULL) {
|
||||
fMessage.AddData("nodeRefsToClose", B_RAW_TYPE,
|
||||
originatingWindow->TargetModel()->NodeRef(), sizeof (node_ref));
|
||||
source->TargetModel()->NodeRef(), sizeof(node_ref));
|
||||
}
|
||||
|
||||
// too long to have triggers
|
||||
@@ -417,9 +415,8 @@ BNavMenu::StartBuildingItemList()
|
||||
status_t status = entry.GetParent(&parent);
|
||||
|
||||
// if ref is the root item then build list of volume root dirs
|
||||
fFlags = uint8((fFlags & ~kVolumesOnly)
|
||||
| (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
|
||||
if (fFlags & kVolumesOnly)
|
||||
fFlags = uint8((fFlags & ~kVolumesOnly) | (status == B_ENTRY_NOT_FOUND ? kVolumesOnly : 0));
|
||||
if ((fFlags & kVolumesOnly) != 0)
|
||||
return true;
|
||||
|
||||
Model startModel(&entry, true);
|
||||
@@ -432,8 +429,8 @@ BNavMenu::StartBuildingItemList()
|
||||
fContainer = new VirtualDirectoryEntryList(&startModel);
|
||||
} else if (startModel.IsDesktop()) {
|
||||
fIteratingDesktop = true;
|
||||
fContainer = DesktopPoseView::InitDesktopDirentIterator(0,
|
||||
startModel.EntryRef());
|
||||
fContainer = DesktopPoseView::InitDesktopDirentIterator(0, startModel.EntryRef());
|
||||
if (TrackerSettings().MountVolumesOntoDesktop())
|
||||
AddRootItemsIfNeeded();
|
||||
AddTrashItem();
|
||||
} else if (startModel.IsTrash()) {
|
||||
@@ -445,26 +442,20 @@ BNavMenu::StartBuildingItemList()
|
||||
fContainer = new EntryIteratorList();
|
||||
|
||||
while (volRoster.GetNextVolume(&volume) == B_OK) {
|
||||
if (volume.IsReadOnly() || !volume.IsPersistent())
|
||||
if (volume.IsReadOnly() || !volume.IsPersistent() || volume.Capacity() == 0)
|
||||
continue;
|
||||
|
||||
BDirectory trashDir;
|
||||
|
||||
if (FSGetTrashDir(&trashDir, volume.Device()) == B_OK) {
|
||||
EntryIteratorList* iteratorList
|
||||
= dynamic_cast<EntryIteratorList*>(fContainer);
|
||||
|
||||
EntryIteratorList* iteratorList = dynamic_cast<EntryIteratorList*>(fContainer);
|
||||
ASSERT(iteratorList != NULL);
|
||||
|
||||
if (iteratorList != NULL)
|
||||
iteratorList->AddItem(new DirectoryEntryList(trashDir));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
BDirectory* directory = dynamic_cast<BDirectory*>(startModel.Node());
|
||||
|
||||
ASSERT(directory != NULL);
|
||||
|
||||
if (directory != NULL)
|
||||
fContainer = new DirectoryEntryList(*directory);
|
||||
}
|
||||
@@ -483,17 +474,19 @@ BNavMenu::AddRootItemsIfNeeded()
|
||||
{
|
||||
BVolumeRoster roster;
|
||||
roster.Rewind();
|
||||
|
||||
BVolume volume;
|
||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
||||
BDirectory root;
|
||||
BEntry entry;
|
||||
if (!volume.IsPersistent()
|
||||
|| volume.GetRootDirectory(&root) != B_OK
|
||||
|| root.GetEntry(&entry) != B_OK) {
|
||||
Model model;
|
||||
|
||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
||||
if (volume.InitCheck() != B_OK || !volume.IsPersistent() || volume.Capacity() == 0
|
||||
|| volume.GetRootDirectory(&root) != B_OK || root.GetEntry(&entry) != B_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Model model(&entry);
|
||||
model.SetTo(&entry);
|
||||
AddOneItem(&model);
|
||||
}
|
||||
}
|
||||
@@ -537,8 +530,11 @@ BNavMenu::AddNextItem()
|
||||
return true;
|
||||
}
|
||||
|
||||
QueryEntryListCollection* queryContainer
|
||||
= dynamic_cast<QueryEntryListCollection*>(fContainer);
|
||||
// skip Trash
|
||||
if (model.IsTrash())
|
||||
return true;
|
||||
|
||||
QueryEntryListCollection* queryContainer = dynamic_cast<QueryEntryListCollection*>(fContainer);
|
||||
if (queryContainer != NULL && !queryContainer->ShowResultsFromTrash()
|
||||
&& FSInTrashDir(model.EntryRef())) {
|
||||
// query entry is in trash and shall not be shown
|
||||
@@ -547,18 +543,14 @@ BNavMenu::AddNextItem()
|
||||
|
||||
ssize_t size = -1;
|
||||
PoseInfo poseInfo;
|
||||
if (model.Node() != NULL) {
|
||||
size = model.Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0,
|
||||
&poseInfo, sizeof(poseInfo));
|
||||
}
|
||||
if (model.Node() != NULL)
|
||||
size = model.Node()->ReadAttr(kAttrPoseInfo, B_RAW_TYPE, 0, &poseInfo, sizeof(poseInfo));
|
||||
|
||||
model.CloseNode();
|
||||
|
||||
// item might be in invisible
|
||||
if (size == sizeof(poseInfo)
|
||||
&& !BPoseView::PoseVisible(&model, &poseInfo)) {
|
||||
if (size == sizeof(poseInfo) && !BPoseView::PoseVisible(&model, &poseInfo))
|
||||
return true;
|
||||
}
|
||||
|
||||
AddOneItem(&model);
|
||||
|
||||
@@ -676,16 +668,17 @@ void
|
||||
BNavMenu::BuildVolumeMenu()
|
||||
{
|
||||
BVolumeRoster roster;
|
||||
BVolume volume;
|
||||
|
||||
roster.Rewind();
|
||||
|
||||
BVolume volume;
|
||||
BDirectory startDir;
|
||||
BEntry entry;
|
||||
|
||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
||||
if (!volume.IsPersistent())
|
||||
if (volume.InitCheck() != B_OK || !volume.IsPersistent() || volume.Capacity() == 0)
|
||||
continue;
|
||||
|
||||
BDirectory startDir;
|
||||
if (volume.GetRootDirectory(&startDir) == B_OK) {
|
||||
BEntry entry;
|
||||
startDir.GetEntry(&entry);
|
||||
|
||||
Model* model = new Model(&entry);
|
||||
@@ -755,12 +748,10 @@ BNavMenu::DoneBuildingItemList()
|
||||
if ((fFlags & kShowParent) != 0) {
|
||||
BDirectory directory(&fNavDir);
|
||||
BEntry entry(&fNavDir);
|
||||
if (!directory.IsRootDirectory()
|
||||
&& entry.GetParent(&entry) == B_OK) {
|
||||
if (!directory.IsRootDirectory() && entry.GetParent(&entry) == B_OK) {
|
||||
Model model(&entry, true);
|
||||
BLooper* looper;
|
||||
AddNavParentDir(&model, fMessage.what,
|
||||
fMessenger.Target(&looper));
|
||||
AddNavParentDir(&model, fMessage.what, fMessenger.Target(&looper));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -152,6 +152,8 @@ public:
|
||||
void SetCanSetAppAsDefault(bool);
|
||||
void SetCanOpen(bool);
|
||||
|
||||
virtual bool ShouldHaveDraggableFolderIcon() { return false; };
|
||||
|
||||
OpenWithPoseView* PoseView() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -5838,14 +5838,14 @@ BPoseView::AttributeChanged(const BMessage* message)
|
||||
attrName = NULL;
|
||||
|
||||
Model* targetModel = TargetModel();
|
||||
if (targetModel != NULL && *targetModel->NodeRef() == itemNode
|
||||
&& targetModel->IsNodeOpen()
|
||||
if (ContainerWindow()->ShouldHaveDraggableFolderIcon() && targetModel != NULL
|
||||
&& *targetModel->NodeRef() == itemNode && targetModel->IsNodeOpen()
|
||||
&& targetModel->AttrChanged(attrName)) {
|
||||
// the icon of our target has changed, update drag icon
|
||||
// TODO: make this simpler (i.e. store the icon with the window)
|
||||
BView* view = Window()->FindView("MenuBar");
|
||||
if (view != NULL) {
|
||||
view = view->FindView("ThisContainer");
|
||||
view = view->FindView("DraggableContainerIcon");
|
||||
if (view != NULL) {
|
||||
IconCache::sIconCache->IconChanged(targetModel);
|
||||
view->Invalidate();
|
||||
|
||||
Reference in New Issue
Block a user