# HG changeset patch
# User zas_
# Date 1207824195 0
# Node ID cb93a982fcdd41b30265032ccd2b66288d25fc9b
# Parent 76cdc3f1fe34a9cecad2d148d39680244d9b4743
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...
diff -r 76cdc3f1fe34 -r cb93a982fcdd src/image-overlay.c
--- 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);
diff -r 76cdc3f1fe34 -r cb93a982fcdd src/preferences.c
--- 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 @@
"%size% (filesize), %width%, %height%, %res% (resolution)\n"
"To access exif data use the exif name, e. g. %fCamera% is the formatted camera name,\n"
"%Exif.Photo.DateTimeOriginal% the date of the original shot.\n"
+ "%fCamera:20 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"
"%fShutterSpeed%|%fISOSpeedRating%|%fFocalLength% could show \"1/20s - 400 - 80 mm\" or \"1/200 - 80 mm\",\n"
"if there's no ISO information in the Exif data.\n"