* Remember in PartitionMenuItem if a partition is a suitable install target.
* Show non-BFS partitions again, but show them disabled and show the content type in the menu label. BFS partitions don't get the content type shown, so that it looks more like the reason why they are disabled if the content type is shown. * Small cleanups. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30611 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -633,18 +633,17 @@ InstallerWindow::_UpdateControls()
|
|||||||
}
|
}
|
||||||
fSrcMenuField->MenuItem()->SetLabel(label.String());
|
fSrcMenuField->MenuItem()->SetLabel(label.String());
|
||||||
|
|
||||||
if (srcItem) {
|
// Disable any unsuitable target items
|
||||||
// Prevent the user from having picked the same partition as source
|
|
||||||
// and destination.
|
|
||||||
for (int32 i = fDestMenu->CountItems() - 1; i >= 0; i--) {
|
for (int32 i = fDestMenu->CountItems() - 1; i >= 0; i--) {
|
||||||
PartitionMenuItem* dstItem
|
PartitionMenuItem* dstItem
|
||||||
= (PartitionMenuItem*)fDestMenu->ItemAt(i);
|
= (PartitionMenuItem*)fDestMenu->ItemAt(i);
|
||||||
if (dstItem->ID() == srcItem->ID()) {
|
if (srcItem != NULL && dstItem->ID() == srcItem->ID()) {
|
||||||
|
// Prevent the user from having picked the same partition as source
|
||||||
|
// and destination.
|
||||||
dstItem->SetEnabled(false);
|
dstItem->SetEnabled(false);
|
||||||
dstItem->SetMarked(false);
|
dstItem->SetMarked(false);
|
||||||
} else
|
} else
|
||||||
dstItem->SetEnabled(true);
|
dstItem->SetEnabled(dstItem->IsValidTarget());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PartitionMenuItem* dstItem = (PartitionMenuItem*)fDestMenu->FindMarked();
|
PartitionMenuItem* dstItem = (PartitionMenuItem*)fDestMenu->FindMarked();
|
||||||
|
|||||||
@@ -12,11 +12,12 @@
|
|||||||
PartitionMenuItem::PartitionMenuItem(const char* name, const char* label,
|
PartitionMenuItem::PartitionMenuItem(const char* name, const char* label,
|
||||||
const char* menuLabel, BMessage* message, partition_id id)
|
const char* menuLabel, BMessage* message, partition_id id)
|
||||||
:
|
:
|
||||||
BMenuItem(label, message)
|
BMenuItem(label, message),
|
||||||
|
fID(id),
|
||||||
|
fMenuLabel(strdup(menuLabel)),
|
||||||
|
fName(strdup(name)),
|
||||||
|
fIsValidTarget(true)
|
||||||
{
|
{
|
||||||
fID = id;
|
|
||||||
fMenuLabel = strdup(menuLabel);
|
|
||||||
fName = strdup(name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,13 +38,27 @@ PartitionMenuItem::ID() const
|
|||||||
const char*
|
const char*
|
||||||
PartitionMenuItem::MenuLabel() const
|
PartitionMenuItem::MenuLabel() const
|
||||||
{
|
{
|
||||||
return fMenuLabel ? fMenuLabel : Label();
|
return fMenuLabel != NULL ? fMenuLabel : Label();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
PartitionMenuItem::Name() const
|
PartitionMenuItem::Name() const
|
||||||
{
|
{
|
||||||
return fName ? fName : Label();
|
return fName != NULL ? fName : Label();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PartitionMenuItem::SetIsValidTarget(bool isValidTarget)
|
||||||
|
{
|
||||||
|
fIsValidTarget = isValidTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
PartitionMenuItem::IsValidTarget() const
|
||||||
|
{
|
||||||
|
return fIsValidTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,14 @@ public:
|
|||||||
const char* MenuLabel() const;
|
const char* MenuLabel() const;
|
||||||
const char* Name() const;
|
const char* Name() const;
|
||||||
|
|
||||||
|
void SetIsValidTarget(bool isValidTarget);
|
||||||
|
bool IsValidTarget() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
partition_id fID;
|
partition_id fID;
|
||||||
char* fMenuLabel;
|
char* fMenuLabel;
|
||||||
char* fName;
|
char* fName;
|
||||||
|
bool fIsValidTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTITION_MENU_ITEM_H_
|
#endif // PARTITION_MENU_ITEM_H_
|
||||||
|
|||||||
@@ -42,32 +42,34 @@
|
|||||||
|
|
||||||
const char BOOT_PATH[] = "/boot";
|
const char BOOT_PATH[] = "/boot";
|
||||||
|
|
||||||
extern void SizeAsString(off_t size, char *string);
|
extern void SizeAsString(off_t size, char* string);
|
||||||
|
|
||||||
|
|
||||||
const uint32 MSG_START_INSTALLING = 'eSRT';
|
const uint32 MSG_START_INSTALLING = 'eSRT';
|
||||||
|
|
||||||
|
|
||||||
class SourceVisitor : public BDiskDeviceVisitor
|
class SourceVisitor : public BDiskDeviceVisitor {
|
||||||
{
|
public:
|
||||||
public:
|
SourceVisitor(BMenu* menu);
|
||||||
SourceVisitor(BMenu *menu);
|
virtual bool Visit(BDiskDevice* device);
|
||||||
virtual bool Visit(BDiskDevice *device);
|
virtual bool Visit(BPartition* partition, int32 level);
|
||||||
virtual bool Visit(BPartition *partition, int32 level);
|
|
||||||
private:
|
private:
|
||||||
BMenu *fMenu;
|
BMenu* fMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TargetVisitor : public BDiskDeviceVisitor
|
class TargetVisitor : public BDiskDeviceVisitor {
|
||||||
{
|
public:
|
||||||
public:
|
TargetVisitor(BMenu* menu);
|
||||||
TargetVisitor(BMenu *menu);
|
virtual bool Visit(BDiskDevice* device);
|
||||||
virtual bool Visit(BDiskDevice *device);
|
virtual bool Visit(BPartition* partition, int32 level);
|
||||||
virtual bool Visit(BPartition *partition, int32 level);
|
|
||||||
private:
|
private:
|
||||||
void _MakeLabel(BPartition *partition, char *label, char *menuLabel);
|
void _MakeLabel(BPartition* partition, char* label, char* menuLabel,
|
||||||
BMenu *fMenu;
|
bool showContentType);
|
||||||
|
|
||||||
|
BMenu* fMenu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -532,13 +534,6 @@ TargetVisitor::Visit(BPartition *partition, int32 level)
|
|||||||
printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path());
|
printf("TargetVisitor::Visit(BPartition *) : %s\n", path.Path());
|
||||||
printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->ContentName());
|
printf("TargetVisitor::Visit(BPartition *) : %s\n", partition->ContentName());
|
||||||
|
|
||||||
if (partition->ContentType() == NULL
|
|
||||||
|| strcmp(partition->ContentType(), kPartitionTypeBFS) != 0) {
|
|
||||||
// Except only valid BFS partitions
|
|
||||||
printf(" not BFS\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (partition->ContentSize() < 20 * 1024 * 1024) {
|
if (partition->ContentSize() < 20 * 1024 * 1024) {
|
||||||
// reject partitions which are too small anyways
|
// reject partitions which are too small anyways
|
||||||
// TODO: Could depend on the source size
|
// TODO: Could depend on the source size
|
||||||
@@ -556,31 +551,46 @@ TargetVisitor::Visit(BPartition *partition, int32 level)
|
|||||||
// TODO: After running DriveSetup and doing another scan, it would
|
// TODO: After running DriveSetup and doing another scan, it would
|
||||||
// be great to pick the partition which just appeared!
|
// be great to pick the partition which just appeared!
|
||||||
|
|
||||||
|
// Only BFS partitions are valid targets, but we want to display the
|
||||||
|
// other partitions as well, in order not to irritate the user.
|
||||||
|
bool isValidTarget = partition->ContentType() != NULL
|
||||||
|
&& strcmp(partition->ContentType(), kPartitionTypeBFS) == 0;
|
||||||
|
|
||||||
char label[255], menuLabel[255];
|
char label[255], menuLabel[255];
|
||||||
_MakeLabel(partition, label, menuLabel);
|
_MakeLabel(partition, label, menuLabel, !isValidTarget);
|
||||||
fMenu->AddItem(new PartitionMenuItem(partition->ContentName(), label,
|
PartitionMenuItem* item = new PartitionMenuItem(partition->ContentName(),
|
||||||
menuLabel, new BMessage(TARGET_PARTITION), partition->ID()));
|
label, menuLabel, new BMessage(TARGET_PARTITION), partition->ID());
|
||||||
|
|
||||||
|
item->SetIsValidTarget(isValidTarget);
|
||||||
|
|
||||||
|
|
||||||
|
fMenu->AddItem(item);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TargetVisitor::_MakeLabel(BPartition *partition, char *label, char *menuLabel)
|
TargetVisitor::_MakeLabel(BPartition* partition, char* label, char* menuLabel,
|
||||||
|
bool showContentType)
|
||||||
{
|
{
|
||||||
char size[15];
|
char size[15];
|
||||||
SizeAsString(partition->ContentSize(), size);
|
SizeAsString(partition->ContentSize(), size);
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
partition->GetPath(&path);
|
partition->GetPath(&path);
|
||||||
|
|
||||||
// TODO: Reenable the printing of the content type once Haiku supports
|
if (showContentType) {
|
||||||
// installing to other file systems than BFS.
|
const char* type = partition->ContentType();
|
||||||
// sprintf(label, "%s - %s [%s] [%s]", partition->ContentName(),
|
if (type == NULL)
|
||||||
// size, partition->ContentType(), path.Path());
|
type = "Unknown Type";
|
||||||
// sprintf(menuLabel, "%s - %s [%s]", partition->ContentName(), size,
|
|
||||||
// partition->ContentType());
|
|
||||||
|
|
||||||
sprintf(label, "%s - %s - %s", partition->ContentName(), size,
|
sprintf(label, "%s - %s [%s] (%s)", partition->ContentName(), size,
|
||||||
|
path.Path(), type);
|
||||||
|
} else {
|
||||||
|
sprintf(label, "%s - %s [%s]", partition->ContentName(), size,
|
||||||
path.Path());
|
path.Path());
|
||||||
|
}
|
||||||
|
|
||||||
sprintf(menuLabel, "%s - %s", partition->ContentName(), size);
|
sprintf(menuLabel, "%s - %s", partition->ContentName(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user