diff --git a/src/kits/tracker/Commands.h b/src/kits/tracker/Commands.h
index c2e19d3..d16b401 100644
a
|
b
|
const uint32 kShowVolumeSpaceBar = 'ShSB';
|
140 | 140 | const uint32 kSpaceBarColorChanged = 'SBcc'; |
141 | 141 | |
142 | 142 | const uint32 kDontMoveFilesToTrashChanged = 'STdm'; |
| 143 | const uint32 kAskBeforeTrashFileChanged = 'STat'; |
143 | 144 | const uint32 kAskBeforeDeleteFileChanged = 'STad'; |
144 | 145 | |
145 | 146 | } // namespace BPrivate |
diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp
index f85df2d..f487c03 100644
a
|
b
|
static const char* kDeleteConfirmationStr =
|
141 | 141 | B_TRANSLATE_MARK("Are you sure you want to delete the " |
142 | 142 | "selected item(s)? This operation cannot be reverted."); |
143 | 143 | |
| 144 | static const char* kTrashConfirmationStr = |
| 145 | B_TRANSLATE_MARK("Are you sure you want to move the " |
| 146 | "selected item(s) to the trash?"); |
| 147 | |
144 | 148 | static const char* kReplaceStr = |
145 | 149 | B_TRANSLATE_MARK("You are trying to replace the item:\n" |
146 | 150 | "\t%name%dest\n" |
… |
… |
FSRestoreRefList(BObjectList<entry_ref> *list, bool async)
|
573 | 577 | |
574 | 578 | |
575 | 579 | void |
576 | | FSMoveToTrash(BObjectList<entry_ref> *srcList, BList *pointList, bool async) |
| 580 | FSMoveToTrash(BObjectList<entry_ref> *srcList, BList *pointList, bool async, |
| 581 | bool confirm) |
577 | 582 | { |
578 | 583 | if (srcList->IsEmpty()) { |
579 | 584 | delete srcList; |
580 | 585 | delete pointList; |
581 | 586 | return; |
582 | 587 | } |
| 588 | |
| 589 | if (confirm && TrackerSettings().AskBeforeTrashFile()) { |
| 590 | BAlert* alert = new BAlert("", |
| 591 | B_TRANSLATE_NOCOLLECT(kTrashConfirmationStr), |
| 592 | B_TRANSLATE("Cancel"), B_TRANSLATE("Move to Trash"), NULL, |
| 593 | B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); |
| 594 | alert->SetShortcut(0, B_ESCAPE); |
| 595 | alert->SetShortcut(1, 'm'); |
| 596 | |
| 597 | if (!alert->Go()) |
| 598 | return; |
| 599 | } |
583 | 600 | |
584 | 601 | if (async) |
585 | 602 | LaunchInNewThread("MoveTask", B_NORMAL_PRIORITY, MoveTask, srcList, |
… |
… |
FSInTrashDir(const entry_ref *ref)
|
2738 | 2755 | void |
2739 | 2756 | FSEmptyTrash() |
2740 | 2757 | { |
| 2758 | if (TrackerSettings().AskBeforeDeleteFile()) { |
| 2759 | BAlert* alert = new BAlert("", |
| 2760 | B_TRANSLATE_NOCOLLECT(kDeleteConfirmationStr), |
| 2761 | B_TRANSLATE("Cancel"), B_TRANSLATE("Delete"), NULL, |
| 2762 | B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); |
| 2763 | |
| 2764 | alert->SetShortcut(0, B_ESCAPE); |
| 2765 | alert->SetShortcut(1, 'd'); |
| 2766 | |
| 2767 | if (!alert->Go()) |
| 2768 | return; |
| 2769 | } |
| 2770 | |
2741 | 2771 | if (find_thread("_tracker_empty_trash_") != B_OK) { |
2742 | 2772 | resume_thread(spawn_thread(empty_trash, "_tracker_empty_trash_", |
2743 | 2773 | B_NORMAL_PRIORITY, NULL)); |
… |
… |
_DeleteTask(BObjectList<entry_ref> *list, bool confirm)
|
2835 | 2865 | delete list; |
2836 | 2866 | return B_OK; |
2837 | 2867 | case 1: |
2838 | | FSMoveToTrash(list, NULL, false); |
| 2868 | FSMoveToTrash(list, NULL, false, false); |
2839 | 2869 | return B_OK; |
2840 | 2870 | } |
2841 | 2871 | } else { |
diff --git a/src/kits/tracker/FSUtils.h b/src/kits/tracker/FSUtils.h
index d033e0b..ca741c1 100644
a
|
b
|
_IMPEXP_TRACKER bool FSIsDeskDir(const BEntry *);
|
174 | 174 | _IMPEXP_TRACKER bool FSIsHomeDir(const BEntry *); |
175 | 175 | _IMPEXP_TRACKER bool FSIsRootDir(const BEntry *); |
176 | 176 | _IMPEXP_TRACKER void FSMoveToTrash(BObjectList<entry_ref> *srcList, BList *pointList = NULL, |
177 | | bool async = true); |
| 177 | bool async = true, bool confirm = true); |
178 | 178 | // Deprecated |
179 | 179 | |
180 | 180 | void FSDeleteRefList(BObjectList<entry_ref> *, bool, bool confirm = true); |
diff --git a/src/kits/tracker/FunctionObject.h b/src/kits/tracker/FunctionObject.h
index bcd8f6e..ea78c2d 100644
a
|
b
|
NewFunctionObject(void (*function)(Param1, Param2, Param3),
|
514 | 514 | } |
515 | 515 | |
516 | 516 | |
| 517 | template<class Param1, class Param2, class Param3, class Param4> |
| 518 | FourParamFunctionObject<Param1, Param2, Param3, Param4> * |
| 519 | NewFunctionObject(void (*function)(Param1, Param2, Param3, Param4), |
| 520 | Param1 p1, Param2 p2, Param3 p3, Param4 p4) |
| 521 | { |
| 522 | return new FourParamFunctionObject<Param1, Param2, Param3, Param4>(function, p1, p2, p3, p4); |
| 523 | } |
| 524 | |
| 525 | |
517 | 526 | template<class T> |
518 | 527 | PlainMemberFunctionObject<T> * |
519 | 528 | NewMemberFunctionObject(void (T::*function)(), T *onThis) |
diff --git a/src/kits/tracker/PoseView.cpp b/src/kits/tracker/PoseView.cpp
index 6d5d92e..8fab7e6 100644
a
|
b
|
BPoseView::MoveListToTrash(BObjectList<entry_ref> *list, bool selectNext,
|
5605 | 5605 | taskList->AddItem(NewFunctionObject(FSDeleteRefList, list, false, true)); |
5606 | 5606 | else |
5607 | 5607 | taskList->AddItem(NewFunctionObject(FSMoveToTrash, list, |
5608 | | (BList *)NULL, false)); |
| 5608 | (BList *)NULL, false, true)); |
5609 | 5609 | |
5610 | 5610 | if (selectNext && ViewMode() == kListMode) { |
5611 | 5611 | // next, if in list view mode try selecting the next item after |
diff --git a/src/kits/tracker/SettingsViews.cpp b/src/kits/tracker/SettingsViews.cpp
index ce2ba4d..e0ad923 100644
a
|
b
|
TrashSettingsView::TrashSettingsView()
|
942 | 942 | B_TRANSLATE("Don't move files to Trash"), |
943 | 943 | new BMessage(kDontMoveFilesToTrashChanged)); |
944 | 944 | |
| 945 | fAskBeforeTrashFileCheckBox = new BCheckBox("", |
| 946 | B_TRANSLATE("Ask before moving files into trash"), |
| 947 | new BMessage(kAskBeforeTrashFileChanged)); |
| 948 | |
945 | 949 | fAskBeforeDeleteFileCheckBox = new BCheckBox("", |
946 | | B_TRANSLATE("Ask before delete"), |
| 950 | B_TRANSLATE("Ask before deleting files permanently"), |
947 | 951 | new BMessage(kAskBeforeDeleteFileChanged)); |
948 | 952 | |
949 | 953 | const float spacing = be_control_look->DefaultItemSpacing(); |
… |
… |
TrashSettingsView::TrashSettingsView()
|
953 | 957 | layout->SetSpacing(0); |
954 | 958 | BGroupLayoutBuilder(layout) |
955 | 959 | .Add(fDontMoveFilesToTrashCheckBox) |
| 960 | .Add(fAskBeforeTrashFileCheckBox) |
956 | 961 | .Add(fAskBeforeDeleteFileCheckBox) |
957 | 962 | .AddGlue() |
958 | 963 | .SetInsets(spacing, spacing, spacing, spacing); |
… |
… |
void
|
964 | 969 | TrashSettingsView::AttachedToWindow() |
965 | 970 | { |
966 | 971 | fDontMoveFilesToTrashCheckBox->SetTarget(this); |
| 972 | fAskBeforeTrashFileCheckBox->SetTarget(this); |
967 | 973 | fAskBeforeDeleteFileCheckBox->SetTarget(this); |
968 | 974 | } |
969 | 975 | |
… |
… |
TrashSettingsView::MessageReceived(BMessage *message)
|
984 | 990 | Window()->PostMessage(kSettingsContentsModified); |
985 | 991 | break; |
986 | 992 | |
| 993 | case kAskBeforeTrashFileChanged: |
| 994 | settings.SetAskBeforeTrashFile(fAskBeforeTrashFileCheckBox->Value() == 1); |
| 995 | |
| 996 | tracker->SendNotices(kAskBeforeTrashFileChanged); |
| 997 | Window()->PostMessage(kSettingsContentsModified); |
| 998 | break; |
| 999 | |
987 | 1000 | case kAskBeforeDeleteFileChanged: |
988 | 1001 | settings.SetAskBeforeDeleteFile(fAskBeforeDeleteFileCheckBox->Value() == 1); |
989 | 1002 | |
… |
… |
TrashSettingsView::IsDefaultable() const
|
1017 | 1030 | TrackerSettings settings; |
1018 | 1031 | |
1019 | 1032 | return settings.DontMoveFilesToTrash() != false |
| 1033 | || settings.AskBeforeTrashFile() != true |
1020 | 1034 | || settings.AskBeforeDeleteFile() != true; |
1021 | 1035 | } |
1022 | 1036 | |
… |
… |
TrashSettingsView::Revert()
|
1027 | 1041 | TrackerSettings settings; |
1028 | 1042 | |
1029 | 1043 | settings.SetDontMoveFilesToTrash(fDontMoveFilesToTrash); |
| 1044 | settings.SetAskBeforeTrashFile(fAskBeforeTrashFile); |
1030 | 1045 | settings.SetAskBeforeDeleteFile(fAskBeforeDeleteFile); |
1031 | 1046 | |
1032 | 1047 | ShowCurrentSettings(); |
… |
… |
TrashSettingsView::_SendNotices()
|
1042 | 1057 | return; |
1043 | 1058 | |
1044 | 1059 | tracker->SendNotices(kDontMoveFilesToTrashChanged); |
| 1060 | tracker->SendNotices(kAskBeforeTrashFileChanged); |
1045 | 1061 | tracker->SendNotices(kAskBeforeDeleteFileChanged); |
1046 | 1062 | } |
1047 | 1063 | |
… |
… |
TrashSettingsView::ShowCurrentSettings()
|
1052 | 1068 | TrackerSettings settings; |
1053 | 1069 | |
1054 | 1070 | fDontMoveFilesToTrashCheckBox->SetValue(settings.DontMoveFilesToTrash()); |
| 1071 | fAskBeforeTrashFileCheckBox->SetValue(settings.AskBeforeTrashFile()); |
1055 | 1072 | fAskBeforeDeleteFileCheckBox->SetValue(settings.AskBeforeDeleteFile()); |
1056 | 1073 | } |
1057 | 1074 | |
… |
… |
TrashSettingsView::RecordRevertSettings()
|
1062 | 1079 | TrackerSettings settings; |
1063 | 1080 | |
1064 | 1081 | fDontMoveFilesToTrash = settings.DontMoveFilesToTrash(); |
| 1082 | fAskBeforeTrashFile = settings.AskBeforeTrashFile(); |
1065 | 1083 | fAskBeforeDeleteFile = settings.AskBeforeDeleteFile(); |
1066 | 1084 | } |
1067 | 1085 | |
… |
… |
bool
|
1070 | 1088 | TrashSettingsView::IsRevertable() const |
1071 | 1089 | { |
1072 | 1090 | return fDontMoveFilesToTrash != (fDontMoveFilesToTrashCheckBox->Value() > 0) |
| 1091 | || fAskBeforeTrashFile != (fAskBeforeTrashFileCheckBox->Value() > 0) |
1073 | 1092 | || fAskBeforeDeleteFile != (fAskBeforeDeleteFileCheckBox->Value() > 0); |
1074 | 1093 | } |
1075 | 1094 | |
diff --git a/src/kits/tracker/SettingsViews.h b/src/kits/tracker/SettingsViews.h
index 89299ab..ac6e291 100644
a
|
b
|
class TrashSettingsView : public SettingsView {
|
180 | 180 | void _SendNotices(); |
181 | 181 | |
182 | 182 | BCheckBox *fDontMoveFilesToTrashCheckBox; |
| 183 | BCheckBox *fAskBeforeTrashFileCheckBox; |
183 | 184 | BCheckBox *fAskBeforeDeleteFileCheckBox; |
184 | 185 | |
185 | 186 | bool fDontMoveFilesToTrash; |
| 187 | bool fAskBeforeTrashFile; |
186 | 188 | bool fAskBeforeDeleteFile; |
187 | 189 | |
188 | 190 | typedef SettingsView _inherited; |
diff --git a/src/kits/tracker/TrackerSettings.cpp b/src/kits/tracker/TrackerSettings.cpp
index b63ca2e..d57fc46 100644
a
|
b
|
class TTrackerState : public Settings {
|
82 | 82 | HexScalarValueSetting *fWarningSpaceColor; |
83 | 83 | |
84 | 84 | BooleanValueSetting *fDontMoveFilesToTrash; |
| 85 | BooleanValueSetting *fAskBeforeTrashFile; |
85 | 86 | BooleanValueSetting *fAskBeforeDeleteFile; |
86 | 87 | |
87 | 88 | Benaphore fInitLock; |
… |
… |
TTrackerState::LoadSettingsIfNeeded()
|
186 | 187 | Add(fWarningSpaceColor = new HexScalarValueSetting("WarningSpaceColor", 0xc0cb0000, "", "")); |
187 | 188 | |
188 | 189 | Add(fDontMoveFilesToTrash = new BooleanValueSetting("DontMoveFilesToTrash", false)); |
| 190 | Add(fAskBeforeTrashFile = new BooleanValueSetting("AskBeforeTrashFile", true)); |
189 | 191 | Add(fAskBeforeDeleteFile = new BooleanValueSetting("AskBeforeDeleteFile", true)); |
190 | 192 | |
191 | 193 | TryReadingSettings(); |
… |
… |
TrackerSettings::SetAskBeforeDeleteFile(bool enabled)
|
514 | 516 | gTrackerState.fAskBeforeDeleteFile->SetValue(enabled); |
515 | 517 | } |
516 | 518 | |
| 519 | |
| 520 | bool |
| 521 | TrackerSettings::AskBeforeTrashFile() |
| 522 | { |
| 523 | return gTrackerState.fAskBeforeTrashFile->Value(); |
| 524 | } |
| 525 | |
| 526 | |
| 527 | void |
| 528 | TrackerSettings::SetAskBeforeTrashFile(bool enabled) |
| 529 | { |
| 530 | gTrackerState.fAskBeforeTrashFile->SetValue(enabled); |
| 531 | } |
| 532 | |
diff --git a/src/kits/tracker/TrackerSettings.h b/src/kits/tracker/TrackerSettings.h
index ed8ae46..309bfeb 100644
a
|
b
|
class TrackerSettings {
|
121 | 121 | |
122 | 122 | bool DontMoveFilesToTrash(); |
123 | 123 | void SetDontMoveFilesToTrash(bool); |
| 124 | bool AskBeforeTrashFile(); |
| 125 | void SetAskBeforeTrashFile(bool); |
124 | 126 | bool AskBeforeDeleteFile(); |
125 | 127 | void SetAskBeforeDeleteFile(bool); |
126 | 128 | |