Mercurial > geeqie.yaz
comparison src/image-overlay.c @ 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 | 54e20abb5c6d |
children | 8268cbe682f1 |
comparison
equal
deleted
inserted
replaced
649:3097880d7d95 | 650:02e2c135ee0c |
---|---|
11 */ | 11 */ |
12 | 12 |
13 #include "main.h" | 13 #include "main.h" |
14 #include "image-overlay.h" | 14 #include "image-overlay.h" |
15 | 15 |
16 #include "bar_info.h" | |
16 #include "collect.h" | 17 #include "collect.h" |
17 #include "debug.h" | 18 #include "debug.h" |
18 #include "exif.h" | 19 #include "exif.h" |
19 #include "filedata.h" | 20 #include "filedata.h" |
20 #include "histogram.h" | 21 #include "histogram.h" |
160 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM); | 161 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM); |
161 } | 162 } |
162 } | 163 } |
163 } | 164 } |
164 | 165 |
166 static gchar *keywords_to_string(FileData *fd) | |
167 { | |
168 GList *keywords; | |
169 GString *kwstr = NULL; | |
170 gchar *ret = NULL; | |
171 | |
172 g_assert(fd); | |
173 | |
174 if (comment_read(fd, &keywords, NULL)) | |
175 { | |
176 GList *work = keywords; | |
177 | |
178 while (work) | |
179 { | |
180 gchar *kw = work->data; | |
181 work = work->next; | |
182 | |
183 if (!kw) continue; | |
184 if (!kwstr) | |
185 kwstr = g_string_new(""); | |
186 else | |
187 g_string_append(kwstr, ", "); | |
188 | |
189 g_string_append(kwstr, kw); | |
190 } | |
191 } | |
192 | |
193 if (kwstr) | |
194 { | |
195 ret = kwstr->str; | |
196 g_string_free(kwstr, FALSE); | |
197 } | |
198 | |
199 return ret; | |
200 } | |
201 | |
165 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars) | 202 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars) |
166 { | 203 { |
167 gchar delim = '%', imp = '|', sep[] = " - "; | 204 gchar delim = '%', imp = '|', sep[] = " - "; |
168 gchar *start, *end; | 205 gchar *start, *end; |
169 gint pos, prev; | 206 gint pos, prev; |
223 | 260 |
224 if (extrapos) | 261 if (extrapos) |
225 extra = g_strndup(extrapos, end - extrapos); | 262 extra = g_strndup(extrapos, end - extrapos); |
226 | 263 |
227 name = g_strndup(start+1, (trunc ? trunc : end)-start-1); | 264 name = g_strndup(start+1, (trunc ? trunc : end)-start-1); |
228 | 265 pos = start - new->str; |
229 pos = start-new->str; | 266 data = NULL; |
230 data = g_strdup(g_hash_table_lookup(vars, name)); | 267 |
231 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE; | 268 if (strcmp(name, "keywords") == 0) |
232 if (!data && exif) | 269 { |
233 data = exif_get_data_as_text(exif, name); | 270 data = keywords_to_string(imd->image_fd); |
271 } | |
272 else if (strcmp(name, "comment") == 0) | |
273 { | |
274 comment_read(imd->image_fd, NULL, &data); | |
275 } | |
276 else | |
277 { | |
278 data = g_strdup(g_hash_table_lookup(vars, name)); | |
279 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE; | |
280 if (!data && exif) | |
281 data = exif_get_data_as_text(exif, name); | |
282 } | |
234 if (data && *data && limit > 0 && strlen(data) > limit + 3) | 283 if (data && *data && limit > 0 && strlen(data) > limit + 3) |
235 { | 284 { |
236 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data); | 285 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data); |
237 g_free(data); | 286 g_free(data); |
238 data = new_data; | 287 data = new_data; |