* 'PNG ' -> B_PNG_FORMAT
* reformat long lines so that they don't exceed 80 chars git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22751 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ac1a8a0c8d
commit
ed7081f728
@ -18,9 +18,9 @@
|
||||
|
||||
//#define COPY_TRACE
|
||||
#ifdef COPY_TRACE
|
||||
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
|
||||
#define ERR2(x, y...) fprintf(stderr, "CopyEngine: "x" %s\n", y, strerror(err))
|
||||
#define ERR(x) fprintf(stderr, "CopyEngine: "x" %s\n", strerror(err))
|
||||
#define CALLED() printf("CALLED %s\n",__PRETTY_FUNCTION__)
|
||||
#define ERR2(x, y...) fprintf(stderr, "CopyEngine: "x" %s\n", y, strerror(err))
|
||||
#define ERR(x) fprintf(stderr, "CopyEngine: "x" %s\n", strerror(err))
|
||||
#else
|
||||
#define CALLED()
|
||||
#define ERR(x)
|
||||
@ -49,7 +49,7 @@ class TargetVisitor : public BDiskDeviceVisitor
|
||||
virtual bool Visit(BDiskDevice *device);
|
||||
virtual bool Visit(BPartition *partition, int32 level);
|
||||
private:
|
||||
void MakeLabel(BPartition *partition, char *label, char *menuLabel);
|
||||
void _MakeLabel(BPartition *partition, char *label, char *menuLabel);
|
||||
BMenu *fMenu;
|
||||
};
|
||||
|
||||
@ -71,10 +71,13 @@ CopyEngine::MessageReceived(BMessage*msg)
|
||||
CALLED();
|
||||
switch (msg->what) {
|
||||
case ENGINE_START:
|
||||
status_t err = Start(fWindow->GetSourceMenu(), fWindow->GetTargetMenu());
|
||||
{
|
||||
status_t err = Start(fWindow->GetSourceMenu(),
|
||||
fWindow->GetTargetMenu());
|
||||
if (err != B_OK)
|
||||
ERR("Start failed");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,7 +142,8 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
||||
if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) {
|
||||
if (!partition->IsMounted()) {
|
||||
if ((err = partition->Mount()) < B_OK) {
|
||||
SetStatusMessage("The disk can't be mounted. Please choose a different disk.");
|
||||
SetStatusMessage("The disk can't be mounted. Please choose a "
|
||||
"different disk.");
|
||||
ERR("BPartition::Mount");
|
||||
return err;
|
||||
}
|
||||
@ -155,7 +159,8 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
||||
} else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) {
|
||||
if (!device.IsMounted()) {
|
||||
if ((err = device.Mount()) < B_OK) {
|
||||
SetStatusMessage("The disk can't be mounted. Please choose a different disk.");
|
||||
SetStatusMessage("The disk can't be mounted. Please choose a "
|
||||
"different disk.");
|
||||
ERR("BDiskDevice::Mount");
|
||||
return err;
|
||||
}
|
||||
@ -173,8 +178,9 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
||||
|
||||
// check if target has enough space
|
||||
if ((fSpaceRequired > 0 && targetVolume.FreeBytes() < fSpaceRequired)
|
||||
&& ((new BAlert("", "The destination disk may not have enough space. Try choosing a different disk or \
|
||||
choose to not install optional items.", "Try installing anyway", "Cancel", 0,
|
||||
&& ((new BAlert("", "The destination disk may not have enough space. "
|
||||
"Try choosing a different disk or choose to not install optional "
|
||||
"items.", "Try installing anyway", "Cancel", 0,
|
||||
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
|
||||
return B_OK;
|
||||
}
|
||||
@ -195,14 +201,16 @@ choose to not install optional items.", "Try installing anyway", "Cancel", 0,
|
||||
|
||||
// check not installing on itself
|
||||
if (strcmp(srcDirectory.Path(), targetDirectory.Path()) == 0) {
|
||||
SetStatusMessage("You can't install the contents of a disk onto itself. Please choose a different disk.");
|
||||
SetStatusMessage("You can't install the contents of a disk onto "
|
||||
"itself. Please choose a different disk.");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// check not installing on boot volume
|
||||
if ((strncmp(BOOT_PATH, targetDirectory.Path(), strlen(BOOT_PATH)) == 0)
|
||||
&& ((new BAlert("", "Are you sure you want to install onto the current boot disk? \
|
||||
The installer will have to reboot your machine if you proceed.", "OK", "Cancel", 0,
|
||||
&& ((new BAlert("", "Are you sure you want to install onto the "
|
||||
"current boot disk? The installer will have to reboot your "
|
||||
"machine if you proceed.", "OK", "Cancel", 0,
|
||||
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
|
||||
SetStatusMessage("Installation stopped.");
|
||||
return B_OK;
|
||||
@ -255,7 +263,8 @@ CopyEngine::CopyFolder(BDirectory &srcDir, BDirectory &targetDir)
|
||||
}
|
||||
err = FSCopyFolder(&entry, &targetDir, fControl, NULL, false, undo);
|
||||
} else {
|
||||
err = FSCopyFile(&entry, &statbuf, &targetDir, fControl, NULL, false, undo);
|
||||
err = FSCopyFile(&entry, &statbuf, &targetDir, fControl, NULL,
|
||||
false, undo);
|
||||
}
|
||||
if (err != B_OK) {
|
||||
BPath path;
|
||||
@ -290,6 +299,9 @@ CopyEngine::SetPackagesList(BList *list)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
SourceVisitor::SourceVisitor(BMenu *menu)
|
||||
: fMenu(menu)
|
||||
{
|
||||
@ -298,12 +310,14 @@ SourceVisitor::SourceVisitor(BMenu *menu)
|
||||
bool
|
||||
SourceVisitor::Visit(BDiskDevice *device)
|
||||
{
|
||||
if (!device->ContentType() || strcmp(device->ContentType(), kPartitionTypeBFS) != 0)
|
||||
if (!device->ContentType()
|
||||
|| strcmp(device->ContentType(), kPartitionTypeBFS) != 0)
|
||||
return false;
|
||||
BPath path;
|
||||
if (device->GetPath(&path) == B_OK)
|
||||
printf("SourceVisitor::Visit(BDiskDevice *) : %s type:%s, contentType:%s\n",
|
||||
path.Path(), device->Type(), device->ContentType());
|
||||
printf("SourceVisitor::Visit(BDiskDevice *) : %s type:%s, "
|
||||
"contentType:%s\n", path.Path(), device->Type(),
|
||||
device->ContentType());
|
||||
PartitionMenuItem *item = new PartitionMenuItem(NULL, device->ContentName(), NULL, new BMessage(SRC_PARTITION), device->ID());
|
||||
if (device->IsMounted()) {
|
||||
BPath mountPoint;
|
||||
@ -319,13 +333,16 @@ SourceVisitor::Visit(BDiskDevice *device)
|
||||
bool
|
||||
SourceVisitor::Visit(BPartition *partition, int32 level)
|
||||
{
|
||||
if (!partition->ContentType() || strcmp(partition->ContentType(), kPartitionTypeBFS) != 0)
|
||||
if (!partition->ContentType()
|
||||
|| strcmp(partition->ContentType(), kPartitionTypeBFS) != 0)
|
||||
return false;
|
||||
BPath path;
|
||||
if (partition->GetPath(&path) == B_OK)
|
||||
printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path());
|
||||
printf("SourceVisitor::Visit(BPartition *) : %s\n", partition->Name());
|
||||
PartitionMenuItem *item = new PartitionMenuItem(NULL, partition->ContentName(), NULL, new BMessage(SRC_PARTITION), partition->ID());
|
||||
PartitionMenuItem *item = new PartitionMenuItem(NULL,
|
||||
partition->ContentName(), NULL, new BMessage(SRC_PARTITION),
|
||||
partition->ID());
|
||||
if (partition->IsMounted()) {
|
||||
BPath mountPoint;
|
||||
partition->GetMountPoint(&mountPoint);
|
||||
@ -337,6 +354,9 @@ SourceVisitor::Visit(BPartition *partition, int32 level)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
TargetVisitor::TargetVisitor(BMenu *menu)
|
||||
: fMenu(menu)
|
||||
{
|
||||
@ -352,8 +372,9 @@ TargetVisitor::Visit(BDiskDevice *device)
|
||||
if (device->GetPath(&path) == B_OK)
|
||||
printf("TargetVisitor::Visit(BDiskDevice *) : %s\n", path.Path());
|
||||
char label[255], menuLabel[255];
|
||||
MakeLabel(device, label, menuLabel);
|
||||
fMenu->AddItem(new PartitionMenuItem(device->ContentName(), label, menuLabel, new BMessage(TARGET_PARTITION), device->ID()));
|
||||
_MakeLabel(device, label, menuLabel);
|
||||
fMenu->AddItem(new PartitionMenuItem(device->ContentName(), label,
|
||||
menuLabel, new BMessage(TARGET_PARTITION), device->ID()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -368,14 +389,15 @@ TargetVisitor::Visit(BPartition *partition, int32 level)
|
||||
printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path());
|
||||
printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->Name());
|
||||
char label[255], menuLabel[255];
|
||||
MakeLabel(partition, label, menuLabel);
|
||||
fMenu->AddItem(new PartitionMenuItem(partition->ContentName(), label, menuLabel, new BMessage(TARGET_PARTITION), partition->ID()));
|
||||
_MakeLabel(partition, label, menuLabel);
|
||||
fMenu->AddItem(new PartitionMenuItem(partition->ContentName(), label,
|
||||
menuLabel, new BMessage(TARGET_PARTITION), partition->ID()));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TargetVisitor::MakeLabel(BPartition *partition, char *label, char *menuLabel)
|
||||
TargetVisitor::_MakeLabel(BPartition *partition, char *label, char *menuLabel)
|
||||
{
|
||||
char size[15];
|
||||
SizeAsString(partition->ContentSize(), size);
|
||||
@ -383,9 +405,10 @@ TargetVisitor::MakeLabel(BPartition *partition, char *label, char *menuLabel)
|
||||
if (partition->Parent())
|
||||
partition->Parent()->GetPath(&path);
|
||||
|
||||
sprintf(label, "%s - %s [%s] [%s partition:%li]", partition->ContentName(), size, partition->ContentType(),
|
||||
path.Path(), partition->ID());
|
||||
sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size, partition->ContentType());
|
||||
sprintf(label, "%s - %s [%s] [%s partition:%li]", partition->ContentName(),
|
||||
size, partition->ContentType(), path.Path(), partition->ID());
|
||||
sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size,
|
||||
partition->ContentType());
|
||||
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <string.h>
|
||||
#include <String.h>
|
||||
#include <TranslationUtils.h>
|
||||
#include <TranslatorFormats.h>
|
||||
#include "InstallerWindow.h"
|
||||
#include "PartitionMenuItem.h"
|
||||
|
||||
@ -38,9 +39,10 @@ class LogoView : public BBox {
|
||||
|
||||
|
||||
LogoView::LogoView(const BRect &r)
|
||||
: BBox(r, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW, B_NO_BORDER)
|
||||
: BBox(r, "logoview", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW,
|
||||
B_NO_BORDER)
|
||||
{
|
||||
fLogo = BTranslationUtils::GetBitmap('PNG ', "haikulogo.png");
|
||||
fLogo = BTranslationUtils::GetBitmap(B_PNG_FORMAT, "haikulogo.png");
|
||||
if (fLogo) {
|
||||
fDrawPoint.x = (r.Width() - fLogo->Bounds().Width()) / 2;
|
||||
fDrawPoint.y = 0;
|
||||
@ -62,8 +64,12 @@ LogoView::Draw(BRect update)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
InstallerWindow::InstallerWindow(BRect frame_rect)
|
||||
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW,
|
||||
B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||
fDriveSetupLaunched(false),
|
||||
fLastSrcItem(NULL),
|
||||
fLastTargetItem(NULL)
|
||||
@ -73,7 +79,8 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
|
||||
BRect bounds = Bounds();
|
||||
bounds.bottom += 1;
|
||||
bounds.right += 1;
|
||||
fBackBox = new BBox(bounds, NULL, B_FOLLOW_ALL, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
||||
fBackBox = new BBox(bounds, NULL, B_FOLLOW_ALL,
|
||||
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
|
||||
AddChild(fBackBox);
|
||||
|
||||
BRect logoRect = fBackBox->Bounds();
|
||||
@ -84,7 +91,8 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
|
||||
LogoView *logoView = new LogoView(logoRect);
|
||||
fBackBox->AddChild(logoView);
|
||||
|
||||
BRect statusRect(bounds.right - 222, logoRect.top + 2, bounds.right - 14, logoRect.bottom - B_H_SCROLL_BAR_HEIGHT + 4);
|
||||
BRect statusRect(bounds.right - 222, logoRect.top + 2, bounds.right - 14,
|
||||
logoRect.bottom - B_H_SCROLL_BAR_HEIGHT + 4);
|
||||
BRect textRect(statusRect);
|
||||
textRect.OffsetTo(B_ORIGIN);
|
||||
textRect.InsetBy(2, 2);
|
||||
@ -93,34 +101,42 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
|
||||
fStatusView->MakeEditable(false);
|
||||
fStatusView->MakeSelectable(false);
|
||||
|
||||
BScrollView *scroll = new BScrollView("statusScroll", fStatusView, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||
BScrollView *scroll = new BScrollView("statusScroll", fStatusView,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW | B_FRAME_EVENTS);
|
||||
fBackBox->AddChild(scroll);
|
||||
|
||||
fBeginButton = new BButton(BRect(bounds.right - 90, bounds.bottom - 35, bounds.right - 11, bounds.bottom - 11),
|
||||
"begin_button", "Begin", new BMessage(BEGIN_MESSAGE), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
fBeginButton = new BButton(BRect(bounds.right - 90, bounds.bottom - 35,
|
||||
bounds.right - 11, bounds.bottom - 11),
|
||||
"begin_button", "Begin", new BMessage(BEGIN_MESSAGE),
|
||||
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
fBeginButton->MakeDefault(true);
|
||||
fBackBox->AddChild(fBeginButton);
|
||||
|
||||
fSetupButton = new BButton(BRect(bounds.left + 11, bounds.bottom - 35,
|
||||
bounds.left + be_plain_font->StringWidth("Setup partitions") + 36, bounds.bottom - 22),
|
||||
"setup_button", "Setup partitions" B_UTF8_ELLIPSIS, new BMessage(SETUP_MESSAGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
bounds.left + be_plain_font->StringWidth("Setup partitions") + 36,
|
||||
bounds.bottom - 22), "setup_button", "Setup partitions" B_UTF8_ELLIPSIS,
|
||||
new BMessage(SETUP_MESSAGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
|
||||
fBackBox->AddChild(fSetupButton);
|
||||
fSetupButton->Hide();
|
||||
|
||||
fPackagesView = new PackagesView(BRect(bounds.left + 12, bounds.top + 4, bounds.right - 15 - B_V_SCROLL_BAR_WIDTH, bounds.bottom - 61), "packages_view");
|
||||
fPackagesScrollView = new BScrollView("packagesScroll", fPackagesView, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW,
|
||||
false, true);
|
||||
fPackagesView = new PackagesView(BRect(bounds.left + 12, bounds.top + 4,
|
||||
bounds.right - 15 - B_V_SCROLL_BAR_WIDTH, bounds.bottom - 61),
|
||||
"packages_view");
|
||||
fPackagesScrollView = new BScrollView("packagesScroll", fPackagesView,
|
||||
B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW, false, true);
|
||||
fBackBox->AddChild(fPackagesScrollView);
|
||||
fPackagesScrollView->Hide();
|
||||
|
||||
fDrawButton = new DrawButton(BRect(bounds.left + 12, bounds.bottom - 33, bounds.left + 120, bounds.bottom - 20),
|
||||
"options_button", "Fewer options", "More options", new BMessage(SHOW_BOTTOM_MESSAGE));
|
||||
fDrawButton = new DrawButton(BRect(bounds.left + 12, bounds.bottom - 33,
|
||||
bounds.left + 120, bounds.bottom - 20), "options_button",
|
||||
"Fewer options", "More options", new BMessage(SHOW_BOTTOM_MESSAGE));
|
||||
fBackBox->AddChild(fDrawButton);
|
||||
|
||||
fDestMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false);
|
||||
fSrcMenu = new BPopUpMenu("scanning" B_UTF8_ELLIPSIS, true, false);
|
||||
|
||||
BRect fieldRect(bounds.left + 50, bounds.top + 70, bounds.right - 13, bounds.top + 90);
|
||||
BRect fieldRect(bounds.left + 50, bounds.top + 70, bounds.right - 13,
|
||||
bounds.top + 90);
|
||||
fSrcMenuField = new BMenuField(fieldRect, "srcMenuField",
|
||||
"Install from: ", fSrcMenu);
|
||||
fSrcMenuField->SetDivider(bounds.right - 274);
|
||||
@ -138,8 +154,11 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
|
||||
sizeRect.top = 105;
|
||||
sizeRect.bottom = sizeRect.top + 15;
|
||||
sizeRect.right -= 12;
|
||||
sizeRect.left = sizeRect.right - be_plain_font->StringWidth("Disk space required: 0.0 KB") - 40;
|
||||
fSizeView = new BStringView(sizeRect, "size_view", "Disk space required: 0.0 KB", B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
const char* requiredDiskSpaceString = "Disk space required: 0.0 KB";
|
||||
sizeRect.left = sizeRect.right - be_plain_font->StringWidth(
|
||||
requiredDiskSpaceString) - 40;
|
||||
fSizeView = new BStringView(sizeRect, "size_view",
|
||||
requiredDiskSpaceString, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||
fSizeView->SetAlignment(B_ALIGN_RIGHT);
|
||||
fBackBox->AddChild(fSizeView);
|
||||
fSizeView->Hide();
|
||||
@ -224,7 +243,9 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
||||
fDriveSetupLaunched = msg->what == B_SOME_APP_LAUNCHED;
|
||||
DisableInterface(fDriveSetupLaunched);
|
||||
if (fDriveSetupLaunched)
|
||||
SetStatusMessage("Running DriveSetup" B_UTF8_ELLIPSIS "\nClose DriveSetup to continue with the\ninstallation.");
|
||||
SetStatusMessage("Running DriveSetup" B_UTF8_ELLIPSIS
|
||||
"\nClose DriveSetup to continue with the\n"
|
||||
"installation.");
|
||||
else
|
||||
StartScan();
|
||||
}
|
||||
@ -241,7 +262,8 @@ InstallerWindow::QuitRequested()
|
||||
{
|
||||
if (fDriveSetupLaunched) {
|
||||
(new BAlert("driveSetup",
|
||||
"Please close the DriveSetup window before closing the\nInstaller window.", "OK"))->Go();
|
||||
"Please close the DriveSetup window before closing the\n"
|
||||
"Installer window.", "OK"))->Go();
|
||||
return false;
|
||||
}
|
||||
be_app->PostMessage(B_QUIT_REQUESTED);
|
||||
@ -308,7 +330,8 @@ InstallerWindow::StartScan()
|
||||
PublishPackages();
|
||||
}
|
||||
AdjustMenus();
|
||||
SetStatusMessage("Choose the disk you want to install onto from the pop-up menu. Then click \"Begin\".");
|
||||
SetStatusMessage("Choose the disk you want to install onto from the "
|
||||
"pop-up menu. Then click \"Begin\".");
|
||||
}
|
||||
|
||||
|
||||
@ -321,8 +344,10 @@ InstallerWindow::AdjustMenus()
|
||||
} else {
|
||||
if (fSrcMenu->CountItems() == 0)
|
||||
fSrcMenuField->MenuItem()->SetLabel("<none>");
|
||||
else
|
||||
fSrcMenuField->MenuItem()->SetLabel(((PartitionMenuItem *)fSrcMenu->ItemAt(0))->MenuLabel());
|
||||
else {
|
||||
fSrcMenuField->MenuItem()->SetLabel(
|
||||
((PartitionMenuItem *)fSrcMenu->ItemAt(0))->MenuLabel());
|
||||
}
|
||||
}
|
||||
|
||||
PartitionMenuItem *item2 = (PartitionMenuItem *)fDestMenu->FindMarked();
|
||||
@ -331,8 +356,10 @@ InstallerWindow::AdjustMenus()
|
||||
} else {
|
||||
if (fDestMenu->CountItems() == 0)
|
||||
fDestMenuField->MenuItem()->SetLabel("<none>");
|
||||
else
|
||||
fDestMenuField->MenuItem()->SetLabel(((PartitionMenuItem *)fDestMenu->ItemAt(0))->MenuLabel());
|
||||
else {
|
||||
fDestMenuField->MenuItem()->SetLabel(
|
||||
((PartitionMenuItem *)fDestMenu->ItemAt(0))->MenuLabel());
|
||||
}
|
||||
}
|
||||
char message[255];
|
||||
sprintf(message, "Press the Begin button to install from '%s' onto '%s'",
|
||||
|
Loading…
Reference in New Issue
Block a user