Ticket #3385: inconsistencies when single window + disks icon

When using the Show Disks icon option, single window navigaton mode,
and starting navigation by the Disks icon, these bugs would occurs
upon entering child poses :

*) The draggable icon at the top right wouldn't appear
*) The file menu wouldn't update properly (for example, the New folder
menu item won't show)

Based in part on dru_ed's patch.
This commit is contained in:
Philippe Saint-Pierre 2014-07-14 21:04:34 -04:00
parent 18842fc23e
commit 384eec8fb3
6 changed files with 89 additions and 280 deletions

View File

@ -934,19 +934,8 @@ BContainerWindow::Init(const BMessage* message)
-(KeyMenuBar()->Bounds().Height())); -(KeyMenuBar()->Bounds().Height()));
} }
// add folder icon to menu bar if (!TargetModel()->IsRoot() && !IsTrash())
if (!TargetModel()->IsRoot() && !IsTrash()) { _AddFolderIcon();
float iconSize = fMenuBar->Bounds().Height() - 2;
if (iconSize < 16)
iconSize = 16;
float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2
- iconSize) / 2;
BView* icon = new DraggableContainerIcon(BRect(Bounds().Width()
- 4 - iconSize + 1, iconPosY, Bounds().Width() - 4,
iconPosY + iconSize - 1), "ThisContainer",
B_FOLLOW_RIGHT);
fMenuBar->AddChild(icon);
}
} else { } else {
// add equivalents of the menu shortcuts to the menuless // add equivalents of the menu shortcuts to the menuless
// desktop window // desktop window
@ -1183,11 +1172,10 @@ BContainerWindow::WorkspacesChanged(uint32, uint32)
void void
BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode) BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode)
{ {
BView* view = FindView("MenuBar"); if (fMenuBar != NULL) {
if (view != NULL) {
// make sure the draggable icon hides if it doesn't // make sure the draggable icon hides if it doesn't
// have space left anymore // have space left anymore
view = view->FindView("ThisContainer"); BView *view = fMenuBar->FindView("ThisContainer");
if (view != NULL) if (view != NULL)
view->FrameMoved(view->Frame().LeftTop()); view->FrameMoved(view->Frame().LeftTop());
} }
@ -1596,12 +1584,20 @@ BContainerWindow::MessageReceived(BMessage* message)
settings.SingleWindowBrowse()); settings.SingleWindowBrowse());
// Update draggable folder icon // Update draggable folder icon
BView* view = FindView("MenuBar"); if (fMenuBar != NULL) {
if (view != NULL) { BView *view = fMenuBar->FindView("ThisContainer");
view = view->FindView("ThisContainer"); if (!TargetModel()->IsRoot() && !IsTrash()) {
if (view != NULL) { // Folder icon should be visible, but in single
IconCache::sIconCache->IconChanged(TargetModel()); // window navigation, it might not be.
view->Invalidate(); if (view != NULL) {
IconCache::sIconCache->IconChanged(
TargetModel());
view->Invalidate();
} else
_AddFolderIcon();
} else if (view != NULL) {
view->RemoveSelf();
fMenuBar->Invalidate();
} }
} }
@ -1918,7 +1914,7 @@ BContainerWindow::AddFileMenu(BMenu* menu)
} }
if (!TargetModel()->IsQuery() && !TargetModel()->IsVirtualDirectory() if (!TargetModel()->IsQuery() && !TargetModel()->IsVirtualDirectory()
&& !IsTrash() && !IsPrintersDir()) { && !IsTrash() && !IsPrintersDir() && !TargetModel()->IsRoot()) {
if (!PoseView()->IsFilePanel()) { if (!PoseView()->IsFilePanel()) {
TemplatesMenu* templateMenu = new TemplatesMenu(PoseView(), TemplatesMenu* templateMenu = new TemplatesMenu(PoseView(),
B_TRANSLATE("New")); B_TRANSLATE("New"));
@ -1953,6 +1949,13 @@ BContainerWindow::AddFileMenu(BMenu* menu)
menu->AddItem(new BSeparatorItem(), 1); menu->AddItem(new BSeparatorItem(), 1);
menu->AddItem(new BMenuItem(B_TRANSLATE("Make active printer"), menu->AddItem(new BMenuItem(B_TRANSLATE("Make active printer"),
new BMessage(kMakeActivePrinter))); new BMessage(kMakeActivePrinter)));
} else if (TargetModel()->IsRoot()) {
BMenuItem* item = new BMenuItem(B_TRANSLATE("Unmount"),
new BMessage(kUnmountVolume), 'U');
item->SetEnabled(false);
menu->AddItem(item);
menu->AddItem(new BMenuItem(B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS),
new BMessage(kRunAutomounterSettings)));
} else { } else {
menu->AddItem(new BMenuItem(B_TRANSLATE("Duplicate"), menu->AddItem(new BMenuItem(B_TRANSLATE("Duplicate"),
new BMessage(kDuplicateSelection), 'D')); new BMessage(kDuplicateSelection), 'D'));
@ -1972,17 +1975,19 @@ BContainerWindow::AddFileMenu(BMenu* menu)
if (!IsPrintersDir()) { if (!IsPrintersDir()) {
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(cutItem = new BMenuItem(B_TRANSLATE("Cut"), if (!TargetModel()->IsRoot()) {
new BMessage(B_CUT), 'X')); menu->AddItem(cutItem = new(std::nothrow) BMenuItem(
menu->AddItem(copyItem = new BMenuItem(B_TRANSLATE("Copy"), B_TRANSLATE("Cut"), new BMessage(B_CUT), 'X'));
new BMessage(B_COPY), 'C')); menu->AddItem(copyItem = new(std::nothrow) BMenuItem(
menu->AddItem(pasteItem = new BMenuItem(B_TRANSLATE("Paste"), B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C'));
new BMessage(B_PASTE), 'V')); menu->AddItem(pasteItem = new(std::nothrow) BMenuItem(
B_TRANSLATE("Paste"), new BMessage(B_PASTE), 'V'));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Identify"), menu->AddItem(new BMenuItem(B_TRANSLATE("Identify"),
new BMessage(kIdentifyEntry))); new BMessage(kIdentifyEntry)));
}
BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons")); BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons"));
addOnMenuItem->SetFont(be_plain_font); addOnMenuItem->SetFont(be_plain_font);
menu->AddItem(addOnMenuItem); menu->AddItem(addOnMenuItem);
@ -2202,6 +2207,30 @@ BContainerWindow::MenusBeginning()
? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef() ? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef()
: NULL, fFileMenu); : NULL, fFileMenu);
if (TargetModel()->IsRoot()) {
BVolume boot;
BVolumeRoster().GetBootVolume(&boot);
bool ejectableVolumeSelected = false;
int32 count = PoseView()->SelectionList()->CountItems();
for (int32 index = 0; index < count; index++) {
Model* model
= PoseView()->SelectionList()->ItemAt(index)->TargetModel();
if (model->IsVolume()) {
BVolume volume;
volume.SetTo(model->NodeRef()->device);
if (volume != boot) {
ejectableVolumeSelected = true;
break;
}
}
}
BMenuItem* item = fMenuBar->FindItem(kUnmountVolume);
if (item != NULL)
item->SetEnabled(ejectableVolumeSelected);
}
UpdateMenu(fMenuBar, kMenuBarContext); UpdateMenu(fMenuBar, kMenuBarContext);
AddMimeTypesToMenu(fAttrMenu); AddMimeTypesToMenu(fAttrMenu);
@ -2501,7 +2530,7 @@ void
BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent) BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent)
{ {
if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem
|| !fCopyToItem || !fCreateLinkItem) { || !fCopyToItem || !fCreateLinkItem || TargetModel()->IsRoot()) {
return; return;
} }
@ -2879,7 +2908,7 @@ BContainerWindow::AddWindowContextMenus(BMenu* menu)
} else if (IsPrintersDir()) { } else if (IsPrintersDir()) {
menu->AddItem(new BMenuItem(B_TRANSLATE("Add printer" B_UTF8_ELLIPSIS), menu->AddItem(new BMenuItem(B_TRANSLATE("Add printer" B_UTF8_ELLIPSIS),
new BMessage(kAddPrinter), 'N')); new BMessage(kAddPrinter), 'N'));
} else if (InTrash()) } else if (InTrash() || TargetModel()->IsRoot())
needSeparator = false; needSeparator = false;
else { else {
TemplatesMenu* templateMenu = new TemplatesMenu(PoseView(), TemplatesMenu* templateMenu = new TemplatesMenu(PoseView(),
@ -2911,6 +2940,11 @@ BContainerWindow::AddWindowContextMenus(BMenu* menu)
new BMessage(kOpenParentDir), B_UP_ARROW)); new BMessage(kOpenParentDir), B_UP_ARROW));
} }
if (TargetModel()->IsRoot()) {
menu->AddSeparatorItem();
menu->AddItem(new MountMenu(B_TRANSLATE("Mount")));
}
menu->AddSeparatorItem(); menu->AddSeparatorItem();
BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons")); BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons"));
addOnMenuItem->SetFont(be_plain_font); addOnMenuItem->SetFont(be_plain_font);
@ -3262,6 +3296,26 @@ BContainerWindow::_UpdateSelectionMIMEInfo()
} }
void
BContainerWindow::_AddFolderIcon()
{
if (fMenuBar == NULL)
return;
float iconSize = fMenuBar->Bounds().Height() - 2;
if (iconSize < 16)
iconSize = 16;
float iconPosY = 1 + (fMenuBar->Bounds().Height() - 2
- iconSize) / 2;
BView* icon = new(std::nothrow) DraggableContainerIcon(
BRect(Bounds().Width() - 4 - iconSize + 1, iconPosY,
Bounds().Width() - 4, iconPosY + iconSize - 1), "ThisContainer",
B_FOLLOW_RIGHT);
if (icon != NULL)
fMenuBar->AddChild(icon);
}
BMenuItem* BMenuItem*
BContainerWindow::NewAttributeMenuItem(const char* label, const char* name, BContainerWindow::NewAttributeMenuItem(const char* label, const char* name,
int32 type, float width, int32 align, bool editable, bool statField) int32 type, float width, int32 align, bool editable, bool statField)

