Mercurial > geeqie
changeset 866:c879a9a4f186
image_osd_mkinfo(): pipe replacement by " - " separator was fixed to work correctly with
empty first element.
author | zas_ |
---|---|
date | Fri, 27 Jun 2008 22:57:48 +0000 |
parents | 8d0c91a0f461 |
children | 5169bd198d5a |
files | src/image-overlay.c |
diffstat | 1 files changed, 21 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/image-overlay.c Fri Jun 27 21:35:21 2008 +0000 +++ b/src/image-overlay.c Fri Jun 27 22:57:48 2008 +0000 @@ -210,7 +210,7 @@ gchar delim = '%', imp = '|', sep[] = " - "; gchar *start, *end; guint pos, prev; - guint last; + gboolean want_separator = FALSE; gchar *name, *data; GString *new; gchar *ret; @@ -220,7 +220,6 @@ new = g_string_new(str); prev = 0; - last = FALSE; while (TRUE) { @@ -294,6 +293,7 @@ data = exif_get_data_as_text(exif, name); exif_free_fd(imd->image_fd, exif); } + if (data && *data && limit > 0 && strlen(data) > limit + 3) { gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data); @@ -364,21 +364,31 @@ } g_string_erase(new, pos, end-start+1); - if (data) - g_string_insert(new, pos, data); - - if (pos-prev >= 2 && new->str[pos-1] == imp) + if (data && *data) { - g_string_erase(new, --pos, 1); - if (last && data && *data) + if (want_separator) { + /* insert separator */ g_string_insert(new, pos, sep); pos += strlen(sep); } - } + + g_string_insert(new, pos, data); + pos += strlen(data); + } + + want_separator = FALSE; - prev = data ? pos+strlen(data)-1 : pos-1; - last = data ? TRUE : last; + if (pos-prev >= 1 && new->str[pos] == imp) + { + /* pipe character is replaced by a separator, delete it + * and raise a flag if needed */ + g_string_erase(new, pos--, 1); + want_separator = (data && *data); + } + + prev = pos - 1; + g_free(name); g_free(data); }