diff options
author | Gerald Combs <gerald@wireshark.org> | 2012-10-10 19:17:31 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2012-10-10 19:17:31 +0000 |
commit | 98b0812341cc2d0fa146b10f086c72c968068cc6 (patch) | |
tree | 83957bdea6d4b21887e3d18c2dc53d540d306738 /ui/gtk/main_statusbar.c | |
parent | 2ea9adc0de37dac24226ae8a5451b6dd1d583c01 (diff) |
Add a format_size function similar to g_format_size that renders a size
value in a human-readable format. Use it in the welcome screen, status
bar, and Win32 interface details.
Note that in the welcome screen and status bar we've switched from
customary binary prefixes to strict SI.
svn path=/trunk/; revision=45453
Diffstat (limited to 'ui/gtk/main_statusbar.c')
-rw-r--r-- | ui/gtk/main_statusbar.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/ui/gtk/main_statusbar.c b/ui/gtk/main_statusbar.c index df6f77fdb2..0d363a0324 100644 --- a/ui/gtk/main_statusbar.c +++ b/ui/gtk/main_statusbar.c @@ -44,6 +44,8 @@ #include "../capture.h" #endif +#include <wsutil/str_util.h> + #include "ui/main_statusbar.h" #include "ui/recent.h" #include "ui/utf8_entities.h" @@ -699,20 +701,13 @@ status_capture_comment_update(void) static void statusbar_set_filename(const char *file_name, gint64 file_length, nstime_t *file_elapsed_time) { - gchar *size_str; + gchar *size_str; /* expert info indicator */ status_expert_update(); /* statusbar */ - /* convert file size */ - if (file_length/1024/1024 > 10) { - size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d MB", file_length/1024/1024); - } else if (file_length/1024 > 10) { - size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d KB", file_length/1024); - } else { - size_str = g_strdup_printf("%" G_GINT64_MODIFIER "d Bytes", file_length); - } + size_str = format_size(file_length, format_size_unit_bytes|format_size_prefix_si); statusbar_push_file_msg(" File: \"%s\" %s %02lu:%02lu:%02lu", (file_name) ? file_name : "", size_str, |