* Report inaccessible memory
* Use IEC binary prefixes git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37182 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005-2009, Haiku, Inc.
|
* Copyright (c) 2005-2010, Haiku, Inc.
|
||||||
* Distributed under the terms of the MIT license.
|
* Distributed under the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* DarkWyrm <[email protected]>
|
* DarkWyrm <[email protected]>
|
||||||
* René Gollent
|
* René Gollent
|
||||||
|
* Wim van der Meer <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -65,9 +66,12 @@
|
|||||||
|
|
||||||
|
|
||||||
static const char* UptimeToString(char string[], size_t size);
|
static const char* UptimeToString(char string[], size_t size);
|
||||||
|
static const char* MemSizeToString(char string[], size_t size,
|
||||||
|
system_info* info);
|
||||||
static const char* MemUsageToString(char string[], size_t size,
|
static const char* MemUsageToString(char string[], size_t size,
|
||||||
system_info* info);
|
system_info* info);
|
||||||
|
|
||||||
|
|
||||||
static const rgb_color kDarkGrey = { 100, 100, 100, 255 };
|
static const rgb_color kDarkGrey = { 100, 100, 100, 255 };
|
||||||
static const rgb_color kHaikuGreen = { 42, 131, 36, 255 };
|
static const rgb_color kHaikuGreen = { 42, 131, 36, 255 };
|
||||||
static const rgb_color kHaikuOrange = { 255, 69, 0, 255 };
|
static const rgb_color kHaikuOrange = { 255, 69, 0, 255 };
|
||||||
@@ -537,6 +541,10 @@ AboutView::AboutView()
|
|||||||
B_ALIGN_VERTICAL_UNSET));
|
B_ALIGN_VERTICAL_UNSET));
|
||||||
|
|
||||||
// RAM
|
// RAM
|
||||||
|
BStringView *memSizeView = new BStringView("ramsizetext",
|
||||||
|
MemSizeToString(string, sizeof(string), &systemInfo));
|
||||||
|
memSizeView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
||||||
|
B_ALIGN_VERTICAL_UNSET));
|
||||||
fMemView = new BStringView("ramtext",
|
fMemView = new BStringView("ramtext",
|
||||||
MemUsageToString(string, sizeof(string), &systemInfo));
|
MemUsageToString(string, sizeof(string), &systemInfo));
|
||||||
fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
fMemView->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
|
||||||
@@ -576,6 +584,7 @@ AboutView::AboutView()
|
|||||||
.Add(frequencyView)
|
.Add(frequencyView)
|
||||||
.AddStrut(offset)
|
.AddStrut(offset)
|
||||||
.Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:")))
|
.Add(_CreateLabel("memlabel", B_TRANSLATE("Memory:")))
|
||||||
|
.Add(memSizeView)
|
||||||
.Add(fMemView)
|
.Add(fMemView)
|
||||||
.AddStrut(offset)
|
.AddStrut(offset)
|
||||||
.Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:")))
|
.Add(_CreateLabel("kernellabel", B_TRANSLATE("Kernel:")))
|
||||||
@@ -1669,13 +1678,30 @@ AboutView::_AddPackageCredit(const PackageCredit& package)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
static const char*
|
||||||
|
MemSizeToString(char string[], size_t size, system_info* info)
|
||||||
|
{
|
||||||
|
int inaccessibleMemory = int(info->ignored_pages
|
||||||
|
* (B_PAGE_SIZE / 1048576.0f) + 0.5f);
|
||||||
|
if (inaccessibleMemory > 0) {
|
||||||
|
snprintf(string, size, B_TRANSLATE("%d MiB total, %d MiB inaccessible"),
|
||||||
|
int((info->max_pages + info->ignored_pages)
|
||||||
|
* (B_PAGE_SIZE / 1048576.0f) + 0.5f), inaccessibleMemory);
|
||||||
|
} else {
|
||||||
|
snprintf(string, size, B_TRANSLATE("%d MiB total"),
|
||||||
|
int(info->max_pages * (B_PAGE_SIZE / 1048576.0f) + 0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
MemUsageToString(char string[], size_t size, system_info* info)
|
MemUsageToString(char string[], size_t size, system_info* info)
|
||||||
{
|
{
|
||||||
snprintf(string, size, B_TRANSLATE("%d MB total, %d MB used (%d%%)"),
|
snprintf(string, size, B_TRANSLATE("%d MiB used (%d%%)"),
|
||||||
int(info->max_pages * (B_PAGE_SIZE / 1048576.0f) + 0.5f),
|
int(info->used_pages * (B_PAGE_SIZE / 1048576.0f) + 0.5f),
|
||||||
int(info->used_pages * (B_PAGE_SIZE / 1048576.0f) + 0.5f),
|
int(100 * info->used_pages / info->max_pages));
|
||||||
int(100 * info->used_pages / info->max_pages));
|
|
||||||
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user