[haiku-commits] r41131 - haiku/trunk/src/kits/tracker

  • From: jonas@xxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 28 Mar 2011 08:44:46 +0200 (CEST)

Author: kirilla
Date: 2011-03-28 08:44:46 +0200 (Mon, 28 Mar 2011)
New Revision: 41131
Changeset: https://dev.haiku-os.org/changeset/41131

Modified:
   haiku/trunk/src/kits/tracker/FSUtils.cpp
   haiku/trunk/src/kits/tracker/FSUtils.h
   haiku/trunk/src/kits/tracker/InfoWindow.cpp
   haiku/trunk/src/kits/tracker/TextWidget.cpp
Log:
Have ConfirmChangeIfWellKnownDirectory() protect the folders Common, Desktop, 
Root and Trash from renames and moves. Shift-key dialog protection added for 
the Home folder. Attempts on Desktop, Root and Trash are blocked silently. I 
admitt it's a bit odd to protect these so resolutely, unlike system, common and 
home, which are truly essential to the system. Would it be patronizing to 
enforce a stricter regime?

Modified: haiku/trunk/src/kits/tracker/FSUtils.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FSUtils.cpp    2011-03-28 02:23:07 UTC (rev 
41130)
+++ haiku/trunk/src/kits/tracker/FSUtils.cpp    2011-03-28 06:44:46 UTC (rev 
41131)
@@ -623,7 +623,11 @@
        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 @@
        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)) {
 
@@ -2598,6 +2608,14 @@
 
 
 bool
+FSIsRootDir(const BEntry *entry)
+{
+       BPath path(entry);
+       return path == "/";
+}
+
+
+bool
 DirectoryMatchesOrContains(const BEntry *entry, directory_which which)
 {
        BPath path;

Modified: haiku/trunk/src/kits/tracker/FSUtils.h
===================================================================
--- haiku/trunk/src/kits/tracker/FSUtils.h      2011-03-28 02:23:07 UTC (rev 
41130)
+++ haiku/trunk/src/kits/tracker/FSUtils.h      2011-03-28 06:44:46 UTC (rev 
41131)
@@ -172,6 +172,7 @@
 _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<entry_ref> *srcList, BList 
*pointList = NULL,
        bool async = true);
        // Deprecated

Modified: haiku/trunk/src/kits/tracker/InfoWindow.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/InfoWindow.cpp 2011-03-28 02:23:07 UTC (rev 
41130)
+++ haiku/trunk/src/kits/tracker/InfoWindow.cpp 2011-03-28 06:44:46 UTC (rev 
41131)
@@ -299,9 +299,7 @@
        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 @@
                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 @@
                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 @@
        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 @@
                        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())  {

Modified: haiku/trunk/src/kits/tracker/TextWidget.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/TextWidget.cpp 2011-03-28 02:23:07 UTC (rev 
41130)
+++ haiku/trunk/src/kits/tracker/TextWidget.cpp 2011-03-28 06:44:46 UTC (rev 
41131)
@@ -321,14 +321,9 @@
        if (!IsEditable())
                return;
 
-       // don't allow editing of the trash directory name
-       if (pose->TargetModel()->IsTrash())
+       if (pose->TargetModel()->HasLocalizedName())
                return;
 
-       // don't allow editing of the "Disks" icon name
-       if (pose->TargetModel()->IsRoot())
-               return;
-
        BEntry entry(pose->TargetModel()->EntryRef());
        if (entry.InitCheck() == B_OK
                && !ConfirmChangeIfWellKnownDirectory(&entry,


Other related posts:

  • » [haiku-commits] r41131 - haiku/trunk/src/kits/tracker - jonas