* 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
+2 -2
View File
@@ -82,14 +82,14 @@ ShowImageStatusView::Draw(BRect updateRect)
void void
ShowImageStatusView::MouseDown(BPoint where) 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; BEntry entry;
if (entry.SetTo(&fRef) == B_OK) if (entry.SetTo(&fRef) == B_OK)
menu->Populate(&entry, Window(), false, false, true, false, true); menu->Populate(&entry, Window(), false, false, true, false, true);
else else
menu->Populate(NULL, Window(), false, false, true, false, true); menu->Populate(NULL, Window(), false, false, true, false, true);
menu->SetTargetForItems(BMessenger(kTrackerSignature));
BPoint point = Bounds().LeftBottom(); BPoint point = Bounds().LeftBottom();
point.y += 3; point.y += 3;
ConvertToScreen(&point); ConvertToScreen(&point);
+1 -2
View File
@@ -308,14 +308,13 @@ BCountView::MouseDown(BPoint)
return; return;
if (!window->TargetModel()->IsRoot()) { if (!window->TargetModel()->IsRoot()) {
BDirMenu *menu = new BDirMenu(NULL, B_REFS_RECEIVED); BDirMenu *menu = new BDirMenu(NULL, be_app, B_REFS_RECEIVED);
BEntry entry; BEntry entry;
if (entry.SetTo(window->TargetModel()->EntryRef()) == B_OK) 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 else
menu->Populate(NULL, Window(), false, false, true, false, true); menu->Populate(NULL, Window(), false, false, true, false, true);
menu->SetTargetForItems(be_app);
BPoint point = Bounds().LeftBottom(); BPoint point = Bounds().LeftBottom();
point.y += 3; point.y += 3;
ConvertToScreen(&point); ConvertToScreen(&point);
+12 -4
View File
@@ -57,8 +57,12 @@ All rights reserved.
#undef B_TRANSLATE_CONTEXT #undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "DirMenu" #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), fMenuBar(bar),
fCommand(command) fCommand(command)
{ {
@@ -154,9 +158,10 @@ BDirMenu::Populate(const BEntry *startEntry, BWindow *originatingWindow,
} }
if (result == kReadAttrFailed || !info.fInvisible if (result == kReadAttrFailed || !info.fInvisible
|| (showDesktop && desktopEntry == entry)) || (showDesktop && desktopEntry == entry)) {
AddItemToDirMenu(&entry, originatingWindow, reverse, AddItemToDirMenu(&entry, originatingWindow, reverse,
addShortcuts, navMenuEntries); addShortcuts, navMenuEntries);
}
if (hitRoot) { if (hitRoot) {
if (!showDesktop && showDisksIcon && *startEntry != "/") if (!showDesktop && showDisksIcon && *startEntry != "/")
@@ -210,7 +215,8 @@ BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow,
sizeof (node_ref)); sizeof (node_ref));
ModelMenuItem *item; ModelMenuItem *item;
if (navMenuEntries) { 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_ref ref;
entry->GetRef(&ref); entry->GetRef(&ref);
subMenu->SetNavDir(&ref); subMenu->SetNavDir(&ref);
@@ -233,6 +239,8 @@ BDirMenu::AddItemToDirMenu(const BEntry *entry, BWindow *originatingWindow,
else else
AddItem(item, 0); AddItem(item, 0);
item->SetTarget(fTarget);
if (fMenuBar) { if (fMenuBar) {
ModelMenuItem *menu = dynamic_cast<ModelMenuItem *>(fMenuBar->ItemAt(0)); ModelMenuItem *menu = dynamic_cast<ModelMenuItem *>(fMenuBar->ItemAt(0));
if (menu) { if (menu) {
+3 -1
View File
@@ -44,7 +44,8 @@ namespace BPrivate {
class BDirMenu : public BPopUpMenu { class BDirMenu : public BPopUpMenu {
public: public:
BDirMenu(BMenuBar *, uint32 command, const char *entryName = 0); BDirMenu(BMenuBar *, BMessenger target, uint32 command,
const char *entryName = 0);
virtual ~BDirMenu(); virtual ~BDirMenu();
void Populate(const BEntry *startDir, BWindow *originatingWindow, void Populate(const BEntry *startDir, BWindow *originatingWindow,
@@ -57,6 +58,7 @@ public:
void SetMenuBar(BMenuBar *); void SetMenuBar(BMenuBar *);
private: private:
BMessenger fTarget;
BMenuBar *fMenuBar; BMenuBar *fMenuBar;
uint32 fCommand; uint32 fCommand;
BString fEntryName; BString fEntryName;
+1 -1
View File
@@ -652,7 +652,7 @@ TFilePanel::Init(const BMessage *)
} }
// add directory menu and menufield // add directory menu and menufield
fDirMenu = new BDirMenu(0, kSwitchDirectory, "refs"); fDirMenu = new BDirMenu(0, this, kSwitchDirectory, "refs");
font_height ht; font_height ht;
be_plain_font->GetHeight(&ht); be_plain_font->GetHeight(&ht);