Updated to use B_TRANSLATE* macros. relates to #5408.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36663 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Matt Madia
2010-05-06 16:11:12 +00:00
parent 4e689749d8
commit 04bcc0b403
10 changed files with 219 additions and 207 deletions
+9 -7
View File
@@ -1,12 +1,12 @@
/* /*
* Copyright 2008-2009, Haiku, Inc. All rights reserved. * Copyright 2008-2009, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
* Axel Dörfler <[email protected]> * Axel Dörfler <[email protected]>
*/ */
#include "BootManagerWindow.h" #include "BootManagerWindow.h"
#include <Alert.h> #include <Alert.h>
@@ -55,17 +55,19 @@ void
BootManager::AboutRequested() BootManager::AboutRequested()
{ {
BString aboutText; BString aboutText;
const char* title = TR_CMT("Haiku Boot Manager", "About text title"); const char* title = B_TRANSLATE_COMMENT("Haiku Boot Manager",
"About text title");
aboutText << aboutText <<
title << "\n\n" << title << "\n\n" <<
TR("written by") << "\n" B_TRANSLATE("written by") << "\n"
"\tDavid Dengg\n" "\tDavid Dengg\n"
"\tMichael Pfeiffer\n" "\tMichael Pfeiffer\n"
"\n" << "\n" <<
TR_CMT("Copyright %year, Haiku Inc.\n", "Leave %year untranslated"); B_TRANSLATE_COMMENT("Copyright %year, Haiku Inc.\n",
"Leave %year untranslated");
aboutText.ReplaceLast("%year", "2008-2010"); aboutText.ReplaceLast("%year", "2008-2010");
BAlert *alert = new BAlert("about", BAlert *alert = new BAlert("about",
aboutText.String(), TR("OK")); aboutText.String(), B_TRANSLATE("OK"));
BTextView *view = alert->TextView(); BTextView *view = alert->TextView();
BFont font; BFont font;
+28 -24
View File
@@ -155,8 +155,8 @@ BootManagerController::_HasSelectedPartitions()
} }
BAlert* alert = new BAlert("info", BAlert* alert = new BAlert("info",
TR("At least one partition must be selected!"), B_TRANSLATE("At least one partition must be selected!"),
TR_CMT("OK", "Button")); B_TRANSLATE_COMMENT("OK", "Button"));
alert->Go(); alert->Go();
return false; return false;
@@ -166,10 +166,10 @@ BootManagerController::_HasSelectedPartitions()
bool bool
BootManagerController::_WriteBootMenu() BootManagerController::_WriteBootMenu()
{ {
BAlert* alert = new BAlert("confirm", TR("About to write the boot menu " BAlert* alert = new BAlert("confirm", B_TRANSLATE("About to write the "
"to disk. Are you sure you want to continue?"), "boot menu to disk. Are you sure you want to continue?"),
TR_CMT("Write boot menu", "Button"), B_TRANSLATE_COMMENT("Write boot menu", "Button"),
TR_CMT("Back", "Button"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE_COMMENT("Back", "Button"), NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
if (alert->Go() == 1) if (alert->Go() == 1)
return false; return false;
@@ -199,15 +199,15 @@ BootManagerController::_RestoreMBR()
fSettings.FindString("file", &path); fSettings.FindString("file", &path);
BString message; BString message;
message << TR_CMT("About to restore the Master Boot Record (MBR) of" message << B_TRANSLATE_COMMENT("About to restore the Master Boot Record "
" %disk from %file. Do you wish to continue?", "(MBR) of %disk from %file. Do you wish to continue?",
"Don't translate the place holders: %disk and %file"); "Don't translate the place holders: %disk and %file");
message.ReplaceFirst("%disk", disk); message.ReplaceFirst("%disk", disk);
message.ReplaceFirst("%file", path); message.ReplaceFirst("%file", path);
BAlert* alert = new BAlert("confirm", message.String(), BAlert* alert = new BAlert("confirm", message.String(),
TR_CMT("Restore MBR", "Button"), B_TRANSLATE_COMMENT("Restore MBR", "Button"),
TR_CMT("Back", "Button"), B_TRANSLATE_COMMENT("Back", "Button"),
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT);
if (alert->Go() == 1) if (alert->Go() == 1)
return false; return false;
@@ -232,7 +232,7 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
case kStateErrorEntry: case kStateErrorEntry:
page = _CreateErrorEntryPage(frame); page = _CreateErrorEntryPage(frame);
wizard->SetPreviousButtonHidden(true); wizard->SetPreviousButtonHidden(true);
wizard->SetNextButtonLabel(TR_CMT("Done", "Button")); wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Done", "Button"));
break; break;
case kStateSaveMBR: case kStateSaveMBR:
page = _CreateSaveMBRPage(frame); page = _CreateSaveMBRPage(frame);
@@ -250,21 +250,21 @@ BootManagerController::CreatePage(int32 state, WizardView* wizard)
break; break;
case kStateInstallSummary: case kStateInstallSummary:
page = _CreateInstallSummaryPage(frame); page = _CreateInstallSummaryPage(frame);
wizard->SetNextButtonLabel(TR_CMT("Next", "Button")); wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Next", "Button"));
break; break;
case kStateInstalled: case kStateInstalled:
page = _CreateInstalledPage(frame); page = _CreateInstalledPage(frame);
wizard->SetNextButtonLabel(TR_CMT("Done", "Button")); wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Done", "Button"));
break; break;
case kStateUninstall: case kStateUninstall:
page = _CreateUninstallPage(frame); page = _CreateUninstallPage(frame);
wizard->SetPreviousButtonHidden(false); wizard->SetPreviousButtonHidden(false);
wizard->SetNextButtonLabel(TR_CMT("Next", "Button")); 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"
page = _CreateUninstalledPage(frame); page = _CreateUninstalledPage(frame);
wizard->SetNextButtonLabel(TR_CMT("Done", "Button")); wizard->SetNextButtonLabel(B_TRANSLATE_COMMENT("Done", "Button"));
break; break;
} }
@@ -279,15 +279,17 @@ BootManagerController::_CreateErrorEntryPage(BRect frame)
if (fReadPartitionsStatus == kErrorBootSectorTooSmall) if (fReadPartitionsStatus == kErrorBootSectorTooSmall)
description << description <<
TR_CMT("Partition table not compatible", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Partition table not compatible", "Title") <<
TR("The partition table of the first hard disk is not compatible " "\n\n" <<
"with Boot Manager.\n" B_TRANSLATE("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 " "Boot Manager needs 2 KB available space before the first "
"partition."); "partition.");
else else
description << description <<
TR_CMT("Error reading partition table", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Error reading partition table", "Title") <<
TR("Boot Manager is unable to read the partition table!"); "\n\n" <<
B_TRANSLATE("Boot Manager is unable to read the partition table!");
return new DescriptionPage(frame, "errorEntry", description.String(), true); return new DescriptionPage(frame, "errorEntry", description.String(), true);
} }
@@ -301,8 +303,8 @@ BootManagerController::_CreateSaveMBRPage(BRect frame)
fSettings.FindString("disk", &disk); fSettings.FindString("disk", &disk);
description << description <<
TR_CMT("Backup Master Boot Record", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Backup Master Boot Record", "Title") << "\n\n" <<
TR("The Master Boot Record (MBR) of the boot device:\n" B_TRANSLATE("The Master Boot Record (MBR) of the boot device:\n"
"\t%s\n" "\t%s\n"
"will now be saved to disk. Please select a file to " "will now be saved to disk. Please select a file to "
"save the MBR into.\n\n" "save the MBR into.\n\n"
@@ -326,8 +328,10 @@ BootManagerController::_CreateMBRSavedPage(BRect frame)
if (fSaveMBRStatus == B_OK) { if (fSaveMBRStatus == B_OK) {
description << description <<
TR_CMT("Old Master Boot Record saved", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Old Master Boot Record saved", "Title") <<
TR("The old Master Boot Record was successfully save to %s.") << "\n\n" <<
B_TRANSLATE("The old Master Boot Record was successfully save to "
"%s.") <<
"\n"; "\n";
} else { } else {
description << description <<
+10 -9
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
*/ */
@@ -32,19 +32,20 @@
BootManagerWindow::BootManagerWindow() BootManagerWindow::BootManagerWindow()
: :
BWindow(BRect(100, 100, 500, 400), TR_CMT("Boot Manager", "Window Title"), BWindow(BRect(100, 100, 500, 400), B_TRANSLATE_COMMENT("Boot Manager",
"Window Title"),
B_TITLED_WINDOW, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE) B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE)
{ {
float minWidth, maxWidth, minHeight, maxHeight; float minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight); GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
SetSizeLimits(250, maxWidth, 250, maxHeight); SetSizeLimits(250, maxWidth, 250, maxHeight);
fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL); fWizardView = new WizardView(Bounds(), "wizard", B_FOLLOW_ALL);
AddChild(fWizardView); AddChild(fWizardView);
fController.Initialize(fWizardView); fController.Initialize(fWizardView);
AddShortcut('A', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED)); AddShortcut('A', B_COMMAND_KEY, new BMessage(B_ABOUT_REQUESTED));
CenterOnScreen(); CenterOnScreen();
@@ -68,18 +69,18 @@ BootManagerWindow::MessageReceived(BMessage* msg)
case kMessageNext: case kMessageNext:
fController.Next(fWizardView); fController.Next(fWizardView);
break; break;
case kMessagePrevious: case kMessagePrevious:
fController.Previous(fWizardView); fController.Previous(fWizardView);
break; break;
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
be_app_messenger.SendMessage(B_ABOUT_REQUESTED); be_app_messenger.SendMessage(B_ABOUT_REQUESTED);
break; break;
default: default:
BWindow::MessageReceived(msg); BWindow::MessageReceived(msg);
} }
} }
+30 -28
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
*/ */
@@ -45,14 +45,14 @@ typedef struct {
static const TimeoutOption gTimeoutOptions[] = static const TimeoutOption gTimeoutOptions[] =
{ {
{ 0, TR_MARK("Immediately")}, { 0, B_TRANSLATE_MARK("Immediately")},
{ 1, TR_MARK("After one second")}, { 1, B_TRANSLATE_MARK("After one second")},
{ 2, TR_MARK("After two seconds")}, { 2, B_TRANSLATE_MARK("After two seconds")},
{ 3, TR_MARK("After three seconds")}, { 3, B_TRANSLATE_MARK("After three seconds")},
{ 4, TR_MARK("After four seconds")}, { 4, B_TRANSLATE_MARK("After four seconds")},
{ 5, TR_MARK("After five seconds")}, { 5, B_TRANSLATE_MARK("After five seconds")},
{ 60, TR_MARK("After one minute")}, { 60, B_TRANSLATE_MARK("After one minute")},
{ kTimeoutIndefinitely, TR_MARK("Never")} { kTimeoutIndefinitely, B_TRANSLATE_MARK("Never")}
}; };
@@ -95,7 +95,7 @@ get_label_for_timeout(int32 timeout)
DefaultPartitionPage::DefaultPartitionPage(BMessage* settings, BRect frame, const char* name) DefaultPartitionPage::DefaultPartitionPage(BMessage* settings, BRect frame, const char* name)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, : WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
{ {
_BuildUI(); _BuildUI();
@@ -157,11 +157,11 @@ void
DefaultPartitionPage::_BuildUI() DefaultPartitionPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
BString text; BString text;
text << text <<
TR_CMT("Default Partition", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Default Partition", "Title") << "\n\n" <<
TR("Please specify a default partition and a timeout.\n" B_TRANSLATE("Please specify a default partition and a timeout.\n"
"The boot menu will load the default partition after " "The boot menu will load the default partition after "
"the timeout unless you select another partition. You " "the timeout unless you select another partition. You "
"can also have the boot menu wait indefinitely for you " "can also have the boot menu wait indefinitely for you "
@@ -173,15 +173,16 @@ DefaultPartitionPage::_BuildUI()
AddChild(fDescription); AddChild(fDescription);
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
rect.top = fDescription->Frame().bottom + kTextDistance; rect.top = fDescription->Frame().bottom + kTextDistance;
BPopUpMenu* popUpMenu = _CreatePopUpMenu(); BPopUpMenu* popUpMenu = _CreatePopUpMenu();
fDefaultPartition = new BMenuField(rect, "partitions", fDefaultPartition = new BMenuField(rect, "partitions",
TR_CMT("Default Partition:", "Menu field label"), popUpMenu); B_TRANSLATE_COMMENT("Default Partition:", "Menu field label"),
popUpMenu);
float divider = be_plain_font->StringWidth(fDefaultPartition->Label()) + 3; float divider = be_plain_font->StringWidth(fDefaultPartition->Label()) + 3;
fDefaultPartition->SetDivider(divider); fDefaultPartition->SetDivider(divider);
AddChild(fDefaultPartition); AddChild(fDefaultPartition);
fDefaultPartition->ResizeToPreferred(); fDefaultPartition->ResizeToPreferred();
// timeout slider // timeout slider
rect.top = fDefaultPartition->Frame().bottom + kTextDistance; rect.top = fDefaultPartition->Frame().bottom + kTextDistance;
int32 timeout; int32 timeout;
@@ -197,12 +198,13 @@ DefaultPartitionPage::_BuildUI()
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fTimeoutSlider->SetModificationMessage(new BMessage(kMsgTimeout)); fTimeoutSlider->SetModificationMessage(new BMessage(kMsgTimeout));
fTimeoutSlider->SetValue(sliderValue); fTimeoutSlider->SetValue(sliderValue);
fTimeoutSlider->SetLimitLabels(TR("Immediately"),TR("Never")); fTimeoutSlider->SetLimitLabels(B_TRANSLATE("Immediately"),
B_TRANSLATE("Never"));
fTimeoutSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fTimeoutSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fTimeoutSlider->SetHashMarkCount(kNumberOfTimeoutOptions); fTimeoutSlider->SetHashMarkCount(kNumberOfTimeoutOptions);
fTimeoutSlider->ResizeToPreferred(); fTimeoutSlider->ResizeToPreferred();
AddChild(fTimeoutSlider); AddChild(fTimeoutSlider);
_Layout(); _Layout();
} }
@@ -212,20 +214,20 @@ DefaultPartitionPage::_CreatePopUpMenu()
{ {
int32 defaultPartitionIndex; int32 defaultPartitionIndex;
fSettings->FindInt32("defaultPartition", &defaultPartitionIndex); fSettings->FindInt32("defaultPartition", &defaultPartitionIndex);
BMenuItem* selectedItem = NULL; BMenuItem* selectedItem = NULL;
int32 selectedItemIndex = 0; int32 selectedItemIndex = 0;
BPopUpMenu* menu = new BPopUpMenu(TR_CMT("Partitions", BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE_COMMENT("Partitions",
"Pop up menu title")); "Pop up menu title"));
BMessage message; BMessage message;
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
i ++) { i ++) {
bool show; bool show;
if (message.FindBool("show", &show) != B_OK || !show) if (message.FindBool("show", &show) != B_OK || !show)
continue; continue;
BString name; BString name;
message.FindString("name", &name); message.FindString("name", &name);
@@ -247,8 +249,8 @@ DefaultPartitionPage::_CreatePopUpMenu()
void void
DefaultPartitionPage::_GetTimeoutLabel(int32 timeout, BString& label) DefaultPartitionPage::_GetTimeoutLabel(int32 timeout, BString& label)
{ {
const char* text = TR(get_label_for_timeout(timeout)); const char* text = B_TRANSLATE(get_label_for_timeout(timeout));
label = TR("Timeout: %s"); label = B_TRANSLATE("Timeout: %s");
label.ReplaceFirst("%s", text); label.ReplaceFirst("%s", text);
} }
@@ -257,10 +259,10 @@ void
DefaultPartitionPage::_Layout() DefaultPartitionPage::_Layout()
{ {
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
float left = fDefaultPartition->Frame().left; float left = fDefaultPartition->Frame().left;
float top = fDescription->Frame().bottom + kTextDistance; float top = fDescription->Frame().bottom + kTextDistance;
fDefaultPartition->MoveTo(left, top); fDefaultPartition->MoveTo(left, top);
top = fDefaultPartition->Frame().bottom + kTextDistance; top = fDefaultPartition->Frame().bottom + kTextDistance;
+4 -4
View File
@@ -66,8 +66,8 @@ EntryPage::_BuildUI()
BString text; BString text;
text << text <<
TR_CMT("Install boot menu", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Install boot menu", "Title") << "\n\n" <<
TR("Choose this option to install a boot menu, " B_TRANSLATE("Choose this option to install a boot menu, "
"allowing you to select which operating " "allowing you to select which operating "
"system to boot when you turn on your " "system to boot when you turn on your "
"computer.") << "\n"; "computer.") << "\n";
@@ -83,8 +83,8 @@ EntryPage::_BuildUI()
text.Truncate(0); text.Truncate(0);
text << text <<
TR_CMT("Uninstall boot menu", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Uninstall boot menu", "Title") << "\n\n" <<
TR("Choose this option to remove the boot menu " B_TRANSLATE("Choose this option to remove the boot menu "
"previously installed by this program.\n"); "previously installed by this program.\n");
fUninstallText = CreateDescription(textRect, "uninstallText", text); fUninstallText = CreateDescription(textRect, "uninstallText", text);
MakeHeading(fUninstallText); MakeHeading(fUninstallText);
+16 -15
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
*/ */
@@ -30,7 +30,7 @@ const uint32 kMsgOpenFilePanel = 'open';
FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame, const char* name, FileSelectionPage::FileSelectionPage(BMessage* settings, BRect frame, const char* name,
const char* description, file_panel_mode mode) const char* description, file_panel_mode mode)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, : WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
, fMode(mode) , fMode(mode)
, fFilePanel(NULL) , fFilePanel(NULL)
@@ -93,16 +93,17 @@ void
FileSelectionPage::_BuildUI(const char* description) FileSelectionPage::_BuildUI(const char* description)
{ {
BRect rect(Bounds()); BRect rect(Bounds());
fDescription = CreateDescription(rect, "description", description); fDescription = CreateDescription(rect, "description", description);
MakeHeading(fDescription); MakeHeading(fDescription);
AddChild(fDescription); AddChild(fDescription);
BString file; BString file;
fSettings->FindString("file", &file); fSettings->FindString("file", &file);
fSelect = new BButton(rect, "select", TR_CMT("Select", "Button"), fSelect = new BButton(rect, "select",
B_TRANSLATE_COMMENT("Select", "Button"),
new BMessage(kMsgOpenFilePanel), new BMessage(kMsgOpenFilePanel),
B_FOLLOW_RIGHT); B_FOLLOW_RIGHT);
fSelect->ResizeToPreferred(); fSelect->ResizeToPreferred();
@@ -110,14 +111,14 @@ FileSelectionPage::_BuildUI(const char* description)
float selectLeft = rect.right - fSelect->Bounds().Width(); float selectLeft = rect.right - fSelect->Bounds().Width();
rect.right = selectLeft - kFileButtonDistance; rect.right = selectLeft - kFileButtonDistance;
fFile = new BTextControl(rect, "file", fFile = new BTextControl(rect, "file",
TR_CMT("File:", "Text control label"), B_TRANSLATE_COMMENT("File:", "Text control label"),
file.String(), new BMessage()); file.String(), new BMessage());
fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5); fFile->SetDivider(be_plain_font->StringWidth(fFile->Label()) + 5);
AddChild(fFile); AddChild(fFile);
fSelect->MoveTo(selectLeft, 0); fSelect->MoveTo(selectLeft, 0);
AddChild(fSelect); AddChild(fSelect);
_Layout(); _Layout();
} }
@@ -126,7 +127,7 @@ void
FileSelectionPage::_Layout() FileSelectionPage::_Layout()
{ {
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
float left = fFile->Frame().left; float left = fFile->Frame().left;
float top = fDescription->Frame().bottom + kTextDistance; float top = fDescription->Frame().bottom + kTextDistance;
@@ -144,10 +145,10 @@ FileSelectionPage::_Layout()
} }
fFile->MoveTo(left, fileTop); fFile->MoveTo(left, fileTop);
float width = fSelect->Frame().left - kFileButtonDistance - left; float width = fSelect->Frame().left - kFileButtonDistance - left;
fFile->ResizeTo(width, fileHeight); fFile->ResizeTo(width, fileHeight);
left = fSelect->Frame().left; left = fSelect->Frame().left;
fSelect->MoveTo(left, selectTop); fSelect->MoveTo(left, selectTop);
} }
@@ -167,7 +168,7 @@ FileSelectionPage::_OpenFilePanel()
if (file.GetParent(&parent) == B_OK && if (file.GetParent(&parent) == B_OK &&
get_ref_for_path(parent.Path(), &base) == B_OK) get_ref_for_path(parent.Path(), &base) == B_OK)
directory = &base; directory = &base;
BMessenger messenger(this); BMessenger messenger(this);
fFilePanel = new BFilePanel(fMode, &messenger, directory, fFilePanel = new BFilePanel(fMode, &messenger, directory,
B_FILE_NODE, B_FILE_NODE,
@@ -198,7 +199,7 @@ FileSelectionPage::_SetFileFromFilePanelMessage(BMessage* message)
BEntry entry(&entryRef); BEntry entry(&entryRef);
BPath path; BPath path;
if (entry.GetPath(&path) == B_OK) if (entry.GetPath(&path) == B_OK)
fFile->SetText(path.Path()); fFile->SetText(path.Path());
} }
} }
+54 -53
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
*/ */
@@ -43,7 +43,7 @@
#define GET_FIRST_BIOS_DRIVE 1 #define GET_FIRST_BIOS_DRIVE 1
class Buffer : public BMallocIO class Buffer : public BMallocIO
{ {
public: public:
Buffer() : BMallocIO() {} Buffer() : BMallocIO() {}
@@ -58,7 +58,7 @@ public:
bool bool
Buffer::WriteInt8(int8 value) Buffer::WriteInt8(int8 value)
{ {
return Write(&value, sizeof(value)) == sizeof(value); return Write(&value, sizeof(value)) == sizeof(value);
} }
@@ -123,12 +123,12 @@ class PartitionRecorder : public BDiskDeviceVisitor
public: public:
PartitionRecorder(BMessage* settings, int8 drive); PartitionRecorder(BMessage* settings, int8 drive);
virtual bool Visit(BDiskDevice* device); virtual bool Visit(BDiskDevice* device);
virtual bool Visit(BPartition* partition, int32 level); virtual bool Visit(BPartition* partition, int32 level);
bool HasPartitions() const; bool HasPartitions() const;
off_t FirstOffset() const; off_t FirstOffset() const;
private: private:
bool _Record(BPartition* partition); bool _Record(BPartition* partition);
@@ -181,7 +181,7 @@ PartitionRecorder::_Record(BPartition* partition)
{ {
if (partition->ContainsPartitioningSystem()) if (partition->ContainsPartitioningSystem())
return false; return false;
BPath partitionPath; BPath partitionPath;
partition->GetPath(&partitionPath); partition->GetPath(&partitionPath);
@@ -191,17 +191,18 @@ PartitionRecorder::_Record(BPartition* partition)
fIndex ++; fIndex ++;
BString number; BString number;
number << fIndex; number << fIndex;
buffer << TR_CMT("Unnamed %d", buffer << B_TRANSLATE_COMMENT("Unnamed %d",
"Default name of a partition whose name could not be read from " "Default name of a partition whose name could not be read from "
"disk; characters in codepage 437 are allowed only"); "disk; characters in codepage 437 are allowed only");
buffer.ReplaceFirst("%d", number); buffer.ReplaceFirst("%d", number);
name = buffer.String(); name = buffer.String();
} }
const char* type = partition->Type(); const char* type = partition->Type();
if (type == NULL) if (type == NULL)
type = TR_CMT("Unknown", "Text is shown for an unknown partition type"); type = B_TRANSLATE_COMMENT("Unknown", "Text is shown for an unknown "
"partition type");
BMessage message; BMessage message;
// Data as required by BootLoader.h // Data as required by BootLoader.h
message.AddBool("show", true); message.AddBool("show", true);
@@ -209,16 +210,16 @@ PartitionRecorder::_Record(BPartition* partition)
message.AddString("type", type); message.AddString("type", type);
message.AddString("path", partitionPath.Path()); message.AddString("path", partitionPath.Path());
message.AddInt8("drive", fDrive); message.AddInt8("drive", fDrive);
message.AddInt64("size", partition->Size()); message.AddInt64("size", partition->Size());
// Specific data // Specific data
off_t offset = partition->Offset(); off_t offset = partition->Offset();
message.AddInt64("offset", offset); message.AddInt64("offset", offset);
fSettings->AddMessage("partition", &message); fSettings->AddMessage("partition", &message);
if (offset < fFirstOffset) if (offset < fFirstOffset)
fFirstOffset = offset; fFirstOffset = offset;
return false; return false;
} }
@@ -248,42 +249,42 @@ LegacyBootDrive::ReadPartitions(BMessage *settings)
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; return status;
// skip not from BIOS bootable drives // skip not from BIOS bootable drives
int8 drive; int8 drive;
if (!_GetBiosDrive(path.Path(), &drive)) if (!_GetBiosDrive(path.Path(), &drive))
continue; continue;
PartitionRecorder recorder(settings, drive); PartitionRecorder recorder(settings, drive);
device.VisitEachDescendant(&recorder); device.VisitEachDescendant(&recorder);
if (!diskFound) { if (!diskFound) {
settings->AddString("disk", path.Path()); settings->AddString("disk", path.Path());
diskFound = true; diskFound = true;
#if !USE_SECOND_DISK #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)
return kErrorBootSectorTooSmall; return kErrorBootSectorTooSmall;
// TODO remove when booting from all drives works // TODO remove when booting from all drives works
break; break;
#endif #endif
} }
} }
#if USE_SECOND_DISK #if USE_SECOND_DISK
// for testing only write boot menu to second hdd // for testing only write boot menu to second hdd
settings->ReplaceString("disk", "/dev/disk/ata/1/master/raw"); settings->ReplaceString("disk", "/dev/disk/ata/1/master/raw");
#endif #endif
if (diskFound) if (diskFound)
return B_OK; return B_OK;
else else
@@ -297,40 +298,40 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
BString path; BString path;
if (settings->FindString("disk", &path) != B_OK) if (settings->FindString("disk", &path) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
int32 defaultPartitionIndex; int32 defaultPartitionIndex;
if (settings->FindInt32("defaultPartition", &defaultPartitionIndex) != B_OK) if (settings->FindInt32("defaultPartition", &defaultPartitionIndex) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
int32 timeout; int32 timeout;
if (settings->FindInt32("timeout", &timeout) != B_OK) if (settings->FindInt32("timeout", &timeout) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
int fd = open(path.String(), O_RDWR); int fd = open(path.String(), O_RDWR);
if (fd < 0) if (fd < 0)
return B_IO_ERROR; return B_IO_ERROR;
MasterBootRecord oldMBR; MasterBootRecord oldMBR;
if (read(fd, &oldMBR, sizeof(oldMBR)) != sizeof(oldMBR)) { if (read(fd, &oldMBR, sizeof(oldMBR)) != sizeof(oldMBR)) {
close(fd); close(fd);
return B_IO_ERROR; return B_IO_ERROR;
} }
if (!_IsValid(&oldMBR)) { if (!_IsValid(&oldMBR)) {
close(fd); close(fd);
return B_BAD_VALUE; return B_BAD_VALUE;
} }
Buffer newBootLoader; Buffer newBootLoader;
ssize_t size = sizeof(kBootLoader); ssize_t size = sizeof(kBootLoader);
if (newBootLoader.Write(kBootLoader, size) != size) { if (newBootLoader.Write(kBootLoader, size) != size) {
close(fd); close(fd);
return B_NO_MEMORY; return B_NO_MEMORY;
} }
MasterBootRecord* newMBR = (MasterBootRecord*)newBootLoader.BMallocIO::Buffer(); MasterBootRecord* newMBR = (MasterBootRecord*)newBootLoader.BMallocIO::Buffer();
_CopyPartitionTable(newMBR, &oldMBR); _CopyPartitionTable(newMBR, &oldMBR);
int menuEntries = 0; int menuEntries = 0;
int defaultMenuEntry = 0; int defaultMenuEntry = 0;
BMessage partition; BMessage partition;
@@ -342,14 +343,14 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
continue; continue;
if (index == defaultPartitionIndex) if (index == defaultPartitionIndex)
defaultMenuEntry = menuEntries; defaultMenuEntry = menuEntries;
menuEntries ++; menuEntries ++;
} }
newBootLoader.WriteInt16(menuEntries); newBootLoader.WriteInt16(menuEntries);
newBootLoader.WriteInt16(defaultMenuEntry); newBootLoader.WriteInt16(defaultMenuEntry);
newBootLoader.WriteInt16(timeout); newBootLoader.WriteInt16(timeout);
for (index = 0; settings->FindMessage("partition", index, &partition) == B_OK; index ++) { for (index = 0; settings->FindMessage("partition", index, &partition) == B_OK; index ++) {
bool show; bool show;
BString name; BString name;
@@ -364,20 +365,20 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
partition.FindInt8("drive", &drive); partition.FindInt8("drive", &drive);
if (!show) if (!show)
continue; continue;
BString biosName; BString biosName;
_ConvertToBIOSText(name.String(), biosName); _ConvertToBIOSText(name.String(), biosName);
newBootLoader.WriteString(biosName.String()); newBootLoader.WriteString(biosName.String());
newBootLoader.WriteInt8(drive); newBootLoader.WriteInt8(drive);
newBootLoader.WriteInt64(offset / kBlockSize); newBootLoader.WriteInt64(offset / kBlockSize);
} }
if (!newBootLoader.Align(kBlockSize)) { if (!newBootLoader.Align(kBlockSize)) {
close(fd); close(fd);
return B_ERROR; return B_ERROR;
} }
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
const uint8* buffer = (uint8*)newBootLoader.BMallocIO::Buffer(); const uint8* buffer = (uint8*)newBootLoader.BMallocIO::Buffer();
status_t status = _WriteBlocks(fd, buffer, newBootLoader.Position()); status_t status = _WriteBlocks(fd, buffer, newBootLoader.Position());
@@ -388,20 +389,20 @@ LegacyBootDrive::WriteBootMenu(BMessage *settings)
status_t status_t
LegacyBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file) LegacyBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file)
{ {
BString path; BString path;
if (settings->FindString("disk", &path) != B_OK) if (settings->FindString("disk", &path) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
int fd = open(path.String(), O_RDONLY); int fd = open(path.String(), O_RDONLY);
if (fd < 0) if (fd < 0)
return B_IO_ERROR; return B_IO_ERROR;
ssize_t size = kBlockSize * kNumberOfBootLoaderBlocks; ssize_t size = kBlockSize * kNumberOfBootLoaderBlocks;
uint8* buffer = new(std::nothrow) uint8[size]; uint8* buffer = new(std::nothrow) uint8[size];
if (buffer == NULL) { if (buffer == NULL) {
close(fd); close(fd);
return B_NO_MEMORY; return B_NO_MEMORY;
} }
@@ -410,7 +411,7 @@ LegacyBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file)
close(fd); close(fd);
delete[] buffer; delete[] buffer;
return B_IO_ERROR; return B_IO_ERROR;
} }
MasterBootRecord* mbr = (MasterBootRecord*)buffer; MasterBootRecord* mbr = (MasterBootRecord*)buffer;
if (!_IsValid(mbr)) { if (!_IsValid(mbr)) {
@@ -421,7 +422,7 @@ LegacyBootDrive::SaveMasterBootRecord(BMessage* settings, BFile* file)
if (file->Write(buffer, size) != size) if (file->Write(buffer, size) != size)
status = B_IO_ERROR; status = B_IO_ERROR;
delete[] buffer; delete[] buffer;
close(fd); close(fd);
return status; return status;
} }
@@ -433,27 +434,27 @@ LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
BString path; BString path;
if (settings->FindString("disk", &path) != B_OK) if (settings->FindString("disk", &path) != B_OK)
return B_BAD_VALUE; return B_BAD_VALUE;
int fd = open(path.String(), O_RDWR); int fd = open(path.String(), O_RDWR);
if (fd < 0) if (fd < 0)
return B_IO_ERROR; return B_IO_ERROR;
MasterBootRecord oldMBR; MasterBootRecord oldMBR;
if (read(fd, &oldMBR, sizeof(oldMBR)) != sizeof(oldMBR)) { if (read(fd, &oldMBR, sizeof(oldMBR)) != sizeof(oldMBR)) {
close(fd); close(fd);
return B_IO_ERROR; return B_IO_ERROR;
} }
if (!_IsValid(&oldMBR)) { if (!_IsValid(&oldMBR)) {
close(fd); close(fd);
return B_BAD_VALUE; return B_BAD_VALUE;
} }
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
size_t size = kBlockSize * kNumberOfBootLoaderBlocks; size_t size = kBlockSize * kNumberOfBootLoaderBlocks;
uint8* buffer = new(std::nothrow) uint8[size]; uint8* buffer = new(std::nothrow) uint8[size];
if (buffer == NULL) { if (buffer == NULL) {
close(fd); close(fd);
return B_NO_MEMORY; return B_NO_MEMORY;
} }
@@ -461,7 +462,7 @@ LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
close(fd); close(fd);
delete[] buffer; delete[] buffer;
return B_IO_ERROR; return B_IO_ERROR;
} }
MasterBootRecord* newMBR = (MasterBootRecord*)buffer; MasterBootRecord* newMBR = (MasterBootRecord*)buffer;
if (!_IsValid(newMBR)) { if (!_IsValid(newMBR)) {
@@ -469,11 +470,11 @@ LegacyBootDrive::RestoreMasterBootRecord(BMessage* settings, BFile* file)
delete[] buffer; delete[] buffer;
return B_BAD_VALUE; return B_BAD_VALUE;
} }
_CopyPartitionTable(newMBR, &oldMBR); _CopyPartitionTable(newMBR, &oldMBR);
status_t status = _WriteBlocks(fd, buffer, size); status_t status = _WriteBlocks(fd, buffer, size);
delete[] buffer; delete[] buffer;
close(fd); close(fd);
return status; return status;
} }
@@ -590,7 +591,7 @@ void
LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination, LegacyBootDrive::_CopyPartitionTable(MasterBootRecord* destination,
const MasterBootRecord* source) const MasterBootRecord* source)
{ {
memcpy(destination->diskSignature, source->diskSignature, memcpy(destination->diskSignature, source->diskSignature,
sizeof(source->diskSignature) + sizeof(source->reserved) + sizeof(source->diskSignature) + sizeof(source->reserved) +
sizeof(source->partition)); sizeof(source->partition));
} }
+39 -39
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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, [email protected] * Michael Pfeiffer, [email protected]
* Ingo Weinhold <[email protected]> * Ingo Weinhold <[email protected]>
@@ -33,7 +33,7 @@ const uint32 kMessageName = 'name';
PartitionsPage::PartitionsPage(BMessage* settings, BRect frame, const char* name) PartitionsPage::PartitionsPage(BMessage* settings, BRect frame, const char* name)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, : WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
{ {
_BuildUI(); _BuildUI();
@@ -59,23 +59,23 @@ PartitionsPage::PageCompleted()
BControl* control = dynamic_cast<BControl*>(child); BControl* control = dynamic_cast<BControl*>(child);
if (control == NULL) if (control == NULL)
continue; continue;
int32 index; int32 index;
BMessage* message = control->Message(); BMessage* message = control->Message();
if (message == NULL || message->FindInt32("index", &index) != B_OK) if (message == NULL || message->FindInt32("index", &index) != B_OK)
continue; continue;
BMessage partition; BMessage partition;
if (fSettings->FindMessage("partition", index, &partition) != B_OK) if (fSettings->FindMessage("partition", index, &partition) != B_OK)
continue; continue;
if (kMessageShow == message->what) { if (kMessageShow == message->what) {
partition.ReplaceBool("show", control->Value() == 1); partition.ReplaceBool("show", control->Value() == 1);
} else if (kMessageName == message->what && } else if (kMessageName == message->what &&
dynamic_cast<BTextControl*>(control) != NULL) { dynamic_cast<BTextControl*>(control) != NULL) {
partition.ReplaceString("name", ((BTextControl*)control)->Text()); partition.ReplaceString("name", ((BTextControl*)control)->Text());
} }
fSettings->ReplaceMessage("partition", index, &partition); fSettings->ReplaceMessage("partition", index, &partition);
} }
} }
@@ -96,11 +96,11 @@ void
PartitionsPage::_BuildUI() PartitionsPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
BString text; BString text;
text << text <<
TR_CMT("Partitions", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Partitions", "Title") << "\n\n" <<
TR("The following partitions were detected. Please " B_TRANSLATE("The following partitions were detected. Please "
"check the box next to the partitions to be included " "check the box next to the partitions to be included "
"in the boot menu. You can also set the names of the " "in the boot menu. You can also set the names of the "
"partitions as you would like them to appear in the " "partitions as you would like them to appear in the "
@@ -109,24 +109,24 @@ PartitionsPage::_BuildUI()
MakeHeading(fDescription); MakeHeading(fDescription);
AddChild(fDescription); AddChild(fDescription);
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
rect.left = fDescription->Frame().left + 1; rect.left = fDescription->Frame().left + 1;
rect.top = fDescription->Frame().bottom + kTextDistance; rect.top = fDescription->Frame().bottom + kTextDistance;
rect.right -= B_V_SCROLL_BAR_WIDTH; rect.right -= B_V_SCROLL_BAR_WIDTH;
rect.bottom -= B_H_SCROLL_BAR_HEIGHT + 3; rect.bottom -= B_H_SCROLL_BAR_HEIGHT + 3;
fPartitions = new BView(rect, "partitions", B_FOLLOW_ALL, fPartitions = new BView(rect, "partitions", B_FOLLOW_ALL,
B_WILL_DRAW); B_WILL_DRAW);
fPartitionsScrollView = new BScrollView("scrollView", fPartitions, fPartitionsScrollView = new BScrollView("scrollView", fPartitions,
B_FOLLOW_ALL, B_FOLLOW_ALL,
0, 0,
true, true); true, true);
fPartitionsScrollView->SetViewColor(ViewColor()); fPartitionsScrollView->SetViewColor(ViewColor());
AddChild(fPartitionsScrollView); AddChild(fPartitionsScrollView);
_FillPartitionsView(fPartitions); _FillPartitionsView(fPartitions);
_Layout(); _Layout();
} }
@@ -139,11 +139,11 @@ PartitionsPage::_Layout()
float left = fPartitionsScrollView->Frame().left; float left = fPartitionsScrollView->Frame().left;
float top = fDescription->Frame().bottom + kTextDistance; float top = fDescription->Frame().bottom + kTextDistance;
fPartitionsScrollView->MoveTo(left, top); fPartitionsScrollView->MoveTo(left, top);
float width = fPartitionsScrollView->Frame().Width(); float width = fPartitionsScrollView->Frame().Width();
float height = Bounds().bottom - top; float height = Bounds().bottom - top;
fPartitionsScrollView->ResizeTo(width, height); fPartitionsScrollView->ResizeTo(width, height);
// update scroll bar range and proportion // update scroll bar range and proportion
BScrollBar* scrollbar = fPartitionsScrollView->ScrollBar(B_HORIZONTAL); BScrollBar* scrollbar = fPartitionsScrollView->ScrollBar(B_HORIZONTAL);
float viewWidth = fPartitions->Bounds().IntegerWidth(); float viewWidth = fPartitions->Bounds().IntegerWidth();
@@ -157,7 +157,7 @@ PartitionsPage::_Layout()
else else
proportion = viewWidth / fPartitionsWidth; proportion = viewWidth / fPartitionsWidth;
scrollbar->SetProportion(proportion); scrollbar->SetProportion(proportion);
scrollbar = fPartitionsScrollView->ScrollBar(B_VERTICAL); scrollbar = fPartitionsScrollView->ScrollBar(B_VERTICAL);
float viewHeight = fPartitions->Bounds().IntegerHeight(); float viewHeight = fPartitions->Bounds().IntegerHeight();
max = fPartitionsHeight - viewHeight; max = fPartitionsHeight - viewHeight;
@@ -180,10 +180,10 @@ void
PartitionsPage::_FillPartitionsView(BView* view) PartitionsPage::_FillPartitionsView(BView* view)
{ {
const int32 inset = 1; const int32 inset = 1;
font_height fontHeight; font_height fontHeight;
be_plain_font->GetHeight(&fontHeight); be_plain_font->GetHeight(&fontHeight);
int32 textControlHeight; int32 textControlHeight;
{ {
BTextControl control(BRect(0, 0, 100, 100), "", "", "", NULL); BTextControl control(BRect(0, 0, 100, 100), "", "", "", NULL);
@@ -195,7 +195,7 @@ PartitionsPage::_FillPartitionsView(BView* view)
const int32 height = (int32)(2*inset const int32 height = (int32)(2*inset
+ max_c(textControlHeight, textHeight)); + max_c(textControlHeight, textHeight));
const int32 kDistance = (int32)(ceil(be_plain_font->StringWidth("x"))); const int32 kDistance = (int32)(ceil(be_plain_font->StringWidth("x")));
// show | name | type | size | path // show | name | type | size | path
int32 showWidth = 0; int32 showWidth = 0;
int32 nameWidth = 0; int32 nameWidth = 0;
@@ -203,12 +203,12 @@ PartitionsPage::_FillPartitionsView(BView* view)
int32 sizeWidth = 0; int32 sizeWidth = 0;
int32 pathWidth = 0; int32 pathWidth = 0;
_ComputeColumnWidths(showWidth, nameWidth, typeWidth, sizeWidth, pathWidth); _ComputeColumnWidths(showWidth, nameWidth, typeWidth, sizeWidth, pathWidth);
int32 totalWidth = showWidth + nameWidth + typeWidth + sizeWidth int32 totalWidth = showWidth + nameWidth + typeWidth + sizeWidth
+ pathWidth + 2 * inset + 4 * kDistance; + pathWidth + 2 * inset + 4 * kDistance;
int32 rowNumber = 0; int32 rowNumber = 0;
BRect frame(view->Bounds()); BRect frame(view->Bounds());
frame.bottom = frame.top + height; frame.bottom = frame.top + height;
frame.right = frame.left + 65000; frame.right = frame.left + 65000;
@@ -226,7 +226,7 @@ PartitionsPage::_FillPartitionsView(BView* view)
message.FindString("type", &type); message.FindString("type", &type);
message.FindString("path", &path); message.FindString("path", &path);
message.FindInt64("size", &size); message.FindInt64("size", &size);
// create row for partition data // create row for partition data
BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0); BView* row = new BView(frame, "row", B_FOLLOW_TOP | B_FOLLOW_LEFT, 0);
row->SetViewColor(((rowNumber % 2) == 0) ? kEvenRowColor : kOddRowColor); row->SetViewColor(((rowNumber % 2) == 0) ? kEvenRowColor : kOddRowColor);
@@ -237,7 +237,7 @@ PartitionsPage::_FillPartitionsView(BView* view)
BRect rect(row->Bounds()); BRect rect(row->Bounds());
rect.InsetBy(inset, inset); rect.InsetBy(inset, inset);
rect.right = rect.left + showWidth; rect.right = rect.left + showWidth;
BCheckBox* checkBox = new BCheckBox(rect, "show", "", BCheckBox* checkBox = new BCheckBox(rect, "show", "",
_CreateControlMessage(kMessageShow, i)); _CreateControlMessage(kMessageShow, i));
if (show) if (show)
checkBox->SetValue(1); checkBox->SetValue(1);
@@ -248,15 +248,15 @@ PartitionsPage::_FillPartitionsView(BView* view)
checkBox->MoveTo(inset, (int)((height - showHeight + 1) / 2)); checkBox->MoveTo(inset, (int)((height - showHeight + 1) / 2));
row->AddChild(checkBox); row->AddChild(checkBox);
rect.OffsetBy(showWidth + kDistance, 0); rect.OffsetBy(showWidth + kDistance, 0);
// name // name
rect.right = rect.left + nameWidth; rect.right = rect.left + nameWidth;
BTextControl* nameControl = new BTextControl(rect, "name", "", name.String(), BTextControl* nameControl = new BTextControl(rect, "name", "", name.String(),
_CreateControlMessage(kMessageName, i)); _CreateControlMessage(kMessageName, i));
nameControl->SetDivider(0); nameControl->SetDivider(0);
row->AddChild(nameControl); row->AddChild(nameControl);
rect.OffsetBy(nameWidth + kDistance, 0); rect.OffsetBy(nameWidth + kDistance, 0);
// type // type
rect.right = rect.left + typeWidth; rect.right = rect.left + typeWidth;
BStringView* typeView = new BStringView(rect, "type", type.String()); BStringView* typeView = new BStringView(rect, "type", type.String());
@@ -271,21 +271,21 @@ PartitionsPage::_FillPartitionsView(BView* view)
sizeView->SetAlignment(B_ALIGN_RIGHT); sizeView->SetAlignment(B_ALIGN_RIGHT);
row->AddChild(sizeView); row->AddChild(sizeView);
rect.OffsetBy(sizeWidth + kDistance, 0); rect.OffsetBy(sizeWidth + kDistance, 0);
// path // path
rect.right = rect.left + pathWidth; rect.right = rect.left + pathWidth;
BStringView* pathView = new BStringView(rect, "path", path.String()); BStringView* pathView = new BStringView(rect, "path", path.String());
row->AddChild(pathView); row->AddChild(pathView);
} }
fPartitionsWidth = totalWidth; fPartitionsWidth = totalWidth;
fPartitionsHeight = frame.top; fPartitionsHeight = frame.top;
} }
void void
PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth, PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
int32& typeWidth, int32& sizeWidth, int32& pathWidth) int32& typeWidth, int32& sizeWidth, int32& pathWidth)
{ {
BCheckBox checkBox(BRect(0, 0, 100, 100), "show", "", new BMessage()); BCheckBox checkBox(BRect(0, 0, 100, 100), "show", "", new BMessage());
@@ -293,9 +293,9 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
showWidth = checkBox.Bounds().IntegerWidth(); showWidth = checkBox.Bounds().IntegerWidth();
// reserve space for about 16 characters // reserve space for about 16 characters
nameWidth = (int32)ceil(be_plain_font->StringWidth("oooooooooooooooo")); nameWidth = (int32)ceil(be_plain_font->StringWidth("oooooooooooooooo"));
const int32 kStringViewInsets = 2; const int32 kStringViewInsets = 2;
BMessage message; BMessage message;
for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) { for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK; i ++) {
// get partition data // get partition data
@@ -309,7 +309,7 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
_CreateSizeText(size, &sizeText); _CreateSizeText(size, &sizeText);
int32 width = (int32)ceil(be_plain_font->StringWidth(type.String())) + int32 width = (int32)ceil(be_plain_font->StringWidth(type.String())) +
kStringViewInsets; kStringViewInsets;
if (typeWidth < width) if (typeWidth < width)
typeWidth = width; typeWidth = width;
@@ -326,7 +326,7 @@ PartitionsPage::_ComputeColumnWidths(int32& showWidth, int32& nameWidth,
} }
void void
PartitionsPage::_CreateSizeText(int64 _size, BString* text) PartitionsPage::_CreateSizeText(int64 _size, BString* text)
{ {
const char* suffixes[] = { const char* suffixes[] = {
@@ -347,7 +347,7 @@ PartitionsPage::_CreateSizeText(int64 _size, BString* text)
} }
BMessage* BMessage*
PartitionsPage::_CreateControlMessage(uint32 what, int32 index) PartitionsPage::_CreateControlMessage(uint32 what, int32 index)
{ {
BMessage* message = new BMessage(what); BMessage* message = new BMessage(what);
+8 -8
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
*/ */
@@ -22,7 +22,7 @@
UninstallPage::UninstallPage(BMessage* settings, BRect frame, const char* name) UninstallPage::UninstallPage(BMessage* settings, BRect frame, const char* name)
: WizardPageView(settings, frame, name, B_FOLLOW_ALL, : WizardPageView(settings, frame, name, B_FOLLOW_ALL,
B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE) B_WILL_DRAW | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE)
{ {
_BuildUI(); _BuildUI();
@@ -48,18 +48,18 @@ void
UninstallPage::_BuildUI() UninstallPage::_BuildUI()
{ {
BRect rect(Bounds()); BRect rect(Bounds());
BString text; BString text;
text << text <<
TR_CMT("Uninstall Boot Manager", "Title") << "\n\n" << B_TRANSLATE_COMMENT("Uninstall Boot Manager", "Title") << "\n\n" <<
TR("Please locate the Master Boot Record (MBR) save file to " B_TRANSLATE("Please locate the Master Boot Record (MBR) save file to "
"restore from. This is the file that was created when the " "restore from. This is the file that was created when the "
"boot manager was first installed."); "boot manager was first installed.");
fDescription = CreateDescription(rect, "description", text); fDescription = CreateDescription(rect, "description", text);
MakeHeading(fDescription); MakeHeading(fDescription);
AddChild(fDescription); AddChild(fDescription);
_Layout(); _Layout();
} }
@@ -67,6 +67,6 @@ UninstallPage::_BuildUI()
void void
UninstallPage::_Layout() UninstallPage::_Layout()
{ {
LayoutDescriptionVertically(fDescription); LayoutDescriptionVertically(fDescription);
} }
+21 -20
View File
@@ -1,7 +1,7 @@
/* /*
* Copyright 2008, Haiku, Inc. All rights reserved. * Copyright 2008, 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 <[email protected]> * Michael Pfeiffer <[email protected]>
*/ */
@@ -49,25 +49,25 @@ WizardView::PageFrame()
float right = Bounds().right - kBorderWidth; float right = Bounds().right - kBorderWidth;
float top = kBorderHeight; float top = kBorderHeight;
float bottom = fSeparator->Frame().top - kSeparatorDistance - 1; float bottom = fSeparator->Frame().top - kSeparatorDistance - 1;
return BRect(left, top, right, bottom); return BRect(left, top, right, bottom);
} }
void void
WizardView::SetPage(WizardPageView* page) WizardView::SetPage(WizardPageView* page)
{ {
if (fPage == page) if (fPage == page)
return; return;
if (fPage != NULL) { if (fPage != NULL) {
RemoveChild(fPage); RemoveChild(fPage);
delete fPage; delete fPage;
} }
fPage = page; fPage = page;
if (page == NULL) if (page == NULL)
return; return;
BRect frame = PageFrame(); BRect frame = PageFrame();
page->MoveTo(frame.left, frame.top); page->MoveTo(frame.left, frame.top);
page->ResizeTo(frame.Width()+1, frame.Height()+1); page->ResizeTo(frame.Width()+1, frame.Height()+1);
@@ -112,12 +112,12 @@ WizardView::SetNextButtonLabel(const char* text)
fNext->SetLabel(text); fNext->SetLabel(text);
fNext->ResizeToPreferred(); fNext->ResizeToPreferred();
BRect newFrame = fNext->Frame(); BRect newFrame = fNext->Frame();
fNext->MoveBy(frame.Width() - newFrame.Width(), fNext->MoveBy(frame.Width() - newFrame.Width(),
frame.Height() - newFrame.Height()); frame.Height() - newFrame.Height());
} }
void void
WizardView::SetPreviousButtonHidden(bool hide) WizardView::SetPreviousButtonHidden(bool hide)
{ {
if (hide) { if (hide) {
@@ -134,35 +134,36 @@ void
WizardView::_BuildUI() WizardView::_BuildUI()
{ {
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
float width = Bounds().Width(); float width = Bounds().Width();
float height = Bounds().Height(); float height = Bounds().Height();
fSeparator = new BBox(BRect(kBorderWidth, 0, fSeparator = new BBox(BRect(kBorderWidth, 0,
width - 1 - kBorderWidth, kSeparatorHeight - 1), width - 1 - kBorderWidth, kSeparatorHeight - 1),
"separator", "separator",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM); B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM);
AddChild(fSeparator); AddChild(fSeparator);
fPrevious = new BButton(BRect(0, 0, 100, 20), "previous", fPrevious = new BButton(BRect(0, 0, 100, 20), "previous",
TR_CMT("Previous", "Button"), B_TRANSLATE_COMMENT("Previous", "Button"),
new BMessage(kMessagePrevious), new BMessage(kMessagePrevious),
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM); B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
AddChild(fPrevious); AddChild(fPrevious);
fPrevious->ResizeToPreferred(); fPrevious->ResizeToPreferred();
fNext = new BButton(BRect(0, 0, 100, 20), "next", TR_CMT("Next", "Button"), fNext = new BButton(BRect(0, 0, 100, 20), "next",
new BMessage(kMessageNext), B_TRANSLATE_COMMENT("Next", "Button"),
new BMessage(kMessageNext),
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
AddChild(fNext); AddChild(fNext);
fNext->ResizeToPreferred(); fNext->ResizeToPreferred();
// layout views // layout views
float buttonHeight = fPrevious->Bounds().Height(); float buttonHeight = fPrevious->Bounds().Height();
float buttonTop = height - 1 - buttonHeight - kBorderHeight; float buttonTop = height - 1 - buttonHeight - kBorderHeight;
fPrevious->MoveTo(kBorderWidth, buttonTop); fPrevious->MoveTo(kBorderWidth, buttonTop);
fSeparator->MoveTo(kBorderWidth, buttonTop - kSeparatorDistance - kSeparatorHeight); fSeparator->MoveTo(kBorderWidth, buttonTop - kSeparatorDistance - kSeparatorHeight);
fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1, buttonTop); fNext->MoveTo(width - fNext->Bounds().Width() - kBorderWidth - 1, buttonTop);
} }