diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp index c5725fa68c..eb6f9e61b7 100644 --- a/src/kits/tracker/FSUtils.cpp +++ b/src/kits/tracker/FSUtils.cpp @@ -623,7 +623,11 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction if (confirmedAlready && *confirmedAlready == kConfirmedAll) return true; + if (FSIsDeskDir(entry) || FSIsTrashDir(entry) || FSIsRootDir(entry)) + return false; + if (!DirectoryMatchesOrContains(entry, B_SYSTEM_DIRECTORY) + && !DirectoryMatchesOrContains(entry, B_COMMON_DIRECTORY) && !DirectoryMatchesOrContains(entry, B_USER_DIRECTORY)) // quick way out return true; @@ -631,18 +635,24 @@ ConfirmChangeIfWellKnownDirectory(const BEntry *entry, const char *ifYouDoAction BString warning; bool requireOverride = true; - if (DirectoryMatchesOrContains(entry, B_BEOS_DIRECTORY)) { + if (DirectoryMatchesOrContains(entry, B_SYSTEM_DIRECTORY)) { warning.SetTo( B_TRANSLATE("If you %ifYouDoAction the system folder or its " "contents, you won't be able to boot " OS_NAME "! Are you sure you " "want to do this? To %toDoAction the system folder or its contents " "anyway, hold down the Shift key and click \"Do it\".")); + } else if (DirectoryMatches(entry, B_COMMON_DIRECTORY)) { + warning.SetTo( + B_TRANSLATE("If you %ifYouDoAction the common folder, " OS_NAME + " may not behave properly! Are you sure you want to do this? " + "To %toDoAction the common folder anyway, hold down the " + "Shift key and click \"Do it\".")); } else if (DirectoryMatches(entry, B_USER_DIRECTORY)) { warning .SetTo( B_TRANSLATE("If you %ifYouDoAction the home folder, " OS_NAME " may not behave properly! Are you sure you want to do this? " - "To %toDoAction the home anyway, click \"Do it\".")); - requireOverride = false; + "To %toDoAction the home folder anyway, hold down the " + "Shift key and click \"Do it\".")); } else if (DirectoryMatchesOrContains(entry, B_USER_CONFIG_DIRECTORY) || DirectoryMatchesOrContains(entry, B_COMMON_SETTINGS_DIRECTORY)) { @@ -2597,6 +2607,14 @@ FSIsHomeDir(const BEntry *entry) } +bool +FSIsRootDir(const BEntry *entry) +{ + BPath path(entry); + return path == "/"; +} + + bool DirectoryMatchesOrContains(const BEntry *entry, directory_which which) { diff --git a/src/kits/tracker/FSUtils.h b/src/kits/tracker/FSUtils.h index e434f3a35b..eb359028b2 100644 --- a/src/kits/tracker/FSUtils.h +++ b/src/kits/tracker/FSUtils.h @@ -172,6 +172,7 @@ _IMPEXP_TRACKER bool FSIsTrashDir(const BEntry *); _IMPEXP_TRACKER bool FSIsPrintersDir(const BEntry *); _IMPEXP_TRACKER bool FSIsDeskDir(const BEntry *); _IMPEXP_TRACKER bool FSIsHomeDir(const BEntry *); +_IMPEXP_TRACKER bool FSIsRootDir(const BEntry *); _IMPEXP_TRACKER void FSMoveToTrash(BObjectList *srcList, BList *pointList = NULL, bool async = true); // Deprecated diff --git a/src/kits/tracker/InfoWindow.cpp b/src/kits/tracker/InfoWindow.cpp index c71aed6f32..ade064c560 100644 --- a/src/kits/tracker/InfoWindow.cpp +++ b/src/kits/tracker/InfoWindow.cpp @@ -299,9 +299,7 @@ BInfoWindow::BInfoWindow(Model *model, int32 group_index, LockingList * if (list) list->AddItem(this); - if (!model->IsTrash() && !model->HasLocalizedName()) - AddShortcut('E', 0, new BMessage(kEditItem)); - + AddShortcut('E', 0, new BMessage(kEditItem)); AddShortcut('O', 0, new BMessage(kOpenSelection)); AddShortcut('U', 0, new BMessage(kUnmountVolume)); AddShortcut('P', 0, new BMessage(kPermissionsSelected)); @@ -433,7 +431,8 @@ BInfoWindow::MessageReceived(BMessage *message) case kEditItem: { BEntry entry(fModel->EntryRef()); - if (ConfirmChangeIfWellKnownDirectory(&entry, + if (!fModel->HasLocalizedName() + && ConfirmChangeIfWellKnownDirectory(&entry, B_TRANSLATE_COMMENT("rename", "As in 'If you rename ...'"), B_TRANSLATE_COMMENT("rename", "As in 'To rename ...'"))) fAttributeView->BeginEditingTitle(); @@ -1222,9 +1221,7 @@ AttributeView::MouseDown(BPoint point) InvertRect(fPathRect); fTrackingState = path_track; } else if (fTitleRect.Contains(point)) { - // You can't change the name of the trash - if (!fModel->IsTrash() - && !fModel->HasLocalizedName() + if (!fModel->HasLocalizedName() && ConfirmChangeIfWellKnownDirectory(&entry, B_TRANSLATE_COMMENT("rename", "As in 'If you rename ...'"), B_TRANSLATE_COMMENT("rename", "As in 'To rename ...'"), true) @@ -2039,12 +2036,12 @@ AttributeView::BuildContextMenu(BMenu *parent) parent->AddItem(new BMenuItem(B_TRANSLATE("Open"), new BMessage(kOpenSelection), 'O')); - if (!model.IsTrash()) { - if (!fModel->HasLocalizedName()) { - parent->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), - new BMessage(kEditItem), 'E')); - parent->AddSeparatorItem(); - } + if (!model.IsDesktop() && !model.IsRoot() && !model.IsTrash() + && !fModel->HasLocalizedName()) { + parent->AddItem(new BMenuItem(B_TRANSLATE("Edit name"), + new BMessage(kEditItem), 'E')); + parent->AddSeparatorItem(); + if (fModel->IsVolume()) { BMenuItem* item = new BMenuItem(B_TRANSLATE("Unmount"), new BMessage(kUnmountVolume), 'U'); @@ -2056,14 +2053,16 @@ AttributeView::BuildContextMenu(BMenu *parent) volume.SetTo(fModel->NodeRef()->device); if (volume == boot) item->SetEnabled(false); - } else { - parent->AddItem(new BMenuItem(B_TRANSLATE("Identify"), - new BMessage(kIdentifyEntry))); } - } else { + } + + if (!model.IsRoot() && !model.IsVolume() && !model.IsTrash()) + parent->AddItem(new BMenuItem(B_TRANSLATE("Identify"), + new BMessage(kIdentifyEntry))); + + if (model.IsTrash()) parent->AddItem(new BMenuItem(B_TRANSLATE("Empty Trash"), new BMessage(kEmptyTrash))); - } BMenuItem *sizeItem = NULL; if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) { diff --git a/src/kits/tracker/TextWidget.cpp b/src/kits/tracker/TextWidget.cpp index 9a1f327017..f60e966e97 100644 --- a/src/kits/tracker/TextWidget.cpp +++ b/src/kits/tracker/TextWidget.cpp @@ -321,12 +321,7 @@ BTextWidget::StartEdit(BRect bounds, BPoseView *view, BPose *pose) if (!IsEditable()) return; - // don't allow editing of the trash directory name - if (pose->TargetModel()->IsTrash()) - return; - - // don't allow editing of the "Disks" icon name - if (pose->TargetModel()->IsRoot()) + if (pose->TargetModel()->HasLocalizedName()) return; BEntry entry(pose->TargetModel()->EntryRef());