예제 #1
0
파일: menu.cpp 프로젝트: mmanley/Antares
static Menu *
add_boot_volume_menu(Directory *bootVolume)
{
    Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Boot Volume");
    MenuItem *item;
    void *cookie;
    int32 count = 0;

    if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
        Directory *volume;
        while (gRoot->GetNextNode(cookie, (Node **)&volume) == B_OK) {
            // only list bootable volumes
            if (!is_bootable(volume))
                continue;

            char name[B_FILE_NAME_LENGTH];
            if (volume->GetName(name, sizeof(name)) == B_OK) {
                menu->AddItem(item = new(nothrow) MenuItem(name));
                item->SetTarget(user_menu_boot_volume);
                item->SetData(volume);

                if (volume == bootVolume) {
                    item->SetMarked(true);
                    item->Select(true);
                }

                count++;
            }
        }
        gRoot->Close(cookie);
    }

    if (count == 0) {
        // no boot volume found yet
        menu->AddItem(item = new(nothrow) MenuItem("<No boot volume found>"));
        item->SetType(MENU_ITEM_NO_CHOICE);
        item->SetEnabled(false);
    }

    menu->AddSeparatorItem();

    menu->AddItem(item = new(nothrow) MenuItem("Rescan volumes"));
    item->SetHelpText("Please insert a Antares CD-ROM or attach a USB disk - "
                      "depending on your system, you can then boot from them.");
    item->SetType(MENU_ITEM_NO_CHOICE);
    if (count == 0)
        item->Select(true);

    menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
    item->SetType(MENU_ITEM_NO_CHOICE);

    if (gKernelArgs.boot_volume.GetBool(BOOT_VOLUME_BOOTED_FROM_IMAGE, false))
        menu->SetChoiceText("CD-ROM or hard drive");

    return menu;
}
예제 #2
0
static bool
user_menu_boot_volume_state(Menu* menu, MenuItem* _item)
{
	MenuItem* bootItem = get_continue_booting_menu_item();
	if (bootItem == NULL) {
		// huh?
		return true;
	}

	PackageVolumeStateMenuItem* item = static_cast<PackageVolumeStateMenuItem*>(
		_item);
	if (sBootVolume->IsValid() && sBootVolume->GetPackageVolumeState() != NULL
			&& sBootVolume->GetPackageVolumeState() == item->VolumeState()) {
		return true;
	}

	BootVolumeMenuItem* volumeItem = static_cast<BootVolumeMenuItem*>(
		item->Supermenu()->Superitem());
	volumeItem->SetMarked(true);
	volumeItem->Select(true);
	volumeItem->UpdateStateName(item->VolumeState());

	sPathBlacklist->MakeEmpty();

	bool valid = sBootVolume->SetTo((Directory*)item->Data(),
		item->VolumeInfo(), item->VolumeState()) == B_OK;

	bootItem->SetEnabled(valid);
	if (valid)
		bootItem->Select(true);

	gBootVolume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
	return true;
}
예제 #3
0
파일: menu.cpp 프로젝트: mmanley/Antares
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;
}
예제 #4
0
파일: menu.cpp 프로젝트: mmanley/Antares
void
MenuItem::Select(bool selected)
{
    if (fIsSelected == selected)
        return;

    if (selected && fMenu != NULL) {
        // unselect previous item
        MenuItem *selectedItem = fMenu->FindSelected();
        if (selectedItem != NULL)
            selectedItem->Select(false);
    }

    fIsSelected = selected;

    if (fMenu != NULL)
        fMenu->Draw(this);
}
예제 #5
0
파일: video.cpp 프로젝트: mylegacy/haiku
Menu *
video_mode_menu()
{
	Menu *menu = new(nothrow) Menu(CHOICE_MENU, "Select Video Mode");
	MenuItem *item;

	menu->AddItem(item = new(nothrow) MenuItem("Default"));
	item->SetMarked(true);
	item->Select(true);
	item->SetHelpText("The Default video mode is the one currently configured "
		"in the system. If there is no mode configured yet, a viable mode will "
		"be chosen automatically.");


	menu->AddSeparatorItem();
	menu->AddItem(item = new(nothrow) MenuItem("Return to main menu"));
	item->SetType(MENU_ITEM_NO_CHOICE);

	return menu;
}
예제 #6
0
static bool
user_menu_boot_volume(Menu* menu, MenuItem* item)
{
	MenuItem* bootItem = get_continue_booting_menu_item();
	if (bootItem == NULL) {
		// huh?
		return true;
	}

	if (sBootVolume->IsValid() && sBootVolume->RootDirectory() == item->Data())
		return true;

	sPathBlacklist->MakeEmpty();

	bool valid = sBootVolume->SetTo((Directory*)item->Data()) == B_OK;

	bootItem->SetEnabled(valid);
	if (valid)
		bootItem->Select(true);

	gBootVolume.SetBool(BOOT_VOLUME_USER_SELECTED, true);
	return true;
}