some changes : alert if free space isn't enough, set status when mouse is over packages (doesn't work for some reason ...)
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16192 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d6b6f8bfe1
commit
a5fa64b505
@ -53,7 +53,8 @@ private:
|
||||
CopyEngine::CopyEngine(InstallerWindow *window)
|
||||
: BLooper("copy_engine"),
|
||||
fWindow(window),
|
||||
fPackages(NULL)
|
||||
fPackages(NULL),
|
||||
fSpaceRequired(0)
|
||||
{
|
||||
fControl = new InstallerCopyLoopControl(window);
|
||||
Run();
|
||||
@ -119,22 +120,35 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
||||
fprintf(stderr, "bad menu items\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// check if target is initialized
|
||||
// ask if init or mount as is
|
||||
|
||||
BPath targetDirectory;
|
||||
BDiskDevice device;
|
||||
BPartition *partition;
|
||||
BVolume targetVolume;
|
||||
|
||||
if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) {
|
||||
if (partition->GetVolume(&targetVolume)!=B_OK)
|
||||
return;
|
||||
if (partition->GetMountPoint(&targetDirectory)!=B_OK)
|
||||
return;
|
||||
} else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) {
|
||||
if (device.GetVolume(&targetVolume)!=B_OK)
|
||||
return;
|
||||
if (device.GetMountPoint(&targetDirectory)!=B_OK)
|
||||
return;
|
||||
} else
|
||||
return; // shouldn't happen
|
||||
|
||||
// check if target is initialized
|
||||
// ask if init or mount as is
|
||||
// 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,
|
||||
B_WIDTH_AS_USUAL, B_STOP_ALERT))->Go() != 0)) {
|
||||
return;
|
||||
}
|
||||
|
||||
BPath srcDirectory;
|
||||
if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) {
|
||||
|
@ -27,6 +27,7 @@ public:
|
||||
void Start(BMenu *srcMenu, BMenu *targetMenu);
|
||||
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);
|
||||
void SetPackagesList(BList *list);
|
||||
void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; };
|
||||
private:
|
||||
void LaunchInitScript(BPath &path);
|
||||
void LaunchFinishScript(BPath &path);
|
||||
@ -36,6 +37,7 @@ private:
|
||||
BDiskDeviceRoster fDDRoster;
|
||||
InstallerCopyLoopControl *fControl;
|
||||
BList *fPackages;
|
||||
off_t fSpaceRequired;
|
||||
};
|
||||
|
||||
#endif /* _CopyEngine_h */
|
||||
|
@ -136,7 +136,7 @@ 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") - 10;
|
||||
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);
|
||||
fSizeView->SetAlignment(B_ALIGN_RIGHT);
|
||||
fBackBox->AddChild(fSizeView);
|
||||
@ -170,6 +170,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
||||
int32 size = 0;
|
||||
fPackagesView->GetPackagesToInstall(list, &size);
|
||||
fCopyEngine->SetPackagesList(list);
|
||||
fCopyEngine->SetSpaceRequired(size);
|
||||
BMessenger(fCopyEngine).SendMessage(ENGINE_START);
|
||||
DisableInterface(true);
|
||||
break;
|
||||
@ -197,8 +198,11 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
||||
}
|
||||
case STATUS_MESSAGE: {
|
||||
const char *status;
|
||||
if (msg->FindString("status", &status) == B_OK)
|
||||
if (msg->FindString("status", &status) == B_OK) {
|
||||
fLastStatus = fStatusView->Text();
|
||||
SetStatusMessage(status);
|
||||
} else
|
||||
SetStatusMessage(fLastStatus.String());
|
||||
}
|
||||
case INSTALL_FINISHED:
|
||||
DisableInterface(false);
|
||||
|
@ -55,6 +55,7 @@ private:
|
||||
BBitmap *fLogo;
|
||||
BPoint fDrawPoint;
|
||||
CopyEngine *fCopyEngine;
|
||||
BString fLastStatus;
|
||||
};
|
||||
|
||||
#endif /* _InstallerWindow_h */
|
||||
|
@ -6,11 +6,13 @@
|
||||
#include <fs_attr.h>
|
||||
#include <Directory.h>
|
||||
#include <Entry.h>
|
||||
#include <Messenger.h>
|
||||
#include <ScrollBar.h>
|
||||
#include <String.h>
|
||||
#include <stdio.h>
|
||||
#include <View.h>
|
||||
#include "PackageViews.h"
|
||||
#include "InstallerWindow.h"
|
||||
|
||||
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
|
||||
|
||||
@ -149,6 +151,22 @@ PackageCheckBox::Draw(BRect update)
|
||||
DrawBitmap(icon, BPoint(Bounds().right - 92, 0));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PackageCheckBox::MouseMoved(BPoint point, uint32 transit, const BMessage *message)
|
||||
{
|
||||
printf("coucouc\n");
|
||||
if (transit == B_ENTERED_VIEW) {
|
||||
BMessage msg(STATUS_MESSAGE);
|
||||
msg.AddString("status", fPackage->Description());
|
||||
BMessenger(NULL, Window()).SendMessage(&msg);
|
||||
} else if (transit == B_EXITED_VIEW) {
|
||||
BMessage msg(STATUS_MESSAGE);
|
||||
BMessenger(NULL, Window()).SendMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GroupView::GroupView(BRect rect, Group *group)
|
||||
: BStringView(rect, "group", group->GroupName()),
|
||||
fGroup(group)
|
||||
|
@ -60,6 +60,7 @@ class PackageCheckBox : public BCheckBox {
|
||||
PackageCheckBox(BRect rect, Package *item);
|
||||
virtual ~PackageCheckBox();
|
||||
virtual void Draw(BRect update);
|
||||
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||
Package *GetPackage() { return fPackage; };
|
||||
private:
|
||||
Package *fPackage;
|
||||
|
Loading…
Reference in New Issue
Block a user