hrev47498 adds 1 changeset to branch 'master' old head: 18842fc23e0525c51cd80b7271b1841a55fb54cf new head: 384eec8fb34ee7228bee570bbb119251844f83cf overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=384eec8+%5E18842fc ---------------------------------------------------------------------------- 384eec8: 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. [ Philippe Saint-Pierre <stpere@xxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev47498 Commit: 384eec8fb34ee7228bee570bbb119251844f83cf URL: http://cgit.haiku-os.org/haiku/commit/?id=384eec8 Author: Philippe Saint-Pierre <stpere@xxxxxxxxx> Date: Tue Jul 15 01:04:34 2014 UTC Ticket: https://dev.haiku-os.org/ticket/3385 ---------------------------------------------------------------------------- 6 files changed, 89 insertions(+), 280 deletions(-) src/kits/tracker/ContainerWindow.cpp | 122 ++++++++++++++++------ src/kits/tracker/ContainerWindow.h | 1 + src/kits/tracker/Jamfile | 2 - src/kits/tracker/Tracker.cpp | 4 - src/kits/tracker/VolumeWindow.cpp | 172 ------------------------------- src/kits/tracker/VolumeWindow.h | 68 ------------ ---------------------------------------------------------------------------- diff --git a/src/kits/tracker/ContainerWindow.cpp b/src/kits/tracker/ContainerWindow.cpp index 64ba80f..aea9609 100644 --- a/src/kits/tracker/ContainerWindow.cpp +++ b/src/kits/tracker/ContainerWindow.cpp @@ -934,19 +934,8 @@ BContainerWindow::Init(const BMessage* message) -(KeyMenuBar()->Bounds().Height())); } - // add folder icon to menu bar - if (!TargetModel()->IsRoot() && !IsTrash()) { - 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); - } + if (!TargetModel()->IsRoot() && !IsTrash()) + _AddFolderIcon(); } else { // add equivalents of the menu shortcuts to the menuless // desktop window @@ -1183,11 +1172,10 @@ BContainerWindow::WorkspacesChanged(uint32, uint32) void BContainerWindow::ViewModeChanged(uint32 oldMode, uint32 newMode) { - BView* view = FindView("MenuBar"); - if (view != NULL) { + if (fMenuBar != NULL) { // make sure the draggable icon hides if it doesn't // have space left anymore - view = view->FindView("ThisContainer"); + BView *view = fMenuBar->FindView("ThisContainer"); if (view != NULL) view->FrameMoved(view->Frame().LeftTop()); } @@ -1596,12 +1584,20 @@ BContainerWindow::MessageReceived(BMessage* message) settings.SingleWindowBrowse()); // Update draggable folder icon - BView* view = FindView("MenuBar"); - if (view != NULL) { - view = view->FindView("ThisContainer"); - if (view != NULL) { - IconCache::sIconCache->IconChanged(TargetModel()); - view->Invalidate(); + if (fMenuBar != NULL) { + BView *view = fMenuBar->FindView("ThisContainer"); + if (!TargetModel()->IsRoot() && !IsTrash()) { + // Folder icon should be visible, but in single + // window navigation, it might not be. + 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() - && !IsTrash() && !IsPrintersDir()) { + && !IsTrash() && !IsPrintersDir() && !TargetModel()->IsRoot()) { if (!PoseView()->IsFilePanel()) { TemplatesMenu* templateMenu = new TemplatesMenu(PoseView(), B_TRANSLATE("New")); @@ -1953,6 +1949,13 @@ BContainerWindow::AddFileMenu(BMenu* menu) menu->AddItem(new BSeparatorItem(), 1); menu->AddItem(new BMenuItem(B_TRANSLATE("Make active printer"), 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 { menu->AddItem(new BMenuItem(B_TRANSLATE("Duplicate"), new BMessage(kDuplicateSelection), 'D')); @@ -1972,17 +1975,19 @@ BContainerWindow::AddFileMenu(BMenu* menu) if (!IsPrintersDir()) { menu->AddSeparatorItem(); - menu->AddItem(cutItem = new BMenuItem(B_TRANSLATE("Cut"), - new BMessage(B_CUT), 'X')); - menu->AddItem(copyItem = new BMenuItem(B_TRANSLATE("Copy"), - new BMessage(B_COPY), 'C')); - menu->AddItem(pasteItem = new BMenuItem(B_TRANSLATE("Paste"), - new BMessage(B_PASTE), 'V')); + if (!TargetModel()->IsRoot()) { + menu->AddItem(cutItem = new(std::nothrow) BMenuItem( + B_TRANSLATE("Cut"), new BMessage(B_CUT), 'X')); + menu->AddItem(copyItem = new(std::nothrow) BMenuItem( + B_TRANSLATE("Copy"), new BMessage(B_COPY), 'C')); + 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"), - new BMessage(kIdentifyEntry))); + menu->AddItem(new BMenuItem(B_TRANSLATE("Identify"), + new BMessage(kIdentifyEntry))); + } BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons")); addOnMenuItem->SetFont(be_plain_font); menu->AddItem(addOnMenuItem); @@ -2202,6 +2207,30 @@ BContainerWindow::MenusBeginning() ? PoseView()->SelectionList()->FirstItem()->TargetModel()->EntryRef() : 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); AddMimeTypesToMenu(fAttrMenu); @@ -2501,7 +2530,7 @@ void BContainerWindow::SetupMoveCopyMenus(const entry_ref* item_ref, BMenu* parent) { if (IsTrash() || InTrash() || IsPrintersDir() || !fMoveToItem - || !fCopyToItem || !fCreateLinkItem) { + || !fCopyToItem || !fCreateLinkItem || TargetModel()->IsRoot()) { return; } @@ -2879,7 +2908,7 @@ BContainerWindow::AddWindowContextMenus(BMenu* menu) } else if (IsPrintersDir()) { menu->AddItem(new BMenuItem(B_TRANSLATE("Add printer" B_UTF8_ELLIPSIS), new BMessage(kAddPrinter), 'N')); - } else if (InTrash()) + } else if (InTrash() || TargetModel()->IsRoot()) needSeparator = false; else { TemplatesMenu* templateMenu = new TemplatesMenu(PoseView(), @@ -2911,6 +2940,11 @@ BContainerWindow::AddWindowContextMenus(BMenu* menu) new BMessage(kOpenParentDir), B_UP_ARROW)); } + if (TargetModel()->IsRoot()) { + menu->AddSeparatorItem(); + menu->AddItem(new MountMenu(B_TRANSLATE("Mount"))); + } + menu->AddSeparatorItem(); BMenu* addOnMenuItem = new BMenu(B_TRANSLATE("Add-ons")); 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* BContainerWindow::NewAttributeMenuItem(const char* label, const char* name, int32 type, float width, int32 align, bool editable, bool statField) diff --git a/src/kits/tracker/ContainerWindow.h b/src/kits/tracker/ContainerWindow.h index 80509b3..c9db673 100644 --- a/src/kits/tracker/ContainerWindow.h +++ b/src/kits/tracker/ContainerWindow.h @@ -328,6 +328,7 @@ private: friend class BackgroundView; void _UpdateSelectionMIMEInfo(); + void _AddFolderIcon(); }; diff --git a/src/kits/tracker/Jamfile b/src/kits/tracker/Jamfile index 66a90ea..031400f 100644 --- a/src/kits/tracker/Jamfile +++ b/src/kits/tracker/Jamfile @@ -98,7 +98,6 @@ for architectureObject in [ MultiArchSubDirSetup ] { VirtualDirectoryManager.cpp VirtualDirectoryPoseView.cpp VirtualDirectoryWindow.cpp - VolumeWindow.cpp WidgetAttributeText.cpp : @@ -143,7 +142,6 @@ DoCatalogs libtracker.so : Tracker.cpp TrackerInitialState.cpp TrackerSettingsWindow.cpp - VolumeWindow.cpp WidgetAttributeText.cpp ; diff --git a/src/kits/tracker/Tracker.cpp b/src/kits/tracker/Tracker.cpp index 4d511bc..ea86a0e 100644 --- a/src/kits/tracker/Tracker.cpp +++ b/src/kits/tracker/Tracker.cpp @@ -88,7 +88,6 @@ All rights reserved. #include "Thread.h" #include "Utilities.h" #include "VirtualDirectoryWindow.h" -#include "VolumeWindow.h" #undef B_TRANSLATION_CONTEXT @@ -1005,9 +1004,6 @@ TTracker::OpenContainerWindow(Model* model, BMessage* originalRefsList, refList = new BMessage(*originalRefsList); } window = new OpenWithContainerWindow(refList, &fWindowList); - } else if (model->IsRoot()) { - // window will adopt the model - window = new BVolumeWindow(&fWindowList, openFlags); } else if (model->IsQuery()) { // window will adopt the model window = new BQueryContainerWindow(&fWindowList, openFlags); diff --git a/src/kits/tracker/VolumeWindow.cpp b/src/kits/tracker/VolumeWindow.cpp deleted file mode 100644 index 401bfd4..0000000 --- a/src/kits/tracker/VolumeWindow.cpp +++ /dev/null @@ -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); -} diff --git a/src/kits/tracker/VolumeWindow.h b/src/kits/tracker/VolumeWindow.h deleted file mode 100644 index d2ec72d..0000000 --- a/src/kits/tracker/VolumeWindow.h +++ /dev/null @@ -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