static void add_boot_volume_item(Menu* menu, Directory* volume, const char* name) { BReference<PackageVolumeInfo> volumeInfo; PackageVolumeState* selectedState = NULL; if (volume == sBootVolume->RootDirectory()) { volumeInfo.SetTo(sBootVolume->GetPackageVolumeInfo()); selectedState = sBootVolume->GetPackageVolumeState(); } else { volumeInfo.SetTo(new(std::nothrow) PackageVolumeInfo); if (volumeInfo->SetTo(volume, "system/packages") == B_OK) selectedState = volumeInfo->States().Head(); else volumeInfo.Unset(); } BootVolumeMenuItem* item = new(nothrow) BootVolumeMenuItem(name); menu->AddItem(item); Menu* subMenu = NULL; if (volumeInfo != NULL) { subMenu = new(std::nothrow) Menu(CHOICE_MENU, "Select Haiku version"); for (PackageVolumeStateList::ConstIterator it = volumeInfo->States().GetIterator(); PackageVolumeState* state = it.Next();) { PackageVolumeStateMenuItem* stateItem = new(nothrow) PackageVolumeStateMenuItem(state->DisplayName(), volumeInfo, state); subMenu->AddItem(stateItem); stateItem->SetTarget(user_menu_boot_volume_state); stateItem->SetData(volume); if (state == selectedState) { stateItem->SetMarked(true); stateItem->Select(true); item->UpdateStateName(stateItem->VolumeState()); } } } if (subMenu != NULL && subMenu->CountItems() > 1) { item->SetSubmenu(subMenu); } else { delete subMenu; item->SetTarget(user_menu_boot_volume); item->SetData(volume); } if (volume == sBootVolume->RootDirectory()) { item->SetMarked(true); item->Select(true); } }
static bool user_menu_boot_volume(Menu *menu, MenuItem *item) { Menu *super = menu->Supermenu(); if (super == NULL) { // huh? return true; } MenuItem *bootItem = super->ItemAt(super->CountItems() - 1); bootItem->SetEnabled(true); bootItem->Select(true); bootItem->SetData(item->Data()); gKernelArgs.boot_volume.SetBool(BOOT_VOLUME_USER_SELECTED, true); return true; }