Ticket #9512: 0001-Tracker-Show-alert-when-emptying-trash.patch

File 0001-Tracker-Show-alert-when-emptying-trash.patch, 1.7 KB (added by return_0e, 7 years ago)

Patch to warn user whilst emptying trash.

  • src/kits/tracker/FSUtils.cpp

    From 4bc2ef979a039ec7f6b0cefe23eb6bb787f98101 Mon Sep 17 00:00:00 2001
    From: "Joseph C, Hill" <mr_j.c.h@hotmail.com>
    Date: Sat, 4 Mar 2017 17:22:06 +0000
    Subject: [PATCH] Tracker: Show alert when emptying trash.
    
    By default, Tracker empties the trash without warning.
    This patch adds an alert to ask the user if they are
    sure or not.
    ---
     src/kits/tracker/FSUtils.cpp | 18 +++++++++++++++---
     1 file changed, 15 insertions(+), 3 deletions(-)
    
    diff --git a/src/kits/tracker/FSUtils.cpp b/src/kits/tracker/FSUtils.cpp
    index 5399efc..43d28d4 100644
    a b static const char* kDeleteConfirmationStr =  
    150150    B_TRANSLATE_MARK("Are you sure you want to delete the "
    151151    "selected item(s)? This operation cannot be reverted.");
    152152
     153static const char* kEmptyTrashConfirmationStr =
     154    B_TRANSLATE_MARK("Are you sure you want to permanently delete "
     155    "all items in the trash? This operation cannot be reverted.");
     156
    153157static const char* kReplaceStr =
    154158    B_TRANSLATE_MARK("You are trying to replace the item:\n"
    155159    "\t%name%dest\n"
    FSInTrashDir(const entry_ref* ref)  
    28302834void
    28312835FSEmptyTrash()
    28322836{
    2833     if (find_thread("_tracker_empty_trash_") != B_OK) {
    2834         resume_thread(spawn_thread(empty_trash, "_tracker_empty_trash_",
    2835             B_NORMAL_PRIORITY, NULL));
     2837    BAlert* alert = new BAlert("", kEmptyTrashConfirmationStr,
     2838            B_TRANSLATE("Cancel"), B_TRANSLATE("Proceed"), 0,
     2839            B_WIDTH_AS_USUAL, B_WARNING_ALERT);
     2840
     2841    switch (alert->Go()) {
     2842        case 1:
     2843            if (find_thread("_tracker_empty_trash_") != B_OK) {
     2844            resume_thread(spawn_thread(empty_trash, "_tracker_empty_trash_",
     2845                B_NORMAL_PRIORITY, NULL));
     2846            }
     2847            break;
    28362848    }
    28372849}
    28382850