* Localized.
* Text of boot menu items is encoded using code page 437 (for example umlaute can now be used). * On the last wizard page before writing the boot menu a preview is shown of the boot menu items. * Enforce menu item size limit of 70 bytes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35771 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5edde94cab
commit
09ccc66ea0
|
@ -40,6 +40,9 @@ public:
|
|||
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_DRIVE_H
|
||||
|
|
|
@ -11,9 +11,14 @@
|
|||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <Locale.h>
|
||||
#include <TextView.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "BootManager"
|
||||
|
||||
|
||||
static const char* kSignature = "application/x-vnd.Haiku-bootman";
|
||||
|
||||
|
||||
|
@ -24,12 +29,16 @@ public:
|
|||
virtual void ReadyToRun();
|
||||
|
||||
virtual void AboutRequested();
|
||||
|
||||
private:
|
||||
BCatalog fCatalog;
|
||||
};
|
||||
|
||||
|
||||
BootManager::BootManager()
|
||||
: BApplication(kSignature)
|
||||
{
|
||||
be_locale->GetAppCatalog(&fCatalog);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,12 +53,13 @@ BootManager::ReadyToRun()
|
|||
void
|
||||
BootManager::AboutRequested()
|
||||
{
|
||||
BAlert *alert = new BAlert("about", "Haiku Boot Manager\n\n"
|
||||
BAlert *alert = new BAlert("about",
|
||||
TR("Haiku Boot Manager\n\n"
|
||||
"written by\n"
|
||||
"\tDavid Dengg\n"
|
||||
"\tMichael Pfeiffer\n"
|
||||
"\n"
|
||||
"Copyright 2008-10, Haiku Inc.\n", "OK");
|
||||
"Copyright 2008-10, Haiku Inc.\n"), TR("OK"));
|
||||
BTextView *view = alert->TextView();
|
||||
BFont font;
|
||||
|
||||
|
|
|
@ -28,12 +28,16 @@
|
|||
|
||||
#include <Alert.h>
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <File.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "BootManagerController"
|
||||
|
||||
|
||||
BootManagerController::BootManagerController()
|
||||
{
|
||||
#if USE_TEST_BOOT_DRIVE
|
||||
|
@ -150,8 +154,9 @@ BootManagerController::_HasSelectedPartitions()
|
|||
return true;
|
||||
}
|
||||
|
||||
BAlert* alert = new BAlert("info", "At least one partition must be "
|
||||
"selected!", "OK");
|
||||
BAlert* alert = new BAlert("info",
|
||||
TR("At least one partition must be selected!"),
|
||||
TR("OK"));
|
||||
alert->Go();
|
||||
|
||||
return false;
|
||||
|
@ -161,9 +166,10 @@ BootManagerController::_HasSelectedPartitions()
|
|||
bool
|
||||
BootManagerController::_WriteBootMenu()
|
||||
{
|
||||
BAlert* alert = new BAlert("confirm", "About to write the boot menu "
|
||||
"to disk. Are you sure you want to continue?", "Write boot menu",
|
||||
"Back", NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
BAlert* alert = new BAlert("confirm", TR("About to write the boot menu "
|
||||
"to disk. Are you sure you want to continue?"),
|
||||
TR("Write boot menu"),
|
||||
TR("Back"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
|
||||
if (alert->Go() == 1)
|
||||
return false;
|
||||
|
@ -193,11 +199,11 @@ BootManagerController::_RestoreMBR()
|
|||
fSettings.FindString("file", &path);
|
||||
|
||||
BString message;
|
||||
message << "About to restore the Master Boot Record (MBR) of "
|
||||
<< disk << " from " << path << ". "
|
||||
"Do you wish to continue?";
|
||||
message << TR("About to restore the Master Boot Record (MBR) of")
|
||||
<< " " << disk << " " << TR("from") << " " << path << ". " <<
|
||||
TR("Do you wish to continue?");
|
||||
BAlert* alert = new BAlert("confirm", message.String(),
|
||||
"Restore MBR", "Back",
|
||||
TR("Restore MBR"), TR("Back"),
|
||||
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
|
||||
if (alert->Go() == 1)
|
||||
return false;
|
||||
|
@ -222,7 +228,7 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
|||
case kStateErrorEntry:
|
||||
page = _CreateErrorEntryPage(frame);
|
||||
wizard->SetPreviousButtonHidden(true);
|
||||
wizard->SetNextButtonLabel("Done");
|
||||
wizard->SetNextButtonLabel(TR("Done"));
|
||||
break;
|
||||
case kStateSaveMBR:
|
||||
page = _CreateSaveMBRPage(frame);
|
||||
|
@ -240,21 +246,21 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
|
|||
break;
|
||||
case kStateInstallSummary:
|
||||
page = _CreateInstallSummaryPage(frame);
|
||||
wizard->SetNextButtonLabel("Next");
|
||||
wizard->SetNextButtonLabel(TR("Next"));
|
||||
break;
|
||||
case kStateInstalled:
|
||||
page = _CreateInstalledPage(frame);
|
||||
wizard->SetNextButtonLabel("Done");
|
||||
wizard->SetNextButtonLabel(TR("Done"));
|
||||
break;
|
||||
case kStateUninstall:
|
||||
page = _CreateUninstallPage(frame);
|
||||
wizard->SetPreviousButtonHidden(false);
|
||||
wizard->SetNextButtonLabel("Next");
|
||||
wizard->SetNextButtonLabel(TR("Next"));
|
||||
break;
|
||||
case kStateUninstalled:
|
||||
// TODO prevent overwriting MBR after clicking "Previous"
|
||||
page = _CreateUninstalledPage(frame);
|
||||
wizard->SetNextButtonLabel("Done");
|
||||
wizard->SetNextButtonLabel(TR("Done"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -269,14 +275,15 @@ BootManagerController::_CreateErrorEntryPage(BRect frame)
|
|||
|
||||
if (fReadPartitionsStatus == kErrorBootSectorTooSmall)
|
||||
description <<
|
||||
"Partition table not compatible\n\n"
|
||||
"The partition table of the first hard disk is not compatible "
|
||||
TR("Partition table not compatible") << "\n\n" <<
|
||||
TR("The partition table of the first hard disk is not compatible "
|
||||
"with Boot Manager.\n"
|
||||
"Boot Manager needs 2 KB available space before the first partition.";
|
||||
"Boot Manager needs 2 KB available space before the first "
|
||||
"partition.");
|
||||
else
|
||||
description <<
|
||||
"Error reading partition table\n\n"
|
||||
"Boot Manager is unable to read the partition table!";
|
||||
TR("Error reading partition table") << "\n\n" <<
|
||||
TR("Boot Manager is unable to read the partition table!");
|
||||
|
||||
return new DescriptionPage(frame, "errorEntry", description.String(), true);
|
||||
}
|
||||
|
@ -290,16 +297,18 @@ BootManagerController::_CreateSaveMBRPage(BRect frame)
|
|||
fSettings.FindString("disk", &disk);
|
||||
|
||||
description <<
|
||||
"Backup Master Boot Record\n\n"
|
||||
"The Master Boot Record (MBR) of the boot device:\n"
|
||||
"\t" << disk << "\n"
|
||||
TR("Backup Master Boot Record") << "\n\n" <<
|
||||
TR("The Master Boot Record (MBR) of the boot device:\n"
|
||||
"\t%s\n"
|
||||
"will now be saved to disk. Please select a file to "
|
||||
"save the MBR into.\n\n"
|
||||
"If something goes wrong with the installation or if "
|
||||
"you later wish to remove the boot menu, simply run the "
|
||||
"bootman program and choose the 'Uninstall' option.";
|
||||
"bootman program and choose the 'Uninstall' option.");
|
||||
description.ReplaceFirst("%s", disk);
|
||||
|
||||
return new FileSelectionPage(&fSettings, frame, "saveMBR", description.String(),
|
||||
return new FileSelectionPage(&fSettings, frame, "saveMBR",
|
||||
description.String(),
|
||||
B_SAVE_PANEL);
|
||||
}
|
||||
|
||||
|
@ -313,15 +322,16 @@ BootManagerController::_CreateMBRSavedPage(BRect frame)
|
|||
|
||||
if (fSaveMBRStatus == B_OK) {
|
||||
description <<
|
||||
"Old Master Boot Record saved\n\n"
|
||||
"The old Master Boot Record was successfully save to "
|
||||
<< file << ".\n";
|
||||
TR("Old Master Boot Record saved") << "\n\n" <<
|
||||
TR("The old Master Boot Record was successfully save to %s.") <<
|
||||
"\n";
|
||||
} else {
|
||||
description <<
|
||||
"Old Master Boot Record Saved failure\n\n"
|
||||
"The old Master Boot Record could not be saved to "
|
||||
<< file << ".\n";
|
||||
TR("Old Master Boot Record Saved failure") << "\n\n" <<
|
||||
TR("The old Master Boot Record could not be saved to %s") <<
|
||||
"\n";
|
||||
}
|
||||
description.ReplaceFirst("%s", file);
|
||||
|
||||
return new DescriptionPage(frame, "summary", description.String(), true);
|
||||
}
|
||||
|
@ -335,10 +345,11 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame)
|
|||
fSettings.FindString("disk", &disk);
|
||||
|
||||
description <<
|
||||
"Summary\n\n"
|
||||
"About to write the following boot menu to the boot disk "
|
||||
"(" << disk << "). Please verify the information below "
|
||||
"before continuing.\n\n";
|
||||
TR("Summary") << "\n\n" <<
|
||||
TR("About to write the following boot menu to the boot disk "
|
||||
"(%s). Please verify the information below before continuing.") <<
|
||||
"\n\n";
|
||||
description.ReplaceFirst("%s", disk);
|
||||
|
||||
BMessage message;
|
||||
for (int32 i = 0; fSettings.FindMessage("partition", i, &message) == B_OK; i ++) {
|
||||
|
@ -351,7 +362,12 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame)
|
|||
BString path;
|
||||
message.FindString("name", &name);
|
||||
message.FindString("path", &path);
|
||||
description << name << "\t(" << path << ")\n";
|
||||
|
||||
BString displayName;
|
||||
if (fBootDrive->GetDisplayText(name.String(), displayName))
|
||||
description << displayName << "\t(" << path << ")\n";
|
||||
else
|
||||
description << name << "\t(" << path << ")\n";
|
||||
}
|
||||
|
||||
return new DescriptionPage(frame, "summary", description.String(), true);
|
||||
|
@ -361,16 +377,19 @@ BootManagerController::_CreateInstallSummaryPage(BRect frame)
|
|||
WizardPageView*
|
||||
BootManagerController::_CreateInstalledPage(BRect frame)
|
||||
{
|
||||
const char* description;
|
||||
BString description;
|
||||
|
||||
if (fWriteBootMenuStatus == B_OK) {
|
||||
description = "Installation of boot menu completed\n\n"
|
||||
"The boot manager has been successfully installed "
|
||||
"on your system.";
|
||||
description <<
|
||||
TR("Installation of boot menu completed") << "\n\n" <<
|
||||
TR("The boot manager has been successfully installed "
|
||||
"on your system.");
|
||||
} else {
|
||||
description = "Installation of boot menu failed\n\n"
|
||||
"An error occured writing the boot menu. The Master Boot Record "
|
||||
"might be destroyed, you should restore the MBR now!";
|
||||
description <<
|
||||
TR("Installation of boot menu failed") << "\n\n" <<
|
||||
TR("An error occurred writing the boot menu. "
|
||||
"The Master Boot Record might be destroyed, "
|
||||
"you should restore the MBR now!");
|
||||
}
|
||||
|
||||
return new DescriptionPage(frame, "done", description, true);
|
||||
|
@ -383,10 +402,10 @@ BootManagerController::_CreateUninstallPage(BRect frame)
|
|||
BString description;
|
||||
|
||||
description <<
|
||||
"Uninstall boot manager\n\n"
|
||||
"Please locate the Master Boot Record (MBR) save file to "
|
||||
"restore from. This is the file that was created when the "
|
||||
"boot manager was first installed.";
|
||||
TR("Uninstall boot manager") << "\n\n" <<
|
||||
TR("Please locate the Master Boot Record (MBR) save file to "
|
||||
"restore from. This is the file that was created when the "
|
||||
"boot manager was first installed.");
|
||||
|
||||
return new FileSelectionPage(&fSettings, frame, "restoreMBR", description.String(),
|
||||
B_OPEN_PANEL);
|
||||
|
@ -404,14 +423,15 @@ BootManagerController::_CreateUninstalledPage(BRect frame)
|
|||
|
||||
if (fRestoreMBRStatus == B_OK) {
|
||||
description <<
|
||||
"Uninstallation of boot menu completed\n\n"
|
||||
"The Master Boot Record of the boot device "
|
||||
"(" << disk << ") has been successfully restored from "
|
||||
<< file << ".";
|
||||
TR("Uninstallation of boot menu completed") << "\n\n" <<
|
||||
TR("The Master Boot Record of the boot device "
|
||||
"(%s) has been successfully restored from %s.");
|
||||
description.ReplaceFirst("%s", disk);
|
||||
description.ReplaceLast("%s", file);
|
||||
} else {
|
||||
description <<
|
||||
"Uninstallation of boot menu failed\n\n"
|
||||
"The Master Boot Record could not be restored!";
|
||||
TR("Uninstallation of boot menu failed") << "\n\n" <<
|
||||
TR("The Master Boot Record could not be restored!");
|
||||
}
|
||||
|
||||
return new DescriptionPage(frame, "summary", description.String(), true);
|
||||
|
|
|
@ -16,12 +16,18 @@
|
|||
#include "DefaultPartitionPage.h"
|
||||
|
||||
#include <Application.h>
|
||||
#include <Catalog.h>
|
||||
#include <Screen.h>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "BootManagerWindow"
|
||||
|
||||
|
||||
|
||||
BootManagerWindow::BootManagerWindow()
|
||||
: BWindow(BRect(100, 100, 500, 400), "Boot Manager", B_TITLED_WINDOW,
|
||||
: BWindow(BRect(100, 100, 500, 400), TR("Boot Manager"), B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
|
||||
{
|
||||
float minWidth, maxWidth, minHeight, maxHeight;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "DefaultPartitionPage.h"
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include <MenuItem.h>
|
||||
|
@ -22,6 +23,9 @@
|
|||
#include <String.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "DefaultPartitionPage"
|
||||
|
||||
|
||||
const uint32 kMsgPartition = 'part';
|
||||
const uint32 kMsgTimeout = 'time';
|
||||
|
||||
|
@ -89,22 +93,24 @@ DefaultPartitionPage::_BuildUI()
|
|||
{
|
||||
BRect rect(Bounds());
|
||||
|
||||
fDescription = CreateDescription(rect, "description",
|
||||
"Default Partition\n\n"
|
||||
"Please specify a default partition and a timeout.\n"
|
||||
BString text;
|
||||
text <<
|
||||
TR("Default Partition") << "\n\n" <<
|
||||
TR("Please specify a default partition and a timeout.\n"
|
||||
"The boot menu will load the default partition after "
|
||||
"the timeout unless you select another partition. You "
|
||||
"can also have the boot menu wait indefinitely for you "
|
||||
"to select a partition."
|
||||
);
|
||||
"to select a partition.");
|
||||
|
||||
fDescription = CreateDescription(rect, "description", text);
|
||||
MakeHeading(fDescription);
|
||||
AddChild(fDescription);
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
rect.top = fDescription->Frame().bottom + kTextDistance;
|
||||
|
||||
BPopUpMenu* popUpMenu = _CreatePopUpMenu();
|
||||
fDefaultPartition = new BMenuField(rect, "partitions", "Default Partition:",
|
||||
popUpMenu);
|
||||
fDefaultPartition = new BMenuField(rect, "partitions",
|
||||
TR("Default Partition:"), popUpMenu);
|
||||
float divider = be_plain_font->StringWidth(fDefaultPartition->Label()) + 3;
|
||||
fDefaultPartition->SetDivider(divider);
|
||||
AddChild(fDefaultPartition);
|
||||
|
@ -113,10 +119,14 @@ DefaultPartitionPage::_BuildUI()
|
|||
rect.top = fDefaultPartition->Frame().bottom + kTextDistance;
|
||||
int32 timeout;
|
||||
fSettings->FindInt32("timeout", &timeout);
|
||||
fWait0 = _CreateWaitRadioButton(rect, "wait0", "Wait Indefinitely", -1, timeout);
|
||||
fWait5 = _CreateWaitRadioButton(rect, "wait5", "Wait 5 Seconds", 5, timeout);
|
||||
fWait10 = _CreateWaitRadioButton(rect, "wait10", "Wait 10 Seconds", 10, timeout);
|
||||
fWait15 = _CreateWaitRadioButton(rect, "wait15", "Wait 15 Seconds", 15, timeout);
|
||||
fWait0 = _CreateWaitRadioButton(rect, "wait0", TR("Wait Indefinitely"),
|
||||
-1, timeout);
|
||||
fWait5 = _CreateWaitRadioButton(rect, "wait5", TR("Wait 5 Seconds"),
|
||||
5, timeout);
|
||||
fWait10 = _CreateWaitRadioButton(rect, "wait10", TR("Wait 10 Seconds"),
|
||||
10, timeout);
|
||||
fWait15 = _CreateWaitRadioButton(rect, "wait15", TR("Wait 15 Seconds"),
|
||||
15, timeout);
|
||||
|
||||
_Layout();
|
||||
}
|
||||
|
@ -131,7 +141,7 @@ DefaultPartitionPage::_CreatePopUpMenu()
|
|||
BMenuItem* selectedItem = NULL;
|
||||
int32 selectedItemIndex = 0;
|
||||
|
||||
BPopUpMenu* menu = new BPopUpMenu("Partitions");
|
||||
BPopUpMenu* menu = new BPopUpMenu(TR("Partitions"));
|
||||
BMessage message;
|
||||
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) {
|
||||
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
#include "EntryPage.h"
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "EntryPage"
|
||||
|
||||
|
||||
EntryPage::EntryPage(BMessage* settings, BRect frame, const char* name)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
|
@ -59,12 +63,14 @@ EntryPage::_BuildUI()
|
|||
BRect textRect(rect);
|
||||
textRect.left = fInstall->Frame().right + kTextDistance;
|
||||
|
||||
fInstallText = CreateDescription(textRect, "installText",
|
||||
"Install boot menu\n\n"
|
||||
"Choose this option to install a boot menu, "
|
||||
BString text;
|
||||
text <<
|
||||
TR("Install boot menu") << "\n\n" <<
|
||||
TR("Choose this option to install a boot menu, "
|
||||
"allowing you to select which operating "
|
||||
"system to boot when you turn on your "
|
||||
"computer.\n");
|
||||
"computer.") << "\n";
|
||||
fInstallText = CreateDescription(textRect, "installText", text);
|
||||
MakeHeading(fInstallText);
|
||||
AddChild(fInstallText);
|
||||
|
||||
|
@ -74,11 +80,14 @@ EntryPage::_BuildUI()
|
|||
AddChild(fUninstall);
|
||||
fUninstall->ResizeToPreferred();
|
||||
|
||||
fUninstallText = CreateDescription(textRect, "uninstallText",
|
||||
"Uninstall boot menu\n\n"
|
||||
"Choose this option to remove the boot menu "
|
||||
"previously installed by this program.\n"
|
||||
);
|
||||
text.Truncate(0);
|
||||
text <<
|
||||
TR("Install boot menu") << "\n\n" <<
|
||||
TR("Choose this option to install a boot menu, "
|
||||
"allowing you to select which operating "
|
||||
"system to boot when you turn on your "
|
||||
"computer.") << "\n";
|
||||
fUninstallText = CreateDescription(textRect, "uninstallText", text);
|
||||
MakeHeading(fUninstallText);
|
||||
AddChild(fUninstallText);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
|
||||
#include <Button.h>
|
||||
#include <Catalog.h>
|
||||
#include <Path.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextControl.h>
|
||||
|
@ -20,6 +21,9 @@
|
|||
#include <String.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "FileSelectionPage"
|
||||
|
||||
|
||||
const uint32 kMsgOpenFilePanel = 'open';
|
||||
|
||||
|
||||
|
@ -98,11 +102,13 @@ FileSelectionPage::_BuildUI(const char* description)
|
|||
fSettings->FindString("file", &file);
|
||||
|
||||
// TODO align text and button
|
||||
fFile = new BTextControl(rect, "file", "File:", file.String(), new BMessage());
|
||||
fFile = new BTextControl(rect, "file", TR("File:"), file.String(),
|
||||
new BMessage());
|
||||
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
|
||||
AddChild(fFile);
|
||||
|
||||
fSelect = new BButton(rect, "select", "Select", new BMessage(kMsgOpenFilePanel),
|
||||
fSelect = new BButton(rect, "select", TR("Select"),
|
||||
new BMessage(kMsgOpenFilePanel),
|
||||
B_FOLLOW_RIGHT);
|
||||
fSelect->ResizeToPreferred();
|
||||
float left = rect.right - fSelect->Frame().Width();
|
||||
|
|
|
@ -18,6 +18,30 @@ Application bootman :
|
|||
WizardController.cpp
|
||||
WizardPageView.cpp
|
||||
WizardView.cpp
|
||||
: be tracker $(TARGET_LIBSUPC++)
|
||||
: bootman.rdef
|
||||
:
|
||||
be
|
||||
textencoding
|
||||
tracker
|
||||
liblocale.so
|
||||
$(TARGET_LIBSUPC++)
|
||||
:
|
||||
bootman.rdef
|
||||
;
|
||||
|
||||
DoCatalogs bootman :
|
||||
x-vnd.Haiku-bootman
|
||||
:
|
||||
BootManager.cpp
|
||||
BootManagerController.cpp
|
||||
BootManagerWindow.cpp
|
||||
DefaultPartitionPage.cpp
|
||||
EntryPage.cpp
|
||||
FileSelectionPage.cpp
|
||||
LegacyBootDrive.cpp
|
||||
PartitionsPage.cpp
|
||||
UninstallPage.cpp
|
||||
WizardView.cpp
|
||||
:
|
||||
en.catalog
|
||||
:
|
||||
;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "LegacyBootDrive.h"
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Drivers.h>
|
||||
#include <DiskDevice.h>
|
||||
#include <DiskDeviceRoster.h>
|
||||
|
@ -20,6 +21,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <memory>
|
||||
#include <new>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -30,10 +32,12 @@
|
|||
#include <DataIO.h>
|
||||
#include <File.h>
|
||||
#include <String.h>
|
||||
#include <UTF8.h>
|
||||
|
||||
#include "BootLoader.h"
|
||||
|
||||
|
||||
#define TR_CONTEXT "LegacyBootDrive"
|
||||
#define USE_SECOND_DISK 0
|
||||
#define GET_FIRST_BIOS_DRIVE 1
|
||||
|
||||
|
@ -62,15 +66,18 @@ Buffer::WriteInt8(int8 value)
|
|||
bool
|
||||
Buffer::WriteInt16(int16 value)
|
||||
{
|
||||
return WriteInt8(value & 0xff) && WriteInt8(value >> 8);
|
||||
return WriteInt8(value & 0xff)
|
||||
&& WriteInt8(value >> 8);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Buffer::WriteInt32(int32 value)
|
||||
{
|
||||
return WriteInt8(value & 0xff) && WriteInt8(value >> 8) &&
|
||||
WriteInt8(value >> 16) && WriteInt8(value >> 24);
|
||||
return WriteInt8(value & 0xff)
|
||||
&& WriteInt8(value >> 8)
|
||||
&& WriteInt8(value >> 16)
|
||||
&& WriteInt8(value >> 24);
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,7 +92,8 @@ bool
|
|||
Buffer::WriteString(const char* value)
|
||||
{
|
||||
int len = strlen(value) + 1;
|
||||
return WriteInt8(len) && Write(value, len) == len;
|
||||
return WriteInt8(len)
|
||||
&& Write(value, len) == len;
|
||||
}
|
||||
|
||||
|
||||
|
@ -180,13 +188,18 @@ PartitionRecorder::_Record(BPartition* partition)
|
|||
const char* name = partition->ContentName();
|
||||
if (name == NULL) {
|
||||
fIndex ++;
|
||||
buffer << "Unnamed " << fIndex;
|
||||
BString number;
|
||||
number << fIndex;
|
||||
buffer << TR_CMT("Unnamed %d",
|
||||
"Default name of a partition whose name could not be read from "
|
||||
"disk");
|
||||
buffer.ReplaceFirst("%d", number);
|
||||
name = buffer.String();
|
||||
}
|
||||
|
||||
const char* type = partition->Type();
|
||||
if (type == NULL)
|
||||
type = "Unknown";
|
||||
type = TR("Unknown");
|
||||
|
||||
BMessage message;
|
||||
// Data as required by BootLoader.h
|
||||
|
@ -280,10 +293,6 @@ LegacyBootDrive::ReadPartitions(BMessage *settings)
|
|||
status_t
|
||||
LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
||||
{
|
||||
printf("WriteBootMenu:\n");
|
||||
// TODO fix crash since AddInt8("drive", ...)
|
||||
// settings->PrintToStream();
|
||||
|
||||
BString path;
|
||||
if (settings->FindString("disk", &path) != B_OK)
|
||||
return B_BAD_VALUE;
|
||||
|
@ -355,7 +364,10 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
|
|||
if (!show)
|
||||
continue;
|
||||
|
||||
newBootLoader.WriteString(name.String());
|
||||
BString biosName;
|
||||
_ConvertToBIOSText(name.String(), biosName);
|
||||
|
||||
newBootLoader.WriteString(biosName.String());
|
||||
newBootLoader.WriteInt8(drive);
|
||||
newBootLoader.WriteInt64(offset / kBlockSize);
|
||||
}
|
||||
|
@ -466,6 +478,62 @@ LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
|
|||
}
|
||||
|
||||
|
||||
status_t
|
||||
LegacyBootDrive::GetDisplayText(const char* text, BString& displayText)
|
||||
{
|
||||
BString biosText;
|
||||
if (!_ConvertToBIOSText(text, biosText)) {
|
||||
displayText = "???";
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
// convert back to UTF-8
|
||||
int32 biosTextLength = biosText.Length();
|
||||
int32 bufferLength = strlen(text);
|
||||
char* buffer = displayText.LockBuffer(bufferLength + 1);
|
||||
int32 state = 0;
|
||||
if (convert_to_utf8(B_MS_DOS_CONVERSION,
|
||||
biosText.String(), &biosTextLength,
|
||||
buffer, &bufferLength, &state) != B_OK) {
|
||||
displayText.UnlockBuffer(0);
|
||||
displayText = "???";
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
buffer[bufferLength] = '\0';
|
||||
bufferLength ++;
|
||||
displayText.UnlockBuffer(bufferLength);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LegacyBootDrive::_ConvertToBIOSText(const char* text, BString& biosText)
|
||||
{
|
||||
// convert text in UTF-8 to 'code page 437'
|
||||
int32 textLength = strlen(text);
|
||||
|
||||
int32 biosTextLength = textLength;
|
||||
char* buffer = biosText.LockBuffer(biosTextLength + 1);
|
||||
if (buffer == NULL) {
|
||||
biosText.UnlockBuffer(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
int32 state = 0;
|
||||
if (convert_from_utf8(B_MS_DOS_CONVERSION, text, &textLength,
|
||||
buffer, &biosTextLength, &state) != B_OK) {
|
||||
biosText.UnlockBuffer(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
buffer[biosTextLength] = '\0';
|
||||
biosTextLength ++;
|
||||
biosText.UnlockBuffer(biosTextLength);
|
||||
return biosTextLength <= kMaxBootMenuItemLength;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LegacyBootDrive::_GetBiosDrive(const char* device, int8* drive)
|
||||
{
|
||||
|
@ -487,7 +555,8 @@ status_t
|
|||
LegacyBootDrive::_ReadBlocks(int fd, uint8* buffer, size_t size)
|
||||
{
|
||||
if (size % kBlockSize != 0) {
|
||||
fprintf(stderr, "_ReadBlocks buffer size must be a multiple of %d\n", (int)kBlockSize);
|
||||
fprintf(stderr, "_ReadBlocks buffer size must be a multiple of %d\n",
|
||||
(int)kBlockSize);
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
const size_t blocks = size / kBlockSize;
|
||||
|
@ -504,7 +573,8 @@ status_t
|
|||
LegacyBootDrive::_WriteBlocks(int fd, const uint8* buffer, size_t size)
|
||||
{
|
||||
if (size % kBlockSize != 0) {
|
||||
fprintf(stderr, "_WriteBlocks buffer size must be a multiple of %d\n", (int)kBlockSize);
|
||||
fprintf(stderr, "_WriteBlocks buffer size must be a multiple of %d\n",
|
||||
(int)kBlockSize);
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
const size_t blocks = size / kBlockSize;
|
||||
|
@ -522,7 +592,8 @@ LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination,
|
|||
const MasterBootRecord* source)
|
||||
{
|
||||
memcpy(destination->diskSignature, source->diskSignature,
|
||||
sizeof(source->diskSignature) + sizeof(source->reserved) + sizeof(source->partition));
|
||||
sizeof(source->diskSignature) + sizeof(source->reserved) +
|
||||
sizeof(source->partition));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ const uint32 kBlockSize = 512;
|
|||
const uint32 kNumberOfBootLoaderBlocks = 4;
|
||||
|
||||
const uint32 kMBRSignature = 0xAA55;
|
||||
|
||||
const int32 kMaxBootMenuItemLength = 70;
|
||||
|
||||
typedef struct {
|
||||
uint8 bootLoader[440];
|
||||
|
@ -31,15 +33,17 @@ class LegacyBootDrive : public BootDrive
|
|||
{
|
||||
public:
|
||||
LegacyBootDrive();
|
||||
virtual ~LegacyBootDrive();
|
||||
~LegacyBootDrive();
|
||||
|
||||
virtual bool IsBootMenuInstalled(BMessage* settings);
|
||||
virtual status_t ReadPartitions(BMessage* settings);
|
||||
virtual status_t WriteBootMenu(BMessage* settings);
|
||||
virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
|
||||
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
|
||||
bool IsBootMenuInstalled(BMessage* settings);
|
||||
status_t ReadPartitions(BMessage* settings);
|
||||
status_t WriteBootMenu(BMessage* settings);
|
||||
status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t GetDisplayText(const char* text, BString& displayText);
|
||||
|
||||
private:
|
||||
bool _ConvertToBIOSText(const char* text, BString& biosText);
|
||||
bool _GetBiosDrive(const char* device, int8* drive);
|
||||
status_t _ReadBlocks(int fd, uint8* buffer, size_t size);
|
||||
status_t _WriteBlocks(int fd, const uint8* buffer, size_t size);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "PartitionsPage.h"
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <CheckBox.h>
|
||||
#include <RadioButton.h>
|
||||
#include <ScrollView.h>
|
||||
|
@ -23,6 +24,9 @@
|
|||
#include <String.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "PartitionsPage"
|
||||
|
||||
|
||||
const uint32 kMessageShow = 'show';
|
||||
const uint32 kMessageName = 'name';
|
||||
|
||||
|
@ -92,14 +96,15 @@ PartitionsPage::_BuildUI()
|
|||
{
|
||||
BRect rect(Bounds());
|
||||
|
||||
fDescription = CreateDescription(rect, "description",
|
||||
"Partitions\n\n"
|
||||
"The following partitions were detected. Please "
|
||||
BString text;
|
||||
text <<
|
||||
TR("Partitions") << "\n\n" <<
|
||||
TR("The following partitions were detected. Please "
|
||||
"check the box next to the partitions to be included "
|
||||
"in the boot menu. You can also set the names of the "
|
||||
"partitions as you would like them to appear in the "
|
||||
"boot menu."
|
||||
);
|
||||
"boot menu.");
|
||||
fDescription = CreateDescription(rect, "description", text);
|
||||
MakeHeading(fDescription);
|
||||
AddChild(fDescription);
|
||||
LayoutDescriptionVertically(fDescription);
|
||||
|
@ -302,9 +307,6 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
|
|||
}
|
||||
|
||||
|
||||
static const char kPrefix[] = " KMGTPE";
|
||||
|
||||
|
||||
void
|
||||
PartitionsPage::_CreateSizeText(int64 _size, BString* text)
|
||||
{
|
||||
|
|
|
@ -107,5 +107,10 @@ TestBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
|
|||
}
|
||||
|
||||
|
||||
status_t
|
||||
TestBootDrive::GetDisplayText(const char* text, BString& displayText)
|
||||
{
|
||||
displayText = text;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -14,13 +14,14 @@ class TestBootDrive : public BootDrive
|
|||
{
|
||||
public:
|
||||
TestBootDrive();
|
||||
virtual ~TestBootDrive();
|
||||
~TestBootDrive();
|
||||
|
||||
virtual bool IsBootMenuInstalled(BMessage* settings);
|
||||
virtual status_t ReadPartitions(BMessage* settings);
|
||||
virtual status_t WriteBootMenu(BMessage* settings);
|
||||
virtual status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
|
||||
virtual status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
|
||||
bool IsBootMenuInstalled(BMessage* settings);
|
||||
status_t ReadPartitions(BMessage* settings);
|
||||
status_t WriteBootMenu(BMessage* settings);
|
||||
status_t SaveMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t RestoreMasterBootRecord(BMessage* settings, BFile* file);
|
||||
status_t GetDisplayText(const char* text, BString& displayText);
|
||||
};
|
||||
|
||||
#endif // TEST_BOOT_DRIVE_H
|
||||
|
|
|
@ -10,12 +10,16 @@
|
|||
#include "UninstallPage.h"
|
||||
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <RadioButton.h>
|
||||
#include <TextView.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "UninstallPage"
|
||||
|
||||
|
||||
UninstallPage::UninstallPage(BMessage* settings, BRect frame, const char* name)
|
||||
: WizardPageView(settings, frame, name, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
|
||||
|
@ -44,11 +48,13 @@ UninstallPage::_BuildUI()
|
|||
{
|
||||
BRect rect(Bounds());
|
||||
|
||||
fDescription = CreateDescription(rect, "description",
|
||||
"Uninstall Boot Manager\n\n"
|
||||
"Please locate the Master Boot Record (MBR) save file to "
|
||||
BString text;
|
||||
text <<
|
||||
TR("Uninstall Boot Manager") << "\n\n" <<
|
||||
TR("Please locate the Master Boot Record (MBR) save file to "
|
||||
"restore from. This is the file that was created when the "
|
||||
"boot manager was first installed.");
|
||||
fDescription = CreateDescription(rect, "description", text);
|
||||
|
||||
MakeHeading(fDescription);
|
||||
AddChild(fDescription);
|
||||
|
|
|
@ -21,7 +21,7 @@ WizardController::StateStack::MakeEmpty()
|
|||
next = stack->Next();
|
||||
delete stack;
|
||||
stack = next;
|
||||
} while (next != NULL);
|
||||
} while (next != NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,11 @@
|
|||
#include "WizardPageView.h"
|
||||
|
||||
#include <Box.h>
|
||||
#include <Catalog.h>
|
||||
|
||||
|
||||
#define TR_CONTEXT "WizardView"
|
||||
|
||||
|
||||
static const float kSeparatorHeight = 2;
|
||||
static const float kSeparatorDistance = 5;
|
||||
|
@ -138,13 +143,13 @@ WizardView::_BuildUI()
|
|||
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
|
||||
AddChild(fSeparator);
|
||||
|
||||
fPrevious = new BButton(BRect(0, 0, 100, 20), "previous", "Previous",
|
||||
fPrevious = new BButton(BRect(0, 0, 100, 20), "previous", TR("Previous"),
|
||||
new BMessage(kMessagePrevious),
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
AddChild(fPrevious);
|
||||
fPrevious->ResizeToPreferred();
|
||||
|
||||
fNext = new BButton(BRect(0, 0, 100, 20), "next", "Next",
|
||||
fNext = new BButton(BRect(0, 0, 100, 20), "next", TR("Next"),
|
||||
new BMessage(kMessageNext),
|
||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
AddChild(fNext);
|
||||
|
|
Loading…
Reference in New Issue