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');
+ }
+
+ if (trunc) limit = atoi(trunc+1);
+
+ name = g_strndup(start+1, ((limit > 0) ? trunc : end)-start-1);
- name = g_strndup(start+1, 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);
"<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"