* Added a way to set the target for a BDirMenu; this didn't work well with

BNavMenus, anyway.
* This fixes ShowImage trying to open anything that is not on top level.
* Automatic white space cleanup in DirMenu.* - I hope Alex doesn't have any
  changes in this file...


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39381 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2010-11-09 21:58:54 +00:00
parent bd13a264f7
commit 71dc3c41c3
5 changed files with 43 additions and 34 deletions

View File

@ -82,14 +82,14 @@ ShowImageStatusView::Draw(BRect updateRect)
void
ShowImageStatusView::MouseDown(BPoint where)
{
BPrivate::BDirMenu* menu = new BDirMenu(NULL, B_REFS_RECEIVED);
BPrivate::BDirMenu* menu = new BDirMenu(NULL, BMessenger(kTrackerSignature),
B_REFS_RECEIVED);
BEntry entry;
if (entry.SetTo(&fRef) == B_OK)
menu->Populate(&entry, Window(), false, false, true, false, true);
else
menu->Populate(NULL, Window(), false, false, true, false, true);
menu->SetTargetForItems(BMessenger(kTrackerSignature));
BPoint point = Bounds().LeftBottom();
point.y += 3;
ConvertToScreen(&point);

View File

@ -308,14 +308,13 @@ BCountView::MouseDown(BPoint)
return;
if (!window->TargetModel()->IsRoot()) {
BDirMenu *menu = new BDirMenu(NULL, B_REFS_RECEIVED);
BDirMenu *menu = new BDirMenu(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);
else
menu->Populate(NULL, Window(), false, false, true, false, true);
menu->SetTargetForItems(be_app);
BPoint point = Bounds().LeftBottom();
point.y += 3;
ConvertToScreen(&point);

View File

@ -57,8 +57,12 @@ All rights reserved.
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "DirMenu"
BDirMenu::BDirMenu(BMenuBar *bar, uint32 command, const char *entryName)
: BPopUpMenu("directories"),
BDirMenu::BDirMenu(BMenuBar *bar, BMessenger target, uint32 command,
const char *entryName)
:
BPopUpMenu("directories"),
fTarget(target),
fMenuBar(bar),
fCommand(command)
{
@ -154,9 +158,10 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow,
}
if (result == kReadAttrFailed || !info.fInvisible
|| (showDesktop && desktopEntry == entry))
|| (showDesktop && desktopEntry == entry)) {
AddItemToDirMenu(&entry, originatingWindow, reverse,
addShortcuts, navMenuEntries);
}
if (hitRoot) {
if (!showDesktop && showDisksIcon && *startEntry != "/")
@ -210,7 +215,8 @@ BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow,
sizeof (node_ref));
ModelMenuItem *item;
if (navMenuEntries) {
BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED, be_app, window);
BNavMenu* subMenu = new BNavMenu(model.Name(), B_REFS_RECEIVED, fTarget,
window);
entry_ref ref;
entry->GetRef(&ref);
subMenu->SetNavDir(&ref);
@ -233,6 +239,8 @@ BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow,
else
AddItem(item, 0);
item->SetTarget(fTarget);
if (fMenuBar) {
ModelMenuItem *menu = dynamic_cast<ModelMenuItem *>(fMenuBar->ItemAt(0));
if (menu) {

View File

@ -44,7 +44,8 @@ namespace BPrivate {
class BDirMenu : public BPopUpMenu {
public:
BDirMenu(BMenuBar *, uint32 command, const char *entryName = 0);
BDirMenu(BMenuBar *, BMessenger target, uint32 command,
const char *entryName = 0);
virtual ~BDirMenu();
void Populate(const BEntry *startDir, BWindow *originatingWindow,
@ -57,6 +58,7 @@ public:
void SetMenuBar(BMenuBar *);
private:
BMessenger fTarget;
BMenuBar *fMenuBar;
uint32 fCommand;
BString fEntryName;

View File

@ -652,7 +652,7 @@ TFilePanel::Init(const BMessage *)
}
// add directory menu and menufield
fDirMenu = new BDirMenu(0, kSwitchDirectory, "refs");
fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");
font_height ht;
be_plain_font->GetHeight(&ht);