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