View File

@ -328,6 +328,7 @@ private:
friend class BackgroundView; friend class BackgroundView;
void _UpdateSelectionMIMEInfo(); void _UpdateSelectionMIMEInfo();
void _AddFolderIcon();
}; };

View File

@ -98,7 +98,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
VirtualDirectoryManager.cpp VirtualDirectoryManager.cpp
VirtualDirectoryPoseView.cpp VirtualDirectoryPoseView.cpp
VirtualDirectoryWindow.cpp VirtualDirectoryWindow.cpp
VolumeWindow.cpp
WidgetAttributeText.cpp WidgetAttributeText.cpp
: :
@ -143,7 +142,6 @@ DoCatalogs libtracker.so :
Tracker.cpp Tracker.cpp
TrackerInitialState.cpp TrackerInitialState.cpp
TrackerSettingsWindow.cpp TrackerSettingsWindow.cpp
VolumeWindow.cpp
WidgetAttributeText.cpp WidgetAttributeText.cpp
; ;

View File

@ -88,7 +88,6 @@ All rights reserved.
#include "Thread.h" #include "Thread.h"
#include "Utilities.h" #include "Utilities.h"
#include "VirtualDirectoryWindow.h" #include "VirtualDirectoryWindow.h"
#include "VolumeWindow.h"
#undef B_TRANSLATION_CONTEXT #undef B_TRANSLATION_CONTEXT
@ -1005,9 +1004,6 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList,
refList = new BMessage(*originalRefsList); refList = new BMessage(*originalRefsList);
} }
window = new OpenWithContainerWindow(refList, &fWindowList); window = new OpenWithContainerWindow(refList, &fWindowList);
} else if (model->IsRoot()) {
// window will adopt the model
window = new BVolumeWindow(&fWindowList, openFlags);
} else if (model->IsQuery()) { } else if (model->IsQuery()) {
// window will adopt the model // window will adopt the model
window = new BQueryContainerWindow(&fWindowList, openFlags); window = new BQueryContainerWindow(&fWindowList, openFlags);

View File

@ -1,172 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#include <Catalog.h>
#include <Debug.h>
#include <Locale.h>
#include <Menu.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <Path.h>
#include <PopUpMenu.h>
#include <Volume.h>
#include <VolumeRoster.h>
#include "Commands.h"
#include "VolumeWindow.h"
#include "PoseView.h"
#include "MountMenu.h"
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "VolumeWindow"
// #pragma mark - BVolumeWindow
BVolumeWindow::BVolumeWindow(LockingList<BWindow>* windowList,
uint32 openFlags)
:
BContainerWindow(windowList, openFlags)
{
}
void
BVolumeWindow::MenusBeginning()
{
_inherited::MenusBeginning();
if (!fMenuBar)
return;
BVolume boot;
BVolumeRoster().GetBootVolume(&boot);
bool ejectableVolumeSelected = false;
int32 count = PoseView()->SelectionList()->CountItems();
for (int32 index = 0; index < count; index++) {
Model* model
= PoseView()->SelectionList()->ItemAt(index)->TargetModel();
if (model->IsVolume()) {
BVolume volume;
volume.SetTo(model->NodeRef()->device);
if (volume != boot) {
ejectableVolumeSelected = true;
break;
}
}
}
BMenuItem* item = fMenuBar->FindItem(kUnmountVolume);
if (item != NULL)
item->SetEnabled(ejectableVolumeSelected);
}
void
BVolumeWindow::AddFileMenu(BMenu* menu)
{
menu->AddItem(new BMenuItem(B_TRANSLATE("Find" B_UTF8_ELLIPSIS),
new BMessage(kFindButton), 'F'));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Open"),
new BMessage(kOpenSelection), 'O'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Get info"),
new BMessage(kGetInfo), 'I'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Edit name"),
new BMessage(kEditItem), 'E'));
BMenuItem* item = new BMenuItem(B_TRANSLATE("Unmount"),
new BMessage(kUnmountVolume), 'U');
item->SetEnabled(false);
menu->AddItem(item);
menu->AddItem(new BMenuItem(B_TRANSLATE("Mount settings" B_UTF8_ELLIPSIS),
new BMessage(kRunAutomounterSettings)));
menu->AddSeparatorItem();
menu->AddItem(new BMenu(B_TRANSLATE("Add-ons")));
menu->SetTargetForItems(PoseView());
}
void
BVolumeWindow::AddWindowContextMenus(BMenu* menu)
{
if (fPoseView != NULL && fPoseView->TargetModel() != NULL
&& !fPoseView->TargetModel()->IsRoot()) {
_inherited::AddWindowContextMenus(menu);
return;
}
menu->AddItem(new BMenuItem(B_TRANSLATE("Icon view"),
new BMessage(kIconMode)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Mini icon view"),
new BMessage(kMiniIconMode)));
menu->AddItem(new BMenuItem(B_TRANSLATE("List view"),
new BMessage(kListMode)));
menu->AddSeparatorItem();
BMenuItem* resizeItem = new BMenuItem(B_TRANSLATE("Resize to fit"),
new BMessage(kResizeToFit), 'Y');
menu->AddItem(resizeItem);
menu->AddItem(new BMenuItem(B_TRANSLATE("Clean up"),
new BMessage(kCleanup), 'K'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Select" B_UTF8_ELLIPSIS),
new BMessage(kShowSelectionWindow), 'A', B_SHIFT_KEY));
menu->AddItem(new BMenuItem(B_TRANSLATE("Select all"),
new BMessage(B_SELECT_ALL), 'A'));
menu->AddItem(new BMenuItem(B_TRANSLATE("Invert selection"),
new BMessage(kInvertSelection), 'S'));
BMenuItem* closeItem = new BMenuItem(B_TRANSLATE("Close"),
new BMessage(B_QUIT_REQUESTED), 'W');
menu->AddItem(closeItem);
menu->AddSeparatorItem();
menu->AddItem(new MountMenu(B_TRANSLATE("Mount")));
menu->AddSeparatorItem();
menu->AddItem(new BMenu(B_TRANSLATE("Add-ons")));
// target items as needed
menu->SetTargetForItems(PoseView());
closeItem->SetTarget(this);
resizeItem->SetTarget(this);
}

View File

@ -1,68 +0,0 @@
/*
Open Tracker License
Terms and Conditions
Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice applies to all licensees
and shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Be Incorporated shall not be
used in advertising or otherwise to promote the sale, use or other dealings in
this Software without prior written authorization from Be Incorporated.
Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks
of Be Incorporated in the United States and other countries. Other brand product
names are registered trademarks or trademarks of their respective holders.
All rights reserved.
*/
#ifndef _VOLUME_WINDOW_H
#define _VOLUME_WINDOW_H
// The volume window displays the virtual file system root with
// all mounted volumes. Does not show up unless the corresponding Tracker
// setting is enabled
#include "ContainerWindow.h"
namespace BPrivate {
class BVolumeWindow : public BContainerWindow {
public:
BVolumeWindow(LockingList<BWindow>* windowList,
uint32 containerWindowFlags);
protected:
virtual void AddFileMenu(BMenu* menu);
virtual void AddWindowContextMenus(BMenu*);
virtual void MenusBeginning();
private:
typedef BContainerWindow _inherited;
};
} // namespace BPrivate
using namespace BPrivate;
#endif // _VOLUME_WINDOW_H