* Maintain the previously selected partition when rescanning drives (ie also
when mounting/unmounting a partition). * Set the enabled state of the Unmount menu item when a partition is not mounted (was using previous state from last partition). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24034 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -146,6 +146,7 @@ MainWindow::MainWindow(BRect frame)
|
|||||||
: BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW,
|
: BWindow(frame, "DriveSetup", B_DOCUMENT_WINDOW,
|
||||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||||
, fCurrentDisk(NULL)
|
, fCurrentDisk(NULL)
|
||||||
|
, fCurrentPartitionID(-1)
|
||||||
, fSpaceIDMap()
|
, fSpaceIDMap()
|
||||||
{
|
{
|
||||||
BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu");
|
BMenuBar* menuBar = new BMenuBar(Bounds(), "root menu");
|
||||||
@@ -179,7 +180,7 @@ fDeleteMI->SetEnabled(false);
|
|||||||
|
|
||||||
// Parition menu
|
// Parition menu
|
||||||
fPartitionMenu = new BMenu("Partition");
|
fPartitionMenu = new BMenu("Partition");
|
||||||
fCreateMenu = new BMenu("Create");
|
fCreateMenu = new BMenu("Create (not implemented)");
|
||||||
fPartitionMenu->AddItem(fCreateMenu);
|
fPartitionMenu->AddItem(fCreateMenu);
|
||||||
|
|
||||||
fInitMenu = new BMenu("Initialize");
|
fInitMenu = new BMenu("Initialize");
|
||||||
@@ -224,8 +225,6 @@ fDeleteMI->SetEnabled(false);
|
|||||||
|
|
||||||
// visit all disks in the system and show their contents
|
// visit all disks in the system and show their contents
|
||||||
_ScanDrives();
|
_ScanDrives();
|
||||||
|
|
||||||
_EnabledDisableMenuItems(NULL, -1, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -368,6 +367,17 @@ MainWindow::_ScanDrives()
|
|||||||
ListPopulatorVisitor driveVisitor(fListView, diskCount, fSpaceIDMap);
|
ListPopulatorVisitor driveVisitor(fListView, diskCount, fSpaceIDMap);
|
||||||
fDDRoster.VisitEachPartition(&driveVisitor);
|
fDDRoster.VisitEachPartition(&driveVisitor);
|
||||||
fDiskView->SetDiskCount(diskCount);
|
fDiskView->SetDiskCount(diskCount);
|
||||||
|
|
||||||
|
// restore selection
|
||||||
|
PartitionListRow* previousSelection
|
||||||
|
= fListView->FindRow(fCurrentPartitionID);
|
||||||
|
if (previousSelection) {
|
||||||
|
fListView->AddToSelection(previousSelection);
|
||||||
|
_EnabledDisableMenuItems(fCurrentDisk, fCurrentPartitionID,
|
||||||
|
previousSelection->ParentID());
|
||||||
|
} else {
|
||||||
|
_EnabledDisableMenuItems(NULL, -1, -1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -483,6 +493,7 @@ fSurfaceTestMI->SetEnabled(false);
|
|||||||
parentPartition = disk->FindDescendant(parentID);
|
parentPartition = disk->FindDescendant(parentID);
|
||||||
|
|
||||||
if (parentPartition) {
|
if (parentPartition) {
|
||||||
|
disk->PrepareModifications();
|
||||||
fCreateMenu->SetEnabled(true);
|
fCreateMenu->SetEnabled(true);
|
||||||
BString supportedChildType;
|
BString supportedChildType;
|
||||||
int32 cookie = 0;
|
int32 cookie = 0;
|
||||||
@@ -500,6 +511,7 @@ fSurfaceTestMI->SetEnabled(false);
|
|||||||
if (fCreateMenu->CountItems() == 0)
|
if (fCreateMenu->CountItems() == 0)
|
||||||
fprintf(stderr, "Failed to get supported child types: %s\n",
|
fprintf(stderr, "Failed to get supported child types: %s\n",
|
||||||
strerror(ret));
|
strerror(ret));
|
||||||
|
disk->CancelModifications();
|
||||||
} else {
|
} else {
|
||||||
fCreateMenu->SetEnabled(false);
|
fCreateMenu->SetEnabled(false);
|
||||||
}
|
}
|
||||||
@@ -512,17 +524,18 @@ fSurfaceTestMI->SetEnabled(false);
|
|||||||
fDeleteMI->SetEnabled(false);
|
fDeleteMI->SetEnabled(false);
|
||||||
fMountMI->SetEnabled(!partition->IsMounted());
|
fMountMI->SetEnabled(!partition->IsMounted());
|
||||||
|
|
||||||
|
bool unMountable = false;
|
||||||
if (partition->IsMounted()) {
|
if (partition->IsMounted()) {
|
||||||
// see if this partition is the boot volume
|
// see if this partition is the boot volume
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
BVolume bootVolume;
|
BVolume bootVolume;
|
||||||
if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK
|
if (BVolumeRoster().GetBootVolume(&bootVolume) == B_OK
|
||||||
&& partition->GetVolume(&volume) == B_OK) {
|
&& partition->GetVolume(&volume) == B_OK) {
|
||||||
fUnmountMI->SetEnabled(volume != bootVolume);
|
unMountable = volume != bootVolume;
|
||||||
} else {
|
} else
|
||||||
fUnmountMI->SetEnabled(true);
|
unMountable = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
fUnmountMI->SetEnabled(unMountable);
|
||||||
} else {
|
} else {
|
||||||
fInitMenu->SetEnabled(false);
|
fInitMenu->SetEnabled(false);
|
||||||
fDeleteMI->SetEnabled(false);
|
fDeleteMI->SetEnabled(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user