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:
@@ -53,7 +53,8 @@ private:
|
|||||||
CopyEngine::CopyEngine(InstallerWindow *window)
|
CopyEngine::CopyEngine(InstallerWindow *window)
|
||||||
: BLooper("copy_engine"),
|
: BLooper("copy_engine"),
|
||||||
fWindow(window),
|
fWindow(window),
|
||||||
fPackages(NULL)
|
fPackages(NULL),
|
||||||
|
fSpaceRequired(0)
|
||||||
{
|
{
|
||||||
fControl = new InstallerCopyLoopControl(window);
|
fControl = new InstallerCopyLoopControl(window);
|
||||||
Run();
|
Run();
|
||||||
@@ -119,22 +120,35 @@ CopyEngine::Start(BMenu *srcMenu, BMenu *targetMenu)
|
|||||||
fprintf(stderr, "bad menu items\n");
|
fprintf(stderr, "bad menu items\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// check if target is initialized
|
||||||
|
// ask if init or mount as is
|
||||||
|
|
||||||
BPath targetDirectory;
|
BPath targetDirectory;
|
||||||
BDiskDevice device;
|
BDiskDevice device;
|
||||||
BPartition *partition;
|
BPartition *partition;
|
||||||
|
BVolume targetVolume;
|
||||||
|
|
||||||
if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) {
|
if (fDDRoster.GetPartitionWithID(targetItem->ID(), &device, &partition) == B_OK) {
|
||||||
|
if (partition->GetVolume(&targetVolume)!=B_OK)
|
||||||
|
return;
|
||||||
if (partition->GetMountPoint(&targetDirectory)!=B_OK)
|
if (partition->GetMountPoint(&targetDirectory)!=B_OK)
|
||||||
return;
|
return;
|
||||||
} else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) {
|
} else if (fDDRoster.GetDeviceWithID(targetItem->ID(), &device) == B_OK) {
|
||||||
|
if (device.GetVolume(&targetVolume)!=B_OK)
|
||||||
|
return;
|
||||||
if (device.GetMountPoint(&targetDirectory)!=B_OK)
|
if (device.GetMountPoint(&targetDirectory)!=B_OK)
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
return; // shouldn't happen
|
return; // shouldn't happen
|
||||||
|
|
||||||
// check if target is initialized
|
|
||||||
// ask if init or mount as is
|
|
||||||
// check if target has enough space
|
// 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;
|
BPath srcDirectory;
|
||||||
if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) {
|
if (fDDRoster.GetPartitionWithID(srcItem->ID(), &device, &partition) == B_OK) {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
void Start(BMenu *srcMenu, BMenu *targetMenu);
|
void Start(BMenu *srcMenu, BMenu *targetMenu);
|
||||||
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);
|
void ScanDisksPartitions(BMenu *srcMenu, BMenu *targetMenu);
|
||||||
void SetPackagesList(BList *list);
|
void SetPackagesList(BList *list);
|
||||||
|
void SetSpaceRequired(off_t bytes) { fSpaceRequired = bytes; };
|
||||||
private:
|
private:
|
||||||
void LaunchInitScript(BPath &path);
|
void LaunchInitScript(BPath &path);
|
||||||
void LaunchFinishScript(BPath &path);
|
void LaunchFinishScript(BPath &path);
|
||||||
@@ -36,6 +37,7 @@ private:
|
|||||||
BDiskDeviceRoster fDDRoster;
|
BDiskDeviceRoster fDDRoster;
|
||||||
InstallerCopyLoopControl *fControl;
|
InstallerCopyLoopControl *fControl;
|
||||||
BList *fPackages;
|
BList *fPackages;
|
||||||
|
off_t fSpaceRequired;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _CopyEngine_h */
|
#endif /* _CopyEngine_h */
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
|
|||||||
sizeRect.top = 105;
|
sizeRect.top = 105;
|
||||||
sizeRect.bottom = sizeRect.top + 15;
|
sizeRect.bottom = sizeRect.top + 15;
|
||||||
sizeRect.right -= 12;
|
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 = new BStringView(sizeRect, "size_view", "Disk space required: 0.0 KB", B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
|
||||||
fSizeView->SetAlignment(B_ALIGN_RIGHT);
|
fSizeView->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fBackBox->AddChild(fSizeView);
|
fBackBox->AddChild(fSizeView);
|
||||||
@@ -170,6 +170,7 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
|||||||
int32 size = 0;
|
int32 size = 0;
|
||||||
fPackagesView->GetPackagesToInstall(list, &size);
|
fPackagesView->GetPackagesToInstall(list, &size);
|
||||||
fCopyEngine->SetPackagesList(list);
|
fCopyEngine->SetPackagesList(list);
|
||||||
|
fCopyEngine->SetSpaceRequired(size);
|
||||||
BMessenger(fCopyEngine).SendMessage(ENGINE_START);
|
BMessenger(fCopyEngine).SendMessage(ENGINE_START);
|
||||||
DisableInterface(true);
|
DisableInterface(true);
|
||||||
break;
|
break;
|
||||||
@@ -197,8 +198,11 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
|||||||
}
|
}
|
||||||
case STATUS_MESSAGE: {
|
case STATUS_MESSAGE: {
|
||||||
const char *status;
|
const char *status;
|
||||||
if (msg->FindString("status", &status) == B_OK)
|
if (msg->FindString("status", &status) == B_OK) {
|
||||||
|
fLastStatus = fStatusView->Text();
|
||||||
SetStatusMessage(status);
|
SetStatusMessage(status);
|
||||||
|
} else
|
||||||
|
SetStatusMessage(fLastStatus.String());
|
||||||
}
|
}
|
||||||
case INSTALL_FINISHED:
|
case INSTALL_FINISHED:
|
||||||
DisableInterface(false);
|
DisableInterface(false);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ private:
|
|||||||
BBitmap *fLogo;
|
BBitmap *fLogo;
|
||||||
BPoint fDrawPoint;
|
BPoint fDrawPoint;
|
||||||
CopyEngine *fCopyEngine;
|
CopyEngine *fCopyEngine;
|
||||||
|
BString fLastStatus;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _InstallerWindow_h */
|
#endif /* _InstallerWindow_h */
|
||||||
|
|||||||
@@ -6,11 +6,13 @@
|
|||||||
#include <fs_attr.h>
|
#include <fs_attr.h>
|
||||||
#include <Directory.h>
|
#include <Directory.h>
|
||||||
#include <Entry.h>
|
#include <Entry.h>
|
||||||
|
#include <Messenger.h>
|
||||||
#include <ScrollBar.h>
|
#include <ScrollBar.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include "PackageViews.h"
|
#include "PackageViews.h"
|
||||||
|
#include "InstallerWindow.h"
|
||||||
|
|
||||||
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
|
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
|
||||||
|
|
||||||
@@ -149,6 +151,22 @@ PackageCheckBox::Draw(BRect update)
|
|||||||
DrawBitmap(icon, BPoint(Bounds().right - 92, 0));
|
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)
|
GroupView::GroupView(BRect rect, Group *group)
|
||||||
: BStringView(rect, "group", group->GroupName()),
|
: BStringView(rect, "group", group->GroupName()),
|
||||||
fGroup(group)
|
fGroup(group)
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class PackageCheckBox : public BCheckBox {
|
|||||||
PackageCheckBox(BRect rect, Package *item);
|
PackageCheckBox(BRect rect, Package *item);
|
||||||
virtual ~PackageCheckBox();
|
virtual ~PackageCheckBox();
|
||||||
virtual void Draw(BRect update);
|
virtual void Draw(BRect update);
|
||||||
|
virtual void MouseMoved(BPoint point, uint32 transit, const BMessage *message);
|
||||||
Package *GetPackage() { return fPackage; };
|
Package *GetPackage() { return fPackage; };
|
||||||
private:
|
private:
|
||||||
Package *fPackage;
|
Package *fPackage;
|
||||||
|
|||||||
Reference in New Issue
Block a user