changeset 650:02e2c135ee0c

Keywords and comment can now be displayed in OSD info using %keywords% and %comment%.
author zas_
date Tue, 13 May 2008 11:58:47 +0000
parents 3097880d7d95
children ac87e9688188
files README src/image-overlay.c
diffstat 2 files changed, 58 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/README	Tue May 13 08:53:26 2008 +0000
+++ b/README	Tue May 13 11:58:47 2008 +0000
@@ -420,7 +420,9 @@
   %width%      Image width
   %height%     Image height
   %res%        Image resolution
-  
+  %keywords%   Image keywords from metadata
+  %comment%    Image comment from metadata
+
   To access exif data use the exif name:
   %Exif.Photo.DateTimeOriginal%	Date of the original shot
 
--- a/src/image-overlay.c	Tue May 13 08:53:26 2008 +0000
+++ b/src/image-overlay.c	Tue May 13 11:58:47 2008 +0000
@@ -13,6 +13,7 @@
 #include "main.h"
 #include "image-overlay.h"
 
+#include "bar_info.h"
 #include "collect.h"
 #include "debug.h"
 #include "exif.h"
@@ -162,6 +163,42 @@
 		}
 }
 
+static gchar *keywords_to_string(FileData *fd)
+{
+	GList *keywords;
+	GString *kwstr = NULL;
+	gchar *ret = NULL;
+
+	g_assert(fd);
+
+	if (comment_read(fd, &keywords, NULL))
+		{
+		GList *work = keywords;
+
+		while (work)
+			{
+			gchar *kw = work->data;
+			work = work->next;
+					
+			if (!kw) continue;
+			if (!kwstr)
+				kwstr = g_string_new("");
+			else
+				g_string_append(kwstr, ", ");
+			
+			g_string_append(kwstr, kw);
+			}
+		}
+
+	if (kwstr)
+		{
+		ret = kwstr->str;
+		g_string_free(kwstr, FALSE);
+		}
+
+	return ret;
+}
+
 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars)
 {
 	gchar delim = '%', imp = '|', sep[] = " - ";
@@ -225,12 +262,24 @@
 			extra = g_strndup(extrapos, end - extrapos);
 					
 		name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
-		
-		pos = start-new->str;
-		data = g_strdup(g_hash_table_lookup(vars, name));
-		if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
-		if (!data && exif)
-			data = exif_get_data_as_text(exif, name);
+		pos = start - new->str;
+		data = NULL;
+
+		if (strcmp(name, "keywords") == 0)
+			{
+			data = keywords_to_string(imd->image_fd);
+			}
+		else if (strcmp(name, "comment") == 0)
+			{
+			comment_read(imd->image_fd, NULL, &data);
+			}
+		else
+			{
+			data = g_strdup(g_hash_table_lookup(vars, name));
+			if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
+			if (!data && exif)
+				data = exif_get_data_as_text(exif, name);
+			}
 		if (data && *data && limit > 0 && strlen(data) > limit + 3)
 			{
 			gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);