MainWindow::_UpdateMenus():

* Don't fall back to the disk device, if no partition was selected. No idea why
  that was done. It led to operations (like initialize) being enabled that
  would fail, if invoked.
* Don't check CanInitialize() on the selected partition with its current disk
  system to determine whether to enable the initialization menu. No idea why
  that was done either. It led to the menu being disabled, when there was no
  reason for it.
* Also disable the initialization menu when no partition is selected.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42135 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2011-06-13 00:00:20 +00:00
parent 5e78920c12
commit 6436e4676f

View File

@ -534,8 +534,10 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
// Create menu and items
BPartition* parentPartition = NULL;
if (selectedPartition <= -2)
if (selectedPartition <= -2) {
// a partitionable space item is selected
parentPartition = disk->FindDescendant(parentID);
}
if (parentPartition && parentPartition->ContainsPartitioningSystem())
fCreateMI->SetEnabled(true);
@ -545,8 +547,6 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
fDeleteMI->SetEnabled(prepared);
BPartition* partition = disk->FindDescendant(selectedPartition);
if (partition == NULL)
partition = disk;
BDiskSystem diskSystem;
fDDRoster.RewindDiskSystems();
@ -569,20 +569,17 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
BMenuItem* item = new BMenuItem(label.String(), message);
// TODO: Very unintuitive that we have to use the pretty name here!
// item->SetEnabled(partition->CanInitialize(diskSystem.Name()));
item->SetEnabled(partition->CanInitialize(diskSystem.PrettyName()));
item->SetEnabled(partition != NULL
// && partition->CanInitialize(diskSystem.Name()));
&& partition->CanInitialize(diskSystem.PrettyName()));
fInitMenu->AddItem(item);
}
// Mount items
if (partition) {
BDiskSystem partitionDiskSystem;
partition->GetDiskSystem(&partitionDiskSystem);
fInitMenu->SetEnabled(!partition->IsMounted()
&& !partition->IsReadOnly()
&& partition->Device()->HasMedia()
// Check if the current disk system allows initialzation.
&& partition->CanInitialize(partitionDiskSystem.PrettyName()));
&& partition->Device()->HasMedia());
fDeleteMI->SetEnabled(!partition->IsMounted()
&& !partition->IsDevice());
@ -604,6 +601,7 @@ MainWindow::_UpdateMenus(BDiskDevice* disk,
} else {
fDeleteMI->SetEnabled(false);
fMountMI->SetEnabled(false);
fInitMenu->SetEnabled(false);
}
if (prepared)