Mercurial > geeqie.yaz
comparison src/exif-common.c @ 548:7ada6e5d4de8
Add a pointer to the build function in the formatted exif tags struct
and use a loop in exif_get_formatted_by_key().
author | zas_ |
---|---|
date | Fri, 02 May 2008 22:28:39 +0000 |
parents | 95e0449d8f29 |
children | 4230e67bdfb1 |
comparison
equal
deleted
inserted
replaced
547:95e0449d8f29 | 548:7ada6e5d4de8 |
---|---|
38 #include "debug.h" | 38 #include "debug.h" |
39 #include "filelist.h" | 39 #include "filelist.h" |
40 #include "format_raw.h" | 40 #include "format_raw.h" |
41 #include "ui_fileops.h" | 41 #include "ui_fileops.h" |
42 | 42 |
43 | |
44 /* human readable key list */ | |
45 | |
46 ExifFormattedText ExifFormattedList[] = { | |
47 { "fCamera", N_("Camera") }, | |
48 { "fDateTime", N_("Date") }, | |
49 { "fShutterSpeed", N_("Shutter speed") }, | |
50 { "fAperture", N_("Aperture") }, | |
51 { "fExposureBias", N_("Exposure bias") }, | |
52 { "fISOSpeedRating", N_("ISO sensitivity") }, | |
53 { "fFocalLength", N_("Focal length") }, | |
54 { "fFocalLength35mmFilm",N_("Focal length 35mm") }, | |
55 { "fSubjectDistance", N_("Subject distance") }, | |
56 { "fFlash", N_("Flash") }, | |
57 { "fResolution", N_("Resolution") }, | |
58 { "fColorProfile", N_("Color profile") }, | |
59 { NULL, NULL } | |
60 }; | |
61 | 43 |
62 double exif_rational_to_double(ExifRational *r, gint sign) | 44 double exif_rational_to_double(ExifRational *r, gint sign) |
63 { | 45 { |
64 if (!r || r->den == 0.0) return 0.0; | 46 if (!r || r->den == 0.0) return 0.0; |
65 | 47 |
448 } | 430 } |
449 if (name[0] == 0 && source[0] == 0) return NULL; | 431 if (name[0] == 0 && source[0] == 0) return NULL; |
450 return g_strdup_printf("%s (%s)", name, source); | 432 return g_strdup_printf("%s (%s)", name, source); |
451 } | 433 } |
452 | 434 |
435 | |
436 /* List of custom formatted pseudo-exif tags */ | |
437 #define EXIF_FORMATTED_TAG(name, label) { #name, label, exif_build##_##name } | |
438 | |
439 ExifFormattedText ExifFormattedList[] = { | |
440 EXIF_FORMATTED_TAG(fCamera, N_("Camera")), | |
441 EXIF_FORMATTED_TAG(fDateTime, N_("Date")), | |
442 EXIF_FORMATTED_TAG(fShutterSpeed, N_("Shutter speed")), | |
443 EXIF_FORMATTED_TAG(fAperture, N_("Aperture")), | |
444 EXIF_FORMATTED_TAG(fExposureBias, N_("Exposure bias")), | |
445 EXIF_FORMATTED_TAG(fISOSpeedRating, N_("ISO sensitivity")), | |
446 EXIF_FORMATTED_TAG(fFocalLength, N_("Focal length")), | |
447 EXIF_FORMATTED_TAG(fFocalLength35mmFilm,N_("Focal length 35mm")), | |
448 EXIF_FORMATTED_TAG(fSubjectDistance, N_("Subject distance")), | |
449 EXIF_FORMATTED_TAG(fFlash, N_("Flash")), | |
450 EXIF_FORMATTED_TAG(fResolution, N_("Resolution")), | |
451 EXIF_FORMATTED_TAG(fColorProfile, N_("Color profile")), | |
452 { NULL, NULL, NULL } | |
453 }; | |
454 | |
453 gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gint *key_valid) | 455 gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gint *key_valid) |
454 { | 456 { |
455 /* must begin with f, else not formatted */ | 457 /* must begin with f, else not formatted */ |
456 if (key[0] != 'f') | 458 if (key[0] == 'f') |
457 { | 459 { |
458 if (key_valid) *key_valid = FALSE; | 460 gint i; |
459 return NULL; | 461 |
460 } | 462 if (key_valid) *key_valid = TRUE; |
461 | 463 |
462 if (key_valid) *key_valid = TRUE; | 464 for (i = 0; ExifFormattedList[i].key; i++) |
463 | 465 if (strcmp(key, ExifFormattedList[i].key) == 0) |
464 #define EXIF_BUILD_FORMATTED_TAG(x) do { if (strcmp(key, #x) == 0) return exif_build##_##x(exif); } while (0) | 466 return ExifFormattedList[i].build_func(exif); |
465 | 467 } |
466 EXIF_BUILD_FORMATTED_TAG(fCamera); | |
467 EXIF_BUILD_FORMATTED_TAG(fDateTime); | |
468 EXIF_BUILD_FORMATTED_TAG(fShutterSpeed); | |
469 EXIF_BUILD_FORMATTED_TAG(fAperture); | |
470 EXIF_BUILD_FORMATTED_TAG(fExposureBias); | |
471 EXIF_BUILD_FORMATTED_TAG(fFocalLength); | |
472 EXIF_BUILD_FORMATTED_TAG(fFocalLength35mmFilm); | |
473 EXIF_BUILD_FORMATTED_TAG(fISOSpeedRating); | |
474 EXIF_BUILD_FORMATTED_TAG(fSubjectDistance); | |
475 EXIF_BUILD_FORMATTED_TAG(fFlash); | |
476 EXIF_BUILD_FORMATTED_TAG(fResolution); | |
477 EXIF_BUILD_FORMATTED_TAG(fColorProfile); | |
478 | 468 |
479 if (key_valid) *key_valid = FALSE; | 469 if (key_valid) *key_valid = FALSE; |
480 return NULL; | 470 return NULL; |
481 } | 471 } |
482 | 472 |