Imported InfoWindow.cpp 1.14 from the OT repository: the "Disks" info window no
longer calculates the size by iterating over all files - it now just adds up the disk capacities. This fixes the userland part of bug #210 - the kernel part has already been fixed earlier. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16599 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -133,7 +133,8 @@ OpenParentAndSelectOriginal(const entry_ref *ref)
|
|||||||
|
|
||||||
|
|
||||||
static BWindow *
|
static BWindow *
|
||||||
OpenToolTipWindow(BRect rect, const char *name, const char *string, BMessenger target, BFont &font, BMessage *message)
|
OpenToolTipWindow(BRect rect, const char *name, const char *string,
|
||||||
|
BMessenger target, BFont &font, BMessage *message)
|
||||||
{
|
{
|
||||||
BWindow *window = new BWindow(rect, name, B_BORDERED_WINDOW_LOOK,
|
BWindow *window = new BWindow(rect, name, B_BORDERED_WINDOW_LOOK,
|
||||||
B_FLOATING_ALL_WINDOW_FEEL,
|
B_FLOATING_ALL_WINDOW_FEEL,
|
||||||
@@ -261,7 +262,7 @@ BInfoWindow::Show()
|
|||||||
ResizeTo(windRect.Width(), windRect.Height());
|
ResizeTo(windRect.Width(), windRect.Height());
|
||||||
|
|
||||||
// volume case is handled by view
|
// volume case is handled by view
|
||||||
if (!TargetModel()->IsVolume()) {
|
if (!TargetModel()->IsVolume() && !TargetModel()->IsRoot()) {
|
||||||
if (TargetModel()->IsDirectory()) {
|
if (TargetModel()->IsDirectory()) {
|
||||||
// if this is a folder then spawn thread to calculate size
|
// if this is a folder then spawn thread to calculate size
|
||||||
SetSizeStr("calculating" B_UTF8_ELLIPSIS);
|
SetSizeStr("calculating" B_UTF8_ELLIPSIS);
|
||||||
@@ -586,7 +587,6 @@ BInfoWindow::CalcSize(void *castToWindow)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
window->SetSizeStr("Error calculating folder size.");
|
window->SetSizeStr("Error calculating folder size.");
|
||||||
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1102,7 +1102,7 @@ AttributeView::MouseDown(BPoint point)
|
|||||||
} else if (fTitleEditView) {
|
} else if (fTitleEditView) {
|
||||||
FinishEditingTitle(true);
|
FinishEditingTitle(true);
|
||||||
} else if (fSizeRect.Contains(point)) {
|
} else if (fSizeRect.Contains(point)) {
|
||||||
if (fModel->IsDirectory() && !fModel->IsVolume()) {
|
if (fModel->IsDirectory() && !fModel->IsVolume() && !fModel->IsRoot()) {
|
||||||
InvertRect(fSizeRect);
|
InvertRect(fSizeRect);
|
||||||
fTrackingState = size_track;
|
fTrackingState = size_track;
|
||||||
} else
|
} else
|
||||||
@@ -1356,7 +1356,6 @@ AttributeView::OpenLinkTarget()
|
|||||||
BInfoWindow *window = dynamic_cast<BInfoWindow *>(Window());
|
BInfoWindow *window = dynamic_cast<BInfoWindow *>(Window());
|
||||||
if (window)
|
if (window)
|
||||||
window->OpenFilePanel(fModel->EntryRef());
|
window->OpenFilePanel(fModel->EntryRef());
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
entry_ref ref;
|
entry_ref ref;
|
||||||
entry.GetRef(&ref);
|
entry.GetRef(&ref);
|
||||||
@@ -1409,14 +1408,28 @@ AttributeView::MouseUp(BPoint point)
|
|||||||
void
|
void
|
||||||
AttributeView::CheckAndSetSize()
|
AttributeView::CheckAndSetSize()
|
||||||
{
|
{
|
||||||
|
if (fModel->IsVolume() || fModel->IsRoot()) {
|
||||||
|
off_t freeBytes = 0;
|
||||||
|
off_t capacity = 0;
|
||||||
|
|
||||||
if (fModel->IsVolume()) {
|
if (fModel->IsVolume()) {
|
||||||
BVolume volume(fModel->NodeRef()->device);
|
BVolume volume(fModel->NodeRef()->device);
|
||||||
off_t freeBytes = volume.FreeBytes();
|
freeBytes = volume.FreeBytes();
|
||||||
|
capacity = volume.Capacity();
|
||||||
|
} else {
|
||||||
|
// iterate over all volumes
|
||||||
|
BVolumeRoster volumeRoster;
|
||||||
|
BVolume volume;
|
||||||
|
while (volumeRoster.GetNextVolume(&volume) == B_OK) {
|
||||||
|
freeBytes += volume.FreeBytes();
|
||||||
|
capacity += volume.Capacity();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (fFreeBytes == freeBytes)
|
if (fFreeBytes == freeBytes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
fFreeBytes = freeBytes;
|
fFreeBytes = freeBytes;
|
||||||
off_t capacity = volume.Capacity();
|
|
||||||
char buffer[500];
|
char buffer[500];
|
||||||
if (capacity >= kGBSize)
|
if (capacity >= kGBSize)
|
||||||
sprintf(buffer, "%.1f G", (float)capacity / kGBSize);
|
sprintf(buffer, "%.1f G", (float)capacity / kGBSize);
|
||||||
@@ -1478,7 +1491,6 @@ AttributeView::MessageReceived(BMessage *message)
|
|||||||
|
|
||||||
fModel->SetPreferredAppSignature(newSignature);
|
fModel->SetPreferredAppSignature(newSignature);
|
||||||
nodeInfo.SetPreferredApp(newSignature);
|
nodeInfo.SetPreferredApp(newSignature);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1557,7 +1569,7 @@ AttributeView::Draw(BRect)
|
|||||||
|
|
||||||
// Capacity/size
|
// Capacity/size
|
||||||
SetHighColor(kAttrTitleColor);
|
SetHighColor(kAttrTitleColor);
|
||||||
if (fModel->IsVolume()) {
|
if (fModel->IsVolume() || fModel->IsRoot()) {
|
||||||
MovePenTo(BPoint(fDivider - (StringWidth("Capacity:")), lineBase));
|
MovePenTo(BPoint(fDivider - (StringWidth("Capacity:")), lineBase));
|
||||||
DrawString("Capacity:");
|
DrawString("Capacity:");
|
||||||
} else {
|
} else {
|
||||||
@@ -1909,13 +1921,15 @@ AttributeView::BuildContextMenu(BMenu *parent)
|
|||||||
parent->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash)));
|
parent->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash)));
|
||||||
|
|
||||||
BMenuItem *sizeItem = NULL;
|
BMenuItem *sizeItem = NULL;
|
||||||
if (model.IsDirectory() && !model.IsVolume())
|
if (model.IsDirectory() && !model.IsVolume() && !model.IsRoot()) {
|
||||||
parent->AddItem(sizeItem = new BMenuItem("Recalculate Folder Size",
|
parent->AddItem(sizeItem = new BMenuItem("Recalculate Folder Size",
|
||||||
new BMessage(kRecalculateSize)));
|
new BMessage(kRecalculateSize)));
|
||||||
|
}
|
||||||
|
|
||||||
if (model.IsSymLink())
|
if (model.IsSymLink()) {
|
||||||
parent->AddItem(sizeItem = new BMenuItem("Set new link target",
|
parent->AddItem(sizeItem = new BMenuItem("Set new link target",
|
||||||
new BMessage(kSetLinkTarget)));
|
new BMessage(kSetLinkTarget)));
|
||||||
|
}
|
||||||
|
|
||||||
parent->AddItem(new BSeparatorItem());
|
parent->AddItem(new BSeparatorItem());
|
||||||
parent->AddItem(new BMenuItem("Permissions", new BMessage(kPermissionsSelected), 'P'));
|
parent->AddItem(new BMenuItem("Permissions", new BMessage(kPermissionsSelected), 'P'));
|
||||||
@@ -2035,7 +2049,9 @@ void
|
|||||||
TrackingView::MouseUp(BPoint)
|
TrackingView::MouseUp(BPoint)
|
||||||
{
|
{
|
||||||
if (Message() != NULL) {
|
if (Message() != NULL) {
|
||||||
if (fMouseInView) Invoke();
|
if (fMouseInView)
|
||||||
|
Invoke();
|
||||||
|
|
||||||
fMouseDown = false;
|
fMouseDown = false;
|
||||||
Window()->Close();
|
Window()->Close();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user