Mercurial > geeqie
changeset 298:cb93a982fcdd
Add the possibility to truncate overlay infos displayed:
%fCamera:20% will truncate data displayed to 20 characters
and add 3 dots at the end.
For example, %name% -> some_file, %name:4% -> some...
author | zas_ |
---|---|
date | Thu, 10 Apr 2008 10:43:15 +0000 |
parents | 76cdc3f1fe34 |
children | 49eaa6463492 |
files | src/image-overlay.c src/preferences.c |
diffstat | 2 files changed, 27 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/image-overlay.c Thu Apr 10 00:09:43 2008 +0000 +++ b/src/image-overlay.c Thu Apr 10 10:43:15 2008 +0000 @@ -139,19 +139,43 @@ while (TRUE) { + gint was_digit = 0; + gint limit = 0; + gchar *trunc = NULL; + gchar *p; + start = strchr(new->str, delim); if (!start) break; end = strchr(start+1, delim); if (!end) break; + + for (p = end; p > start; p--) + { + if (*p == ':' && was_digit) + { + trunc = p; + break; + } + was_digit = (*p >= '0' && *p <= '9'); + } - name = g_strndup(start+1, end-start-1); + if (trunc) limit = atoi(trunc+1); + + name = g_strndup(start+1, ((limit > 0) ? trunc : end)-start-1); + pos = start-new->str; data = g_strdup(g_hash_table_lookup(vars, name)); if (!data && exif) data = exif_get_data_as_text(exif, name); - + if (data && *data && limit > 0) + { + gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data); + g_free(data); + data = new_data; + } + g_string_erase(new, pos, end-start+1); if (data) g_string_insert(new, pos, data);
--- a/src/preferences.c Thu Apr 10 00:09:43 2008 +0000 +++ b/src/preferences.c Thu Apr 10 10:43:15 2008 +0000 @@ -1354,6 +1354,7 @@ "<i>%size%</i> (filesize), <i>%width%</i>, <i>%height%</i>, <i>%res%</i> (resolution)\n" "To access exif data use the exif name, e. g. <i>%fCamera%</i> is the formatted camera name,\n" "<i>%Exif.Photo.DateTimeOriginal%</i> the date of the original shot.\n" + "<i>%fCamera:20</i> notation will truncate the displayed data to 20 characters and will add 3 dots at the end to denote the truncation.\n" "If two or more variables are connected with the |-sign, it prints available variables with a separator.\n" "<i>%fShutterSpeed%</i>|<i>%fISOSpeedRating%</i>|<i>%fFocalLength%</i> could show \"1/20s - 400 - 80 mm\" or \"1/200 - 80 mm\",\n" "if there's no ISO information in the Exif data.\n"