Mercurial > geeqie.yaz
comparison src/exif-common.c @ 1483:7cb24fdf07c0
re-added possibility to display basic file info (size, mode, date)
author | nadvornik |
---|---|
date | Sun, 29 Mar 2009 10:36:13 +0000 |
parents | 91bed0d66cf2 |
children | ece97f3f2305 |
comparison
equal
deleted
inserted
replaced
1482:dac747d99394 | 1483:7cb24fdf07c0 |
---|---|
522 EXIF_FORMATTED_TAG(Flash, N_("Flash")), | 522 EXIF_FORMATTED_TAG(Flash, N_("Flash")), |
523 EXIF_FORMATTED_TAG(Resolution, N_("Resolution")), | 523 EXIF_FORMATTED_TAG(Resolution, N_("Resolution")), |
524 EXIF_FORMATTED_TAG(ColorProfile, N_("Color profile")), | 524 EXIF_FORMATTED_TAG(ColorProfile, N_("Color profile")), |
525 EXIF_FORMATTED_TAG(GPSPosition, N_("GPS position")), | 525 EXIF_FORMATTED_TAG(GPSPosition, N_("GPS position")), |
526 EXIF_FORMATTED_TAG(GPSAltitude, N_("GPS altitude")), | 526 EXIF_FORMATTED_TAG(GPSAltitude, N_("GPS altitude")), |
527 {"file.size", N_("File size"), NULL}, | |
528 {"file.date", N_("File date"), NULL}, | |
529 {"file.mode", N_("File mode"), NULL}, | |
527 { NULL, NULL, NULL } | 530 { NULL, NULL, NULL } |
528 }; | 531 }; |
529 | 532 |
530 gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gboolean *key_valid) | 533 gchar *exif_get_formatted_by_key(ExifData *exif, const gchar *key, gboolean *key_valid) |
531 { | 534 { |
535 | 538 |
536 if (key_valid) *key_valid = TRUE; | 539 if (key_valid) *key_valid = TRUE; |
537 | 540 |
538 key += EXIF_FORMATTED_LEN; | 541 key += EXIF_FORMATTED_LEN; |
539 for (i = 0; ExifFormattedList[i].key; i++) | 542 for (i = 0; ExifFormattedList[i].key; i++) |
540 if (strcmp(key, ExifFormattedList[i].key + EXIF_FORMATTED_LEN) == 0) | 543 if (ExifFormattedList[i].build_func && strcmp(key, ExifFormattedList[i].key + EXIF_FORMATTED_LEN) == 0) |
541 return ExifFormattedList[i].build_func(exif); | 544 return ExifFormattedList[i].build_func(exif); |
542 } | 545 } |
543 | 546 |
544 if (key_valid) *key_valid = FALSE; | 547 if (key_valid) *key_valid = FALSE; |
545 return NULL; | 548 return NULL; |
547 | 550 |
548 gchar *exif_get_description_by_key(const gchar *key) | 551 gchar *exif_get_description_by_key(const gchar *key) |
549 { | 552 { |
550 if (!key) return NULL; | 553 if (!key) return NULL; |
551 | 554 |
552 if (strncmp(key, EXIF_FORMATTED(), EXIF_FORMATTED_LEN) == 0) | 555 if (strncmp(key, EXIF_FORMATTED(), EXIF_FORMATTED_LEN) == 0 || |
556 strncmp(key, "file.", 5) == 0) | |
553 { | 557 { |
554 gint i; | 558 gint i; |
555 | 559 |
556 key += EXIF_FORMATTED_LEN; | |
557 for (i = 0; ExifFormattedList[i].key; i++) | 560 for (i = 0; ExifFormattedList[i].key; i++) |
558 if (strcmp(key, ExifFormattedList[i].key + EXIF_FORMATTED_LEN) == 0) | 561 if (strcmp(key, ExifFormattedList[i].key) == 0) |
559 return g_strdup(_(ExifFormattedList[i].description)); | 562 return g_strdup(_(ExifFormattedList[i].description)); |
560 } | 563 } |
561 | 564 |
562 return exif_get_tag_description_by_key(key); | 565 return exif_get_tag_description_by_key(key); |
563 } | 566 } |
767 return TRUE; | 770 return TRUE; |
768 } | 771 } |
769 | 772 |
770 return FALSE; | 773 return FALSE; |
771 } | 774 } |
775 | |
776 /* | |
777 *------------------------------------------------------------------- | |
778 * file info | |
779 * it is here because it shares tag neming infrastructure with exif | |
780 * we should probably not invest too much effort into this because | |
781 * new exiv2 will support the same functionality | |
782 * http://dev.exiv2.org/issues/show/505 | |
783 *------------------------------------------------------------------- | |
784 */ | |
785 | |
786 static gchar *mode_number(mode_t m) | |
787 { | |
788 gint mb, mu, mg, mo; | |
789 gchar pbuf[12]; | |
790 | |
791 mb = mu = mg = mo = 0; | |
792 | |
793 if (m & S_ISUID) mb |= 4; | |
794 if (m & S_ISGID) mb |= 2; | |
795 if (m & S_ISVTX) mb |= 1; | |
796 | |
797 if (m & S_IRUSR) mu |= 4; | |
798 if (m & S_IWUSR) mu |= 2; | |
799 if (m & S_IXUSR) mu |= 1; | |
800 | |
801 if (m & S_IRGRP) mg |= 4; | |
802 if (m & S_IWGRP) mg |= 2; | |
803 if (m & S_IXGRP) mg |= 1; | |
804 | |
805 if (m & S_IROTH) mo |= 4; | |
806 if (m & S_IWOTH) mo |= 2; | |
807 if (m & S_IXOTH) mo |= 1; | |
808 | |
809 pbuf[0] = (m & S_IRUSR) ? 'r' : '-'; | |
810 pbuf[1] = (m & S_IWUSR) ? 'w' : '-'; | |
811 pbuf[2] = (m & S_IXUSR) ? 'x' : '-'; | |
812 pbuf[3] = (m & S_IRGRP) ? 'r' : '-'; | |
813 pbuf[4] = (m & S_IWGRP) ? 'w' : '-'; | |
814 pbuf[5] = (m & S_IXGRP) ? 'x' : '-'; | |
815 pbuf[6] = (m & S_IROTH) ? 'r' : '-'; | |
816 pbuf[7] = (m & S_IWOTH) ? 'w' : '-'; | |
817 pbuf[8] = (m & S_IXOTH) ? 'x' : '-'; | |
818 pbuf[9] = '\0'; | |
819 | |
820 return g_strdup_printf("%s (%d%d%d%d)", pbuf, mb, mu, mg, mo); | |
821 } | |
822 | |
823 gchar *metadata_file_info(FileData *fd, const gchar *key, MetadataFormat format) | |
824 { | |
825 if (strcmp(key, "file.size") == 0) | |
826 { | |
827 return g_strdup_printf("%ld", (long)fd->size); | |
828 } | |
829 if (strcmp(key, "file.date") == 0) | |
830 { | |
831 return g_strdup(text_from_time(fd->date)); | |
832 } | |
833 if (strcmp(key, "file.mode") == 0) | |
834 { | |
835 return mode_number(fd->mode); | |
836 } | |
837 return g_strdup(""); | |
838 } | |
839 | |
840 | |
772 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ | 841 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ |