memory percent

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@571 e54a6e83-5905-42d5-8d5c-058d10e6a962


Origin commit data
------------------
Commit: 393ef2a20d
Author: Jacek Jendrzej <overx300@gmail.com>
Date: 2010-05-06 (Thu, 06 May 2010)
This commit is contained in:
Jacek Jendrzej
2010-05-06 14:16:33 +00:00
parent 1543c84b7b
commit 3ca30ded7c

View File

@@ -223,14 +223,34 @@ void CDBoxInfoWidget::paint()
ypos+= mheight/2; ypos+= mheight/2;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, sbuf, COL_MENUCONTENT); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, sbuf, COL_MENUCONTENT);
ypos+= mheight; ypos+= mheight;
snprintf(ubuf,buf_size, "memory total %dKb, free %dKb", (int) info.totalram/1024, (int) info.freeram/1024);
ypos+= mheight/2;
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ 10, ypos+ mheight, width - 10, ubuf, COL_MENUCONTENT);
ypos+= mheight;
int headOffset=0; int headOffset=0;
int mpOffset=0; int mpOffset=0;
bool rec_mp=false; bool rec_mp=false, memory_flag = false;
// paint mount head
for (int j = 0; j < headSize; j++) {
switch (j)
{
case 0:
headOffset = 10;
break;
case 1:
headOffset = nameOffset + 20;
break;
case 2:
headOffset = nameOffset + sizeOffset+10 +20;
break;
case 3:
headOffset = nameOffset + (sizeOffset+10)*2+15;
break;
case 4:
headOffset = nameOffset + (sizeOffset+10)*3+15;
break;
}
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset, ypos+ mheight, width - 10, head[j], COL_MENUCONTENTINACTIVE);
}
ypos+= mheight;
if ((mountFile = setmntent("/proc/mounts", "r")) == 0 ) { if ((mountFile = setmntent("/proc/mounts", "r")) == 0 ) {
perror("/proc/mounts"); perror("/proc/mounts");
} }
@@ -253,31 +273,10 @@ void CDBoxInfoWidget::paint()
c = 'G'; c = 'G';
break; break;
case (int) 0x72b6: /*jffs2*/ case (int) 0x72b6: /*jffs2*/
if (strcmp(mnt->mnt_fsname, "rootfs") == 0) if (strcmp(mnt->mnt_fsname, "rootfs") == 0){
continue; strcpy(mnt->mnt_fsname,"memory");
// paint mount head memory_flag = true;
for (int j = 0; j < headSize; j++) {
switch (j)
{
case 0:
headOffset = 10;
break;
case 1:
headOffset = nameOffset + 20;
break;
case 2:
headOffset = nameOffset + sizeOffset+10 +20;
break;
case 3:
headOffset = nameOffset + (sizeOffset+10)*2+15;
break;
case 4:
headOffset = nameOffset + (sizeOffset+10)*3+15;
break;
}
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+ headOffset, ypos+ mheight, width - 10, head[j], COL_MENUCONTENTINACTIVE);
} }
ypos+= mheight;
gb = 1024.0; gb = 1024.0;
c = 'M'; c = 'M';
@@ -285,11 +284,14 @@ void CDBoxInfoWidget::paint()
default: default:
continue; continue;
} }
if ( s.f_blocks > 0 ) { if ( s.f_blocks > 0 || memory_flag ) {
long blocks_used; long blocks_used;
long blocks_percent_used; long blocks_percent_used;
blocks_used = s.f_blocks - s.f_bfree; blocks_used = s.f_blocks - s.f_bfree;
blocks_percent_used = (long)(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5); if(memory_flag){
blocks_percent_used = (info.totalram/1024 - info.freeram/1024)*100/(info.totalram/1024);
}else
blocks_percent_used = (long)(blocks_used * 100.0 / (blocks_used + s.f_bavail) + 0.5);
//paint mountpoints //paint mountpoints
for (int j = 0; j < headSize; j++) { for (int j = 0; j < headSize; j++) {
switch (j) switch (j)
@@ -318,15 +320,25 @@ void CDBoxInfoWidget::paint()
break; break;
case 1: case 1:
mpOffset = nameOffset + 10; mpOffset = nameOffset + 10;
snprintf(ubuf,buf_size,"%7.2f%c", (s.f_blocks * (s.f_bsize / 1024.0)) / gb, c); if(memory_flag)
snprintf(ubuf,buf_size,"%7.2f%c", info.totalram/1024.0 / gb, c);
else
snprintf(ubuf,buf_size,"%7.2f%c", (s.f_blocks * (s.f_bsize / 1024.0)) / gb, c);
break; break;
case 2: case 2:
mpOffset = nameOffset+ (sizeOffset+10)*1+10; mpOffset = nameOffset+ (sizeOffset+10)*1+10;
snprintf(ubuf,buf_size,"%7.2f%c", ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)) / gb, c); if(memory_flag)
snprintf(ubuf,buf_size,"%7.2f%c", (info.totalram/1024.0 - info.freeram/1024.0) / gb, c);
else
snprintf(ubuf,buf_size,"%7.2f%c", ((s.f_blocks - s.f_bfree) * (s.f_bsize / 1024.0)) / gb, c);
break; break;
case 3: case 3:
mpOffset = nameOffset+ (sizeOffset+10)*2+10; mpOffset = nameOffset+ (sizeOffset+10)*2+10;
snprintf(ubuf,buf_size,"%7.2f%c", s.f_bavail * (s.f_bsize / 1024.0) / gb, c); if(memory_flag)
snprintf(ubuf,buf_size,"%7.2f%c", info.freeram / 1024.0 / gb, c);
else
snprintf(ubuf,buf_size,"%7.2f%c", s.f_bavail * (s.f_bsize / 1024.0) / gb, c);
break; break;
case 4: case 4:
mpOffset = nameOffset+ (sizeOffset+10)*3+10; mpOffset = nameOffset+ (sizeOffset+10)*3+10;
@@ -337,6 +349,7 @@ void CDBoxInfoWidget::paint()
rec_mp = false; rec_mp = false;
} }
int pbw = width - offsetw - 10; int pbw = width - offsetw - 10;
memory_flag = false;
//fprintf(stderr, "width: %d offsetw: %d pbw: %d\n", width, offsetw, pbw); //fprintf(stderr, "width: %d offsetw: %d pbw: %d\n", width, offsetw, pbw);
if (pbw > 8) /* smaller progressbar is not useful ;) */ if (pbw > 8) /* smaller progressbar is not useful ;) */
{ {