* Work in progress of being able to choose the drive to install the menu to.
Note, the BootManager might not work right now, anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40130 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,54 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
* Copyright 2011, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Michael Pfeiffer <[email protected]>
|
|
||||||
*/
|
*/
|
||||||
#ifndef BOOT_DRIVE_H
|
#ifndef BOOT_DRIVE_H
|
||||||
#define BOOT_DRIVE_H
|
#define BOOT_DRIVE_H
|
||||||
|
|
||||||
|
|
||||||
#include <File.h>
|
#include <File.h>
|
||||||
#include <Message.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Setting BMessage Format:
|
|
||||||
|
|
||||||
"disk" String (path to boot disk)
|
|
||||||
|
|
||||||
"partition" array of BMessage:
|
|
||||||
"show" bool (flag if entry should be added to boot menu)
|
|
||||||
"name" String (the name as shown in boot menu)
|
|
||||||
"type" String (short name of file system: bfs, dos)
|
|
||||||
"path" String (path to partition in /dev/...)
|
|
||||||
"size" long (size of partition in bytes)
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
enum {
|
|
||||||
// Not enough space free before first partition for boot loader
|
|
||||||
kErrorBootSectorTooSmall = B_ERRORS_END + 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class BootDrive {
|
class BootDrive {
|
||||||
public:
|
public:
|
||||||
BootDrive() {}
|
BootDrive();
|
||||||
virtual ~BootDrive() {}
|
virtual ~BootDrive();
|
||||||
|
|
||||||
virtual bool IsBootMenuInstalled(BMessage* settings) = 0;
|
bool IsBootMenuInstalled() const;
|
||||||
virtual status_t ReadPartitions(BMessage* settings) = 0;
|
bool CanBootMenuBeInstalled() const;
|
||||||
virtual status_t WriteBootMenu(BMessage* settings) = 0;
|
|
||||||
virtual status_t SaveMasterBootRecord(BMessage* settings,
|
|
||||||
BFile* file) = 0;
|
|
||||||
virtual status_t RestoreMasterBootRecord(BMessage* settings,
|
|
||||||
BFile* file) = 0;
|
|
||||||
|
|
||||||
// Converts the specified text into a text as it will be shown
|
bool IsBootDrive() const;
|
||||||
// in the boot menu.
|
|
||||||
virtual status_t GetDisplayText(const char* text,
|
status_t GetStream(BPositionIO* stream);
|
||||||
BString& displayText) = 0;
|
status_t GetBIOSDrive(uint8* drive);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BPath fPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
#include "DefaultPartitionPage.h"
|
#include "DefaultPartitionPage.h"
|
||||||
#include "DescriptionPage.h"
|
#include "DescriptionPage.h"
|
||||||
#include "EntryPage.h"
|
#include "DrivesPage.h"
|
||||||
#include "FileSelectionPage.h"
|
#include "FileSelectionPage.h"
|
||||||
#include "LegacyBootDrive.h"
|
#include "LegacyBootMenu.h"
|
||||||
#include "PartitionsPage.h"
|
#include "PartitionsPage.h"
|
||||||
#include "WizardView.h"
|
#include "WizardView.h"
|
||||||
|
|
||||||
@@ -41,9 +41,9 @@
|
|||||||
BootManagerController::BootManagerController()
|
BootManagerController::BootManagerController()
|
||||||
{
|
{
|
||||||
#if USE_TEST_BOOT_DRIVE
|
#if USE_TEST_BOOT_DRIVE
|
||||||
fBootDrive = new TestBootDrive();
|
fBootMenu = new TestBootDrive();
|
||||||
#else
|
#else
|
||||||
fBootDrive = new LegacyBootDrive();
|
fBootMenu = new LegacyBootMenu();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// set defaults
|
// set defaults
|
||||||
@@ -65,7 +65,7 @@ BootManagerController::BootManagerController()
|
|||||||
fSettings.AddString("file", "");
|
fSettings.AddString("file", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
fReadPartitionsStatus = fBootDrive->ReadPartitions(&fSettings);
|
fReadPartitionsStatus = fBootMenu->ReadPartitions(&fSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -74,6 +74,18 @@ BootManagerController::~BootManagerController()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
BootManagerController::Previous(WizardView* wizard)
|
||||||
|
{
|
||||||
|
if (CurrentState() != kStateEntry)
|
||||||
|
WizardController::Previous(wizard);
|
||||||
|
else {
|
||||||
|
WizardController::Next(wizard);
|
||||||
|
fSettings.ReplaceBool("install", false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int32
|
int32
|
||||||
BootManagerController::InitialState()
|
BootManagerController::InitialState()
|
||||||
{
|
{
|
||||||
@@ -89,10 +101,8 @@ BootManagerController::NextState(int32 state)
|
|||||||
switch (state) {
|
switch (state) {
|
||||||
case kStateEntry:
|
case kStateEntry:
|
||||||
{
|
{
|
||||||
bool install;
|
if (fSettings.FindBool("install")) {
|
||||||
fSettings.FindBool("install", &install);
|
if (fBootMenu->IsBootMenuInstalled(&fSettings))
|
||||||
if (install) {
|
|
||||||
if (fBootDrive->IsBootMenuInstalled(&fSettings))
|
|
||||||
return kStatePartitions;
|
return kStatePartitions;
|
||||||
|
|
||||||
return kStateSaveMBR;
|
return kStateSaveMBR;
|
||||||
@@ -176,7 +186,7 @@ BootManagerController::_WriteBootMenu()
|
|||||||
if (alert->Go() == 1)
|
if (alert->Go() == 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
fWriteBootMenuStatus = fBootDrive->WriteBootMenu(&fSettings);
|
fWriteBootMenuStatus = fBootMenu->WriteBootMenu(&fSettings);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +197,7 @@ BootManagerController::_SaveMBR()
|
|||||||
BString path;
|
BString path;
|
||||||
fSettings.FindString("file", &path);
|
fSettings.FindString("file", &path);
|
||||||
BFile file(path.String(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
BFile file(path.String(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE);
|
||||||
fSaveMBRStatus = fBootDrive->SaveMasterBootRecord(&fSettings, &file);
|
fSaveMBRStatus = fBootMenu->SaveMasterBootRecord(&fSettings, &file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,7 +225,7 @@ BootManagerController::_RestoreMBR()
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
BFile file(path.String(), B_READ_ONLY);
|
BFile file(path.String(), B_READ_ONLY);
|
||||||
fRestoreMBRStatus = fBootDrive->RestoreMasterBootRecord(&fSettings, &file);
|
fRestoreMBRStatus = fBootMenu->RestoreMasterBootRecord(&fSettings, &file);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,8 +238,7 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
|||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case kStateEntry:
|
case kStateEntry:
|
||||||
page = new EntryPage(&fSettings, "entry");
|
page = new DrivesPage(wizard, &fSettings, "drives");
|
||||||
wizard->SetPreviousButtonHidden(true);
|
|
||||||
break;
|
break;
|
||||||
case kStateErrorEntry:
|
case kStateErrorEntry:
|
||||||
page = _CreateErrorEntryPage();
|
page = _CreateErrorEntryPage();
|
||||||
@@ -252,7 +261,6 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
|||||||
break;
|
break;
|
||||||
case kStateInstallSummary:
|
case kStateInstallSummary:
|
||||||
page = _CreateInstallSummaryPage();
|
page = _CreateInstallSummaryPage();
|
||||||
wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Next", "Button"));
|
|
||||||
break;
|
break;
|
||||||
case kStateInstalled:
|
case kStateInstalled:
|
||||||
page = _CreateInstalledPage();
|
page = _CreateInstalledPage();
|
||||||
@@ -261,7 +269,6 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
|||||||
case kStateUninstall:
|
case kStateUninstall:
|
||||||
page = _CreateUninstallPage(frame);
|
page = _CreateUninstallPage(frame);
|
||||||
wizard->SetPreviousButtonHidden(false);
|
wizard->SetPreviousButtonHidden(false);
|
||||||
wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Next", "Button"));
|
|
||||||
break;
|
break;
|
||||||
case kStateUninstalled:
|
case kStateUninstalled:
|
||||||
// TODO prevent overwriting MBR after clicking "Previous"
|
// TODO prevent overwriting MBR after clicking "Previous"
|
||||||
@@ -279,7 +286,7 @@ BootManagerController::_CreateErrorEntryPage()
|
|||||||
{
|
{
|
||||||
BString description;
|
BString description;
|
||||||
|
|
||||||
if (fReadPartitionsStatus == kErrorBootSectorTooSmall) {
|
if (fReadPartitionsStatus == B_PARTITION_TOO_SMALL) {
|
||||||
description << B_TRANSLATE_COMMENT("Partition table not compatible",
|
description << B_TRANSLATE_COMMENT("Partition table not compatible",
|
||||||
"Title") << "\n\n"
|
"Title") << "\n\n"
|
||||||
<< B_TRANSLATE("The partition table of the first hard disk is not "
|
<< B_TRANSLATE("The partition table of the first hard disk is not "
|
||||||
@@ -371,7 +378,7 @@ BootManagerController::_CreateInstallSummaryPage()
|
|||||||
message.FindString("path", &path);
|
message.FindString("path", &path);
|
||||||
|
|
||||||
BString displayName;
|
BString displayName;
|
||||||
if (fBootDrive->GetDisplayText(name.String(), displayName) == B_OK)
|
if (fBootMenu->GetDisplayText(name.String(), displayName) == B_OK)
|
||||||
description << displayName << "\t(" << path << ")\n";
|
description << displayName << "\t(" << path << ")\n";
|
||||||
else
|
else
|
||||||
description << name << "\t(" << path << ")\n";
|
description << name << "\t(" << path << ")\n";
|
||||||
|
|||||||
@@ -15,10 +15,9 @@
|
|||||||
|
|
||||||
|
|
||||||
class BootDrive;
|
class BootDrive;
|
||||||
|
class BootMenu;
|
||||||
class WizardView;
|
class WizardView;
|
||||||
class WizardPageView;
|
class WizardPageView;
|
||||||
class BRect;
|
|
||||||
|
|
||||||
|
|
||||||
/* Remainder of Settings Message Format:
|
/* Remainder of Settings Message Format:
|
||||||
@@ -34,6 +33,8 @@ public:
|
|||||||
BootManagerController();
|
BootManagerController();
|
||||||
virtual ~BootManagerController();
|
virtual ~BootManagerController();
|
||||||
|
|
||||||
|
virtual void Previous(WizardView* wizard);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int32 InitialState();
|
virtual int32 InitialState();
|
||||||
virtual int32 NextState(int32 state);
|
virtual int32 NextState(int32 state);
|
||||||
@@ -71,7 +72,7 @@ private:
|
|||||||
WizardPageView* _CreateUninstalledPage();
|
WizardPageView* _CreateUninstalledPage();
|
||||||
|
|
||||||
BMessage fSettings;
|
BMessage fSettings;
|
||||||
BootDrive* fBootDrive;
|
BootMenu* fBootMenu;
|
||||||
|
|
||||||
status_t fReadPartitionsStatus;
|
status_t fReadPartitionsStatus;
|
||||||
status_t fWriteBootMenuStatus;
|
status_t fWriteBootMenuStatus;
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2008-2011, Haiku, Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Michael Pfeiffer <[email protected]>
|
||||||
|
*/
|
||||||
|
#ifndef BOOT_MENU_H
|
||||||
|
#define BOOT_MENU_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <File.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* Setting BMessage Format:
|
||||||
|
|
||||||
|
"disk" String (path to boot disk)
|
||||||
|
|
||||||
|
"partition" array of BMessage:
|
||||||
|
"show" bool (flag if entry should be added to boot menu)
|
||||||
|
"name" String (the name as shown in boot menu)
|
||||||
|
"type" String (short name of file system: bfs, dos)
|
||||||
|
"path" String (path to partition in /dev/...)
|
||||||
|
"size" long (size of partition in bytes)
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
class BootMenu {
|
||||||
|
public:
|
||||||
|
BootMenu() {}
|
||||||
|
virtual ~BootMenu() {}
|
||||||
|
|
||||||
|
virtual bool IsBootMenuInstalled(BMessage* settings) = 0;
|
||||||
|
virtual status_t ReadPartitions(BMessage* settings) = 0;
|
||||||
|
virtual status_t WriteBootMenu(BMessage* settings) = 0;
|
||||||
|
virtual status_t SaveMasterBootRecord(BMessage* settings,
|
||||||
|
BFile* file) = 0;
|
||||||
|
virtual status_t RestoreMasterBootRecord(BMessage* settings,
|
||||||
|
BFile* file) = 0;
|
||||||
|
|
||||||
|
// Converts the specified text into a text as it will be shown
|
||||||
|
// in the boot menu.
|
||||||
|
virtual status_t GetDisplayText(const char* text,
|
||||||
|
BString& displayText) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // BOOT_MENU_H
|
||||||
@@ -0,0 +1,306 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Axel Dörfler, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "DrivesPage.h"
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <ControlLook.h>
|
||||||
|
#include <DiskDeviceRoster.h>
|
||||||
|
#include <DiskDevice.h>
|
||||||
|
#include <LayoutBuilder.h>
|
||||||
|
#include <ListView.h>
|
||||||
|
#include <Path.h>
|
||||||
|
#include <ScrollView.h>
|
||||||
|
#include <TextView.h>
|
||||||
|
|
||||||
|
#include <StringForSize.h>
|
||||||
|
|
||||||
|
#include "BootDrive.h"
|
||||||
|
#include "WizardView.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATE_CONTEXT
|
||||||
|
#define B_TRANSLATE_CONTEXT "DrivesPage"
|
||||||
|
|
||||||
|
|
||||||
|
const uint32 kMsgSelectionChanged = 'slch';
|
||||||
|
|
||||||
|
|
||||||
|
class DriveItem : public BListItem {
|
||||||
|
public:
|
||||||
|
DriveItem(const BDiskDevice& device);
|
||||||
|
virtual ~DriveItem();
|
||||||
|
|
||||||
|
bool IsInstalled() const;
|
||||||
|
bool CanBeInstalled() const;
|
||||||
|
bool IsBootDrive() const;
|
||||||
|
const char* Path() const { return fPath.Path(); }
|
||||||
|
|
||||||
|
BMessage& Settings() { return fSettings; }
|
||||||
|
BootDrive* Drive() { return fDrive; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void DrawItem(BView* owner, BRect frame,
|
||||||
|
bool complete = false);
|
||||||
|
virtual void Update(BView* owner, const BFont* font);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BMessage fSettings;
|
||||||
|
BootDrive* fDrive;
|
||||||
|
BString fName;
|
||||||
|
BPath fPath;
|
||||||
|
BString fSize;
|
||||||
|
float fBaselineOffset;
|
||||||
|
float fSecondBaselineOffset;
|
||||||
|
float fSizeWidth;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
DriveItem::DriveItem(const BDiskDevice& device)
|
||||||
|
:
|
||||||
|
fBaselineOffset(0),
|
||||||
|
fSizeWidth(0)
|
||||||
|
{
|
||||||
|
// TODO: retrieve disk name!
|
||||||
|
if (device.Name() != NULL && device.Name()[0])
|
||||||
|
fName = device.Name();
|
||||||
|
else
|
||||||
|
fName = B_TRANSLATE_COMMENT("Hard Drive", "Default disk name");
|
||||||
|
|
||||||
|
device.GetPath(&fPath);
|
||||||
|
|
||||||
|
char buffer[256];
|
||||||
|
fSize = string_for_size(device.Size(), buffer, sizeof(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DriveItem::~DriveItem()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DriveItem::IsInstalled() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DriveItem::CanBeInstalled() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
DriveItem::IsBootDrive() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DriveItem::DrawItem(BView* owner, BRect frame, bool complete)
|
||||||
|
{
|
||||||
|
owner->PushState();
|
||||||
|
|
||||||
|
if (IsSelected() || complete) {
|
||||||
|
if (IsSelected()) {
|
||||||
|
owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_2_TINT));
|
||||||
|
owner->SetLowColor(owner->HighColor());
|
||||||
|
} else
|
||||||
|
owner->SetHighColor(owner->LowColor());
|
||||||
|
|
||||||
|
owner->FillRect(frame);
|
||||||
|
}
|
||||||
|
|
||||||
|
rgb_color black = {0, 0, 0, 255};
|
||||||
|
|
||||||
|
if (!IsEnabled())
|
||||||
|
owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
|
||||||
|
else
|
||||||
|
owner->SetHighColor(black);
|
||||||
|
|
||||||
|
// device
|
||||||
|
owner->MovePenTo(frame.left + 4, frame.top + fSecondBaselineOffset);
|
||||||
|
owner->DrawString(fPath.Path());
|
||||||
|
|
||||||
|
// size
|
||||||
|
owner->MovePenTo(frame.right - 4 - fSizeWidth, frame.top + fBaselineOffset);
|
||||||
|
owner->DrawString(fSize.String());
|
||||||
|
|
||||||
|
// name
|
||||||
|
BFont boldFont;
|
||||||
|
owner->GetFont(&boldFont);
|
||||||
|
boldFont.SetFace(B_BOLD_FACE);
|
||||||
|
owner->SetFont(&boldFont);
|
||||||
|
|
||||||
|
owner->MovePenTo(frame.left + 4, frame.top + fBaselineOffset);
|
||||||
|
owner->DrawString(fName.String());
|
||||||
|
|
||||||
|
owner->PopState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DriveItem::Update(BView* owner, const BFont* font)
|
||||||
|
{
|
||||||
|
fSizeWidth = font->StringWidth(fSize.String());
|
||||||
|
|
||||||
|
BFont boldFont(font);
|
||||||
|
boldFont.SetFace(B_BOLD_FACE);
|
||||||
|
float width = 8 + boldFont.StringWidth(fPath.Path())
|
||||||
|
+ be_control_look->DefaultItemSpacing() + fSizeWidth;
|
||||||
|
float pathWidth = font->StringWidth(fPath.Path());
|
||||||
|
if (width < pathWidth)
|
||||||
|
width = pathWidth;
|
||||||
|
|
||||||
|
SetWidth(width);
|
||||||
|
|
||||||
|
font_height fheight;
|
||||||
|
font->GetHeight(&fheight);
|
||||||
|
|
||||||
|
float lineHeight = ceilf(fheight.ascent) + ceilf(fheight.descent)
|
||||||
|
+ ceilf(fheight.leading);
|
||||||
|
|
||||||
|
fBaselineOffset = 2 + ceilf(fheight.ascent + fheight.leading / 2);
|
||||||
|
fSecondBaselineOffset = fBaselineOffset + lineHeight;
|
||||||
|
|
||||||
|
SetHeight(2 * lineHeight + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
DrivesPage::DrivesPage(WizardView* wizardView, BMessage* settings,
|
||||||
|
const char* name)
|
||||||
|
:
|
||||||
|
WizardPageView(settings, name),
|
||||||
|
fWizardView(wizardView)
|
||||||
|
{
|
||||||
|
BString text;
|
||||||
|
text << B_TRANSLATE_COMMENT("Drives", "Title") << "\n"
|
||||||
|
<< B_TRANSLATE("Please select the drive you want the boot manager to "
|
||||||
|
"be installed to or uninstalled from.");
|
||||||
|
BTextView* description = CreateDescription("description", text);
|
||||||
|
MakeHeading(description);
|
||||||
|
|
||||||
|
fDrivesView = new BListView("drives");
|
||||||
|
fDrivesView->SetSelectionMessage(new BMessage(kMsgSelectionChanged));
|
||||||
|
|
||||||
|
bool any = _FillDrivesView();
|
||||||
|
|
||||||
|
BScrollView* scrollView = new BScrollView("scrollView", fDrivesView, 0,
|
||||||
|
false, true);
|
||||||
|
|
||||||
|
SetLayout(new BGroupLayout(B_VERTICAL));
|
||||||
|
|
||||||
|
BLayoutBuilder::Group<>((BGroupLayout*)GetLayout())
|
||||||
|
.Add(description, 0.5)
|
||||||
|
.Add(scrollView, 1);
|
||||||
|
|
||||||
|
if (any) {
|
||||||
|
fWizardView->SetPreviousButtonLabel(
|
||||||
|
B_TRANSLATE_COMMENT("Uninstall", "Button"));
|
||||||
|
fWizardView->SetPreviousButtonHidden(false);
|
||||||
|
} else {
|
||||||
|
fWizardView->SetPreviousButtonHidden(true);
|
||||||
|
fWizardView->SetNextButtonLabel(
|
||||||
|
B_TRANSLATE_COMMENT("Quit", "Button"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DrivesPage::~DrivesPage()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DrivesPage::PageCompleted()
|
||||||
|
{
|
||||||
|
DriveItem* item = _SelectedDriveItem();
|
||||||
|
|
||||||
|
if (fSettings->ReplaceString("disk", item->Path()) != B_OK)
|
||||||
|
fSettings->AddString("disk", item->Path());
|
||||||
|
|
||||||
|
fSettings->ReplaceBool("install", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DrivesPage::AttachedToWindow()
|
||||||
|
{
|
||||||
|
fDrivesView->SetTarget(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DrivesPage::MessageReceived(BMessage* message)
|
||||||
|
{
|
||||||
|
switch (message->what) {
|
||||||
|
case kMsgSelectionChanged:
|
||||||
|
{
|
||||||
|
_UpdateWizardButtons(_SelectedDriveItem());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
WizardPageView::MessageReceived(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Builds the list view items, and adds them to fDriveView.
|
||||||
|
Returns whether there were any possible install targets. Automatically
|
||||||
|
selects the boot drive.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
DrivesPage::_FillDrivesView()
|
||||||
|
{
|
||||||
|
bool any = false;
|
||||||
|
|
||||||
|
BDiskDeviceRoster roster;
|
||||||
|
BDiskDevice device;
|
||||||
|
while (roster.GetNextDevice(&device) == B_OK) {
|
||||||
|
if (device.HasMedia() && !device.IsReadOnly()) {
|
||||||
|
DriveItem* item = new DriveItem(device);
|
||||||
|
if (item->CanBeInstalled())
|
||||||
|
any = true;
|
||||||
|
fDrivesView->AddItem(item);
|
||||||
|
if (item->IsBootDrive()) {
|
||||||
|
fDrivesView->Select(fDrivesView->CountItems() - 1);
|
||||||
|
_UpdateWizardButtons(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return any;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DriveItem*
|
||||||
|
DrivesPage::_SelectedDriveItem()
|
||||||
|
{
|
||||||
|
return (DriveItem*)fDrivesView->ItemAt(fDrivesView->CurrentSelection());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
DrivesPage::_UpdateWizardButtons(DriveItem* item)
|
||||||
|
{
|
||||||
|
fWizardView->SetPreviousButtonEnabled(
|
||||||
|
item->CanBeInstalled() && item->IsInstalled());
|
||||||
|
fWizardView->SetNextButtonEnabled(item->CanBeInstalled());
|
||||||
|
|
||||||
|
fWizardView->SetNextButtonLabel(
|
||||||
|
item->IsInstalled() && item->CanBeInstalled()
|
||||||
|
? B_TRANSLATE_COMMENT("Update", "Button")
|
||||||
|
: B_TRANSLATE_COMMENT("Install", "Button"));
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2011, Axel Dörfler, [email protected].
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
#ifndef DRIVES_PAGE_H
|
||||||
|
#define DRIVES_PAGE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "WizardPageView.h"
|
||||||
|
|
||||||
|
|
||||||
|
class BListView;
|
||||||
|
class BTextView;
|
||||||
|
class BScrollView;
|
||||||
|
class DriveItem;
|
||||||
|
class WizardView;
|
||||||
|
|
||||||
|
|
||||||
|
class DrivesPage : public WizardPageView {
|
||||||
|
public:
|
||||||
|
DrivesPage(WizardView* wizardView,
|
||||||
|
BMessage* settings, const char* name);
|
||||||
|
virtual ~DrivesPage();
|
||||||
|
|
||||||
|
virtual void PageCompleted();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void AttachedToWindow();
|
||||||
|
void MessageReceived(BMessage* message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool _FillDrivesView();
|
||||||
|
DriveItem* _SelectedDriveItem();
|
||||||
|
void _UpdateWizardButtons(DriveItem* item);
|
||||||
|
|
||||||
|
private:
|
||||||
|
WizardView* fWizardView;
|
||||||
|
BListView* fDrivesView;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // DRIVES_PAGE_H
|
||||||
@@ -1,90 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2008-2011, Haiku, Inc. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Michael Pfeiffer <[email protected]>
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "EntryPage.h"
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <Catalog.h>
|
|
||||||
#include <LayoutBuilder.h>
|
|
||||||
#include <RadioButton.h>
|
|
||||||
#include <TextView.h>
|
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
|
||||||
#define B_TRANSLATE_CONTEXT "EntryPage"
|
|
||||||
|
|
||||||
|
|
||||||
EntryPage::EntryPage(BMessage* settings, const char* name)
|
|
||||||
:
|
|
||||||
WizardPageView(settings, name)
|
|
||||||
{
|
|
||||||
_BuildUI();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
EntryPage::~EntryPage()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
EntryPage::PageCompleted()
|
|
||||||
{
|
|
||||||
fSettings->ReplaceBool("install", fInstallButton->Value() != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
EntryPage::_BuildUI()
|
|
||||||
{
|
|
||||||
fInstallButton = new BRadioButton("install", NULL, NULL);
|
|
||||||
|
|
||||||
BString text;
|
|
||||||
text << B_TRANSLATE_COMMENT("Install boot menu", "Title") << "\n"
|
|
||||||
<< B_TRANSLATE("Choose this option to install a boot menu, "
|
|
||||||
"allowing you to select which operating "
|
|
||||||
"system to boot when you turn on your "
|
|
||||||
"computer.") << "\n";
|
|
||||||
fInstallText = CreateDescription("installText", text);
|
|
||||||
MakeHeading(fInstallText);
|
|
||||||
|
|
||||||
fUninstallButton = new BRadioButton("uninstall", NULL, NULL);
|
|
||||||
|
|
||||||
text.Truncate(0);
|
|
||||||
text << B_TRANSLATE_COMMENT("Uninstall boot menu", "Title") << "\n"
|
|
||||||
<< B_TRANSLATE("Choose this option to remove the boot menu "
|
|
||||||
"previously installed by this program.\n");
|
|
||||||
fUninstallText = CreateDescription("uninstallText", text);
|
|
||||||
MakeHeading(fUninstallText);
|
|
||||||
|
|
||||||
SetLayout(new BGroupLayout(B_VERTICAL));
|
|
||||||
|
|
||||||
BLayoutBuilder::Group<>((BGroupLayout*)GetLayout())
|
|
||||||
.AddGroup(B_HORIZONTAL, 0)
|
|
||||||
.AddGroup(B_VERTICAL, 0, 0)
|
|
||||||
.Add(fInstallButton)
|
|
||||||
.AddGlue()
|
|
||||||
.End()
|
|
||||||
.Add(fInstallText, 1)
|
|
||||||
.End()
|
|
||||||
.AddGroup(B_HORIZONTAL, 0)
|
|
||||||
.AddGroup(B_VERTICAL, 0, 0)
|
|
||||||
.Add(fUninstallButton)
|
|
||||||
.AddGlue()
|
|
||||||
.End()
|
|
||||||
.Add(fUninstallText)
|
|
||||||
.End()
|
|
||||||
.AddGlue();
|
|
||||||
|
|
||||||
if (fSettings->FindBool("install"))
|
|
||||||
fInstallButton->SetValue(1);
|
|
||||||
else
|
|
||||||
fUninstallButton->SetValue(1);
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2008-2011, Haiku, Inc. All rights reserved.
|
|
||||||
* Distributed under the terms of the MIT License.
|
|
||||||
*
|
|
||||||
* Authors:
|
|
||||||
* Michael Pfeiffer <[email protected]>
|
|
||||||
*/
|
|
||||||
#ifndef ENTRY_PAGE_H
|
|
||||||
#define ENTRY_PAGE_H
|
|
||||||
|
|
||||||
|
|
||||||
#include "WizardPageView.h"
|
|
||||||
|
|
||||||
|
|
||||||
class BRadioButton;
|
|
||||||
class BTextView;
|
|
||||||
|
|
||||||
|
|
||||||
class EntryPage : public WizardPageView {
|
|
||||||
public:
|
|
||||||
EntryPage(BMessage* settings, const char* name);
|
|
||||||
virtual ~EntryPage();
|
|
||||||
|
|
||||||
virtual void PageCompleted();
|
|
||||||
|
|
||||||
private:
|
|
||||||
void _BuildUI();
|
|
||||||
|
|
||||||
private:
|
|
||||||
BRadioButton* fInstallButton;
|
|
||||||
BTextView* fInstallText;
|
|
||||||
BRadioButton* fUninstallButton;
|
|
||||||
BTextView* fUninstallText;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // ENTRY_PAGE_H
|
|
||||||
@@ -8,9 +8,9 @@ Application BootManager :
|
|||||||
BootManagerWindow.cpp
|
BootManagerWindow.cpp
|
||||||
DefaultPartitionPage.cpp
|
DefaultPartitionPage.cpp
|
||||||
DescriptionPage.cpp
|
DescriptionPage.cpp
|
||||||
EntryPage.cpp
|
DrivesPage.cpp
|
||||||
FileSelectionPage.cpp
|
FileSelectionPage.cpp
|
||||||
LegacyBootDrive.cpp
|
LegacyBootMenu.cpp
|
||||||
PartitionsPage.cpp
|
PartitionsPage.cpp
|
||||||
# TestBootDrive.cpp
|
# TestBootDrive.cpp
|
||||||
UninstallPage.cpp
|
UninstallPage.cpp
|
||||||
|
|||||||
+27
-39
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
* Copyright 2008-2011, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "LegacyBootDrive.h"
|
#include "LegacyBootMenu.h"
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
#define B_TRANSLATE_CONTEXT "LegacyBootDrive"
|
#define B_TRANSLATE_CONTEXT "LegacyBootMenu"
|
||||||
#define USE_SECOND_DISK 0
|
#define USE_SECOND_DISK 0
|
||||||
#define GET_FIRST_BIOS_DRIVE 1
|
#define GET_FIRST_BIOS_DRIVE 1
|
||||||
|
|
||||||
@@ -238,18 +238,18 @@ PartitionRecorder::_Record(BPartition* partition)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
LegacyBootDrive::LegacyBootDrive()
|
LegacyBootMenu::LegacyBootMenu()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LegacyBootDrive::~LegacyBootDrive()
|
LegacyBootMenu::~LegacyBootMenu()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LegacyBootDrive::IsBootMenuInstalled(BMessage* settings)
|
LegacyBootMenu::IsBootMenuInstalled(BMessage* settings)
|
||||||
{
|
{
|
||||||
// TODO detect bootman
|
// TODO detect bootman
|
||||||
return false;
|
return false;
|
||||||
@@ -257,17 +257,18 @@ LegacyBootDrive::IsBootMenuInstalled(BMessage* settings)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::ReadPartitions(BMessage *settings)
|
LegacyBootMenu::ReadPartitions(BMessage *settings)
|
||||||
{
|
{
|
||||||
|
status_t status = B_ERROR;
|
||||||
|
|
||||||
BDiskDeviceRoster diskDeviceRoster;
|
BDiskDeviceRoster diskDeviceRoster;
|
||||||
BDiskDevice device;
|
BDiskDevice device;
|
||||||
bool diskFound = false;
|
bool diskFound = false;
|
||||||
while (diskDeviceRoster.GetNextDevice(&device) == B_OK) {
|
while (diskDeviceRoster.GetNextDevice(&device) == B_OK) {
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
status_t status = device.GetPath(&path);
|
status_t status = device.GetPath(&path);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
continue;
|
||||||
|
|
||||||
// skip not from BIOS bootable drives
|
// skip not from BIOS bootable drives
|
||||||
int8 drive;
|
int8 drive;
|
||||||
@@ -281,33 +282,20 @@ LegacyBootDrive::ReadPartitions(BMessage *settings)
|
|||||||
settings->AddString("disk", path.Path());
|
settings->AddString("disk", path.Path());
|
||||||
diskFound = true;
|
diskFound = true;
|
||||||
|
|
||||||
#if !USE_SECOND_DISK
|
// Enough space to write boot menu to drive?
|
||||||
// Enough space to write boot menu to drive?
|
// (ignored in test build)
|
||||||
// (ignored in test build)
|
off_t size = sizeof(kBootLoader);
|
||||||
off_t size = sizeof(kBootLoader);
|
if (!recorder.HasPartitions() || recorder.FirstOffset() < size)
|
||||||
if (!recorder.HasPartitions() || recorder.FirstOffset() < size)
|
status = B_PARTITION_TOO_SMALL;
|
||||||
return kErrorBootSectorTooSmall;
|
|
||||||
|
|
||||||
// TODO remove when booting from all drives works
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USE_SECOND_DISK
|
return diskFound ? B_OK : status;
|
||||||
// for testing only write boot menu to second hdd
|
|
||||||
settings->ReplaceString("disk", "/dev/disk/ata/1/master/raw");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (diskFound)
|
|
||||||
return B_OK;
|
|
||||||
else
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
LegacyBootMenu::WriteBootMenu(BMessage *settings)
|
||||||
{
|
{
|
||||||
BString path;
|
BString path;
|
||||||
if (settings->FindString("disk", &path) != B_OK)
|
if (settings->FindString("disk", &path) != B_OK)
|
||||||
@@ -375,7 +363,7 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
|||||||
partition.FindBool("show", &show);
|
partition.FindBool("show", &show);
|
||||||
partition.FindString("name", &name);
|
partition.FindString("name", &name);
|
||||||
partition.FindString("path", &path);
|
partition.FindString("path", &path);
|
||||||
// LegacyBootDrive specific data
|
// LegacyBootMenu specific data
|
||||||
partition.FindInt64("offset", &offset);
|
partition.FindInt64("offset", &offset);
|
||||||
partition.FindInt8("drive", &drive);
|
partition.FindInt8("drive", &drive);
|
||||||
if (!show)
|
if (!show)
|
||||||
@@ -403,7 +391,7 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file)
|
LegacyBootMenu::SaveMasterBootRecord(BMessage* settings, BFile* file)
|
||||||
{
|
{
|
||||||
BString path;
|
BString path;
|
||||||
|
|
||||||
@@ -444,7 +432,7 @@ LegacyBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
|
LegacyBootMenu::RestoreMasterBootRecord(BMessage* settings, BFile* file)
|
||||||
{
|
{
|
||||||
BString path;
|
BString path;
|
||||||
if (settings->FindString("disk", &path) != B_OK)
|
if (settings->FindString("disk", &path) != B_OK)
|
||||||
@@ -496,7 +484,7 @@ LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::GetDisplayText(const char* text, BString& displayText)
|
LegacyBootMenu::GetDisplayText(const char* text, BString& displayText)
|
||||||
{
|
{
|
||||||
BString biosText;
|
BString biosText;
|
||||||
if (!_ConvertToBIOSText(text, biosText)) {
|
if (!_ConvertToBIOSText(text, biosText)) {
|
||||||
@@ -524,7 +512,7 @@ LegacyBootDrive::GetDisplayText(const char* text, BString& displayText)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LegacyBootDrive::_ConvertToBIOSText(const char* text, BString& biosText)
|
LegacyBootMenu::_ConvertToBIOSText(const char* text, BString& biosText)
|
||||||
{
|
{
|
||||||
// convert text in UTF-8 to 'code page 437'
|
// convert text in UTF-8 to 'code page 437'
|
||||||
int32 textLength = strlen(text);
|
int32 textLength = strlen(text);
|
||||||
@@ -550,7 +538,7 @@ LegacyBootDrive::_ConvertToBIOSText(const char* text, BString& biosText)
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LegacyBootDrive::_GetBiosDrive(const char* device, int8* drive)
|
LegacyBootMenu::_GetBiosDrive(const char* device, int8* drive)
|
||||||
{
|
{
|
||||||
#if !GET_FIRST_BIOS_DRIVE
|
#if !GET_FIRST_BIOS_DRIVE
|
||||||
int fd = open(device, O_RDONLY);
|
int fd = open(device, O_RDONLY);
|
||||||
@@ -567,7 +555,7 @@ LegacyBootDrive::_GetBiosDrive(const char* device, int8* drive)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::_ReadBlocks(int fd, uint8* buffer, size_t size)
|
LegacyBootMenu::_ReadBlocks(int fd, uint8* buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (size % kBlockSize != 0) {
|
if (size % kBlockSize != 0) {
|
||||||
fprintf(stderr, "_ReadBlocks buffer size must be a multiple of %d\n",
|
fprintf(stderr, "_ReadBlocks buffer size must be a multiple of %d\n",
|
||||||
@@ -585,7 +573,7 @@ LegacyBootDrive::_ReadBlocks(int fd, uint8* buffer, size_t size)
|
|||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
LegacyBootDrive::_WriteBlocks(int fd, const uint8* buffer, size_t size)
|
LegacyBootMenu::_WriteBlocks(int fd, const uint8* buffer, size_t size)
|
||||||
{
|
{
|
||||||
if (size % kBlockSize != 0) {
|
if (size % kBlockSize != 0) {
|
||||||
fprintf(stderr, "_WriteBlocks buffer size must be a multiple of %d\n",
|
fprintf(stderr, "_WriteBlocks buffer size must be a multiple of %d\n",
|
||||||
@@ -603,7 +591,7 @@ LegacyBootDrive::_WriteBlocks(int fd, const uint8* buffer, size_t size)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination,
|
LegacyBootMenu::_CopyPartitionTable(MasterBootRecord* destination,
|
||||||
const MasterBootRecord* source)
|
const MasterBootRecord* source)
|
||||||
{
|
{
|
||||||
memcpy(destination->diskSignature, source->diskSignature,
|
memcpy(destination->diskSignature, source->diskSignature,
|
||||||
@@ -613,7 +601,7 @@ LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination,
|
|||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
LegacyBootDrive::_IsValid(const MasterBootRecord* mbr)
|
LegacyBootMenu::_IsValid(const MasterBootRecord* mbr)
|
||||||
{
|
{
|
||||||
return mbr->signature[0] == (kMBRSignature & 0xff)
|
return mbr->signature[0] == (kMBRSignature & 0xff)
|
||||||
&& mbr->signature[1] == (kMBRSignature >> 8);
|
&& mbr->signature[1] == (kMBRSignature >> 8);
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008-2010, Haiku, Inc. All rights reserved.
|
* Copyright 2008-2011, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
* Michael Pfeiffer <laplace@users.sourceforge.net>
|
||||||
*/
|
*/
|
||||||
#ifndef LEGACY_BOOT_DRIVE_H
|
#ifndef LEGACY_BOOT_MENU_H
|
||||||
#define LEGACY_BOOT_DRIVE_H
|
#define LEGACY_BOOT_MENU_H
|
||||||
|
|
||||||
|
|
||||||
#include "BootDrive.h"
|
#include "BootMenu.h"
|
||||||
|
|
||||||
#include <SupportDefs.h>
|
#include <SupportDefs.h>
|
||||||
|
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
struct MasterBootRecord;
|
struct MasterBootRecord;
|
||||||
|
|
||||||
|
|
||||||
class LegacyBootDrive : public BootDrive {
|
class LegacyBootMenu : public BootMenu {
|
||||||
public:
|
public:
|
||||||
LegacyBootDrive();
|
LegacyBootMenu();
|
||||||
virtual ~LegacyBootDrive();
|
virtual ~LegacyBootMenu();
|
||||||
|
|
||||||
virtual bool IsBootMenuInstalled(BMessage* settings);
|
virtual bool IsBootMenuInstalled(BMessage* settings);
|
||||||
virtual status_t ReadPartitions(BMessage* settings);
|
virtual status_t ReadPartitions(BMessage* settings);
|
||||||
@@ -46,4 +46,4 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // LEGACY_BOOT_DRIVE_H
|
#endif // LEGACY_BOOT_MENU_H
|
||||||
@@ -82,6 +82,16 @@ WizardController::Previous(WizardView* wizard)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32
|
||||||
|
WizardController::CurrentState() const
|
||||||
|
{
|
||||||
|
if (fStack == NULL)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return fStack->State();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
WizardController::_PushState(int32 state)
|
WizardController::_PushState(int32 state)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ protected:
|
|||||||
virtual int32 NextState(int32 state) = 0;
|
virtual int32 NextState(int32 state) = 0;
|
||||||
virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0;
|
virtual WizardPageView* CreatePage(int32 state, WizardView* wizard) = 0;
|
||||||
|
|
||||||
|
int32 CurrentState() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class StateStack {
|
class StateStack {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
WizardView::WizardView(const char* name)
|
WizardView::WizardView(const char* name)
|
||||||
:
|
:
|
||||||
BGroupView(name, B_VERTICAL),
|
BGroupView(name, B_VERTICAL, 0),
|
||||||
fPrevious(NULL),
|
fPrevious(NULL),
|
||||||
fNext(NULL),
|
fNext(NULL),
|
||||||
fPage(NULL)
|
fPage(NULL)
|
||||||
@@ -63,6 +63,9 @@ WizardView::PageCompleted()
|
|||||||
{
|
{
|
||||||
if (fPage != NULL)
|
if (fPage != NULL)
|
||||||
fPage->PageCompleted();
|
fPage->PageCompleted();
|
||||||
|
|
||||||
|
SetNextButtonLabel(B_TRANSLATE_COMMENT("Next", "Button"));
|
||||||
|
SetPreviousButtonLabel(B_TRANSLATE_COMMENT("Previous", "Button"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -123,7 +126,7 @@ WizardView::_BuildUI()
|
|||||||
.Add(fPageContainer)
|
.Add(fPageContainer)
|
||||||
.Add(new BSeparatorView(B_HORIZONTAL))
|
.Add(new BSeparatorView(B_HORIZONTAL))
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING, 0,
|
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
|
||||||
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fPrevious)
|
.Add(fPrevious)
|
||||||
|
|||||||
Reference in New Issue
Block a user