diff options
author | Dennis Real <github@tildepipe.org> | 2012-02-26 19:08:22 +0100 |
---|---|---|
committer | Dennis Real <github@tildepipe.org> | 2012-02-26 19:08:22 +0100 |
commit | fc651e5eb5a7cce4f2df97eb8aee3d9ad34f9717 (patch) | |
tree | d920a9d3c789dc9856871fdc24e73990426075dd /src/slideshow.c | |
parent | 458c5cfd464c84048c7e9027f6ef803d261742e3 (diff) | |
parent | 54deb9b8e21354a1670c179a7d8bd09e4e391026 (diff) |
Merge remote branch 'upstream/master'
Conflicts:
src/exif.c
Diffstat (limited to 'src/slideshow.c')
-rw-r--r-- | src/slideshow.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/slideshow.c b/src/slideshow.c index 189357d..a65d95e 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -404,6 +404,19 @@ char *shell_escape(char *input) return ret; } +char *format_size(int size) +{ + static char ret[5]; + char units[] = {' ', 'k', 'M', 'G', 'T'}; + unsigned char postfix = 0; + while (size >= 1000) { + size /= 1000; + postfix++; + } + snprintf(ret, 5, "%3d%c", size, units[postfix]); + return ret; +} + char *feh_printf(char *str, feh_file * file) { char *c; @@ -452,9 +465,7 @@ char *feh_printf(char *str, feh_file * file) break; case 'S': if (file && (file->info || !feh_file_info_load(file, NULL))) { - snprintf(buf, sizeof(buf), - "%.2fkB", ((double)file->info->size / 1000)); - strcat(ret, buf); + strcat(ret, format_size(file->info->size)); } break; case 'p': @@ -463,14 +474,16 @@ char *feh_printf(char *str, feh_file * file) strcat(ret, buf); } break; + case 'P': + if (file && (file->info || !feh_file_info_load(file, NULL))) { + strcat(ret, format_size(file->info->pixels)); + } + break; case 't': if (file && (file->info || !feh_file_info_load(file, NULL))) { strcat(ret, file->info->format); } break; - case 'P': - strcat(ret, PACKAGE); - break; case 'v': strcat(ret, VERSION); break; |