[Xfce4-commits] <xfce4-taskmanager:master> Display memory values < 1 MiB
Mike Massonnet
noreply at xfce.org
Mon May 10 18:00:01 CEST 2010
Updating branch refs/heads/master
to 7239d4bbb0e9ecf5a3d800632ca3dedc885e1595 (commit)
from 9a6cdd2ff3ac57746a56dbe19439838e7761210f (commit)
commit 7239d4bbb0e9ecf5a3d800632ca3dedc885e1595
Author: Mike Massonnet <mmassonnet at gmail.com>
Date: Mon May 10 17:57:51 2010 +0200
Display memory values < 1 MiB
Fixed the MB “typo” and show values for memory in KiB or B if needed.
The threshold for displaying KiB (< 4 MiB) or B (< 9 KiB) are based on
impulse.
src/task-manager.c | 27 ++++++++++++++++++++++++---
1 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/src/task-manager.c b/src/task-manager.c
index 4620c12..d878eb2 100644
--- a/src/task-manager.c
+++ b/src/task-manager.c
@@ -136,13 +136,34 @@ model_add_task (GtkTreeModel *model, Task *task)
}
static void
+memory_human_size (guint64 mem, gchar *mem_str)
+{
+ guint64 mem_tmp;
+
+ mem_tmp = mem / 1024 / 1024;
+ if (mem_tmp > 3)
+ {
+ g_snprintf (mem_str, 64, _("%lu MiB"), mem_tmp);
+ return;
+ }
+
+ mem_tmp = mem / 1024;
+ if (mem_tmp > 8)
+ {
+ g_snprintf (mem_str, 64, _("%lu KiB"), mem_tmp);
+ return;
+ }
+
+ g_snprintf (mem_str, 64, _("%lu B"), mem);
+}
+
+static void
model_update_tree_iter (GtkTreeModel *model, GtkTreeIter *iter, Task *task)
{
gchar vsz[64], rss[64], cpu[16];
- // TODO show values < 1 MB in KB or B
- g_snprintf (vsz, 64, _("%lu MB"), task->vsz / 1024 / 1024);
- g_snprintf (rss, 64, _("%lu MB"), task->rss / 1024 / 1024);
+ memory_human_size (task->vsz, vsz);
+ memory_human_size (task->rss, rss);
// TODO make precision optional
g_snprintf (cpu, 16, _("%.2f%%"), task->cpu_user + task->cpu_system);
More information about the Xfce4-commits
mailing list