Mercurial > hg > forks > geeqie
changeset 2767:699c2ad6a287
Show rating as star characters
Additional tag formatted.star_rating to show Xmp.xmp.Rating as a set of
star characters
author | Colin Clark <colin.clark@cclark.uk> |
---|---|
date | Sun, 03 Jun 2018 11:39:01 +0100 |
parents | 81f6ca27b710 |
children | 7d275582e37d |
files | doc/docbook/GuideReferenceTags.xml src/bar.c src/exif-common.c src/main.h |
diffstat | 4 files changed, 41 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/docbook/GuideReferenceTags.xml Thu May 31 19:00:02 2018 +0100 +++ b/doc/docbook/GuideReferenceTags.xml Sun Jun 03 11:39:01 2018 +0100 @@ -299,6 +299,17 @@ </para> </entry> </row> + <row> + <entry> + <para>formatted.star_rating</para> + </entry> + <entry> + <para>Xmp.xmp.Rating</para> + </entry> + <entry> + <para>Rating shown as a set of 🟊 characters</para> + </entry> + </row> </tbody> </tgroup> </table>
--- a/src/bar.c Thu May 31 19:00:02 2018 +0100 +++ b/src/bar.c Sun Jun 03 11:39:01 2018 +0100 @@ -114,6 +114,7 @@ " <entry key = 'formatted.SubjectDistance' if_set = 'true' editable = 'false' />" " <entry key = 'formatted.Resolution' if_set = 'true' editable = 'false' />" " <entry key = '" ORIENTATION_KEY "' if_set = 'true' editable = 'false' />" +" <entry key = 'formatted.star_rating' if_set = 'true' editable = 'false' />" " </pane_exif>" " </bar>" " </layout>"
--- a/src/exif-common.c Thu May 31 19:00:02 2018 +0100 +++ b/src/exif-common.c Sun Jun 03 11:39:01 2018 +0100 @@ -852,6 +852,32 @@ return time_zone; } +static gchar *exif_build_formatted_star_rating(ExifData *exif) +{ + gint n; + gchar *ret = NULL; + GString *str = g_string_new(NULL); + + exif_get_integer(exif, "Xmp.xmp.Rating", &n); + + if (n == -1) + { + ret = g_strdup("⨷"); + } + else if (n > 0 && n < 6) + { + while (n > 0) + { + str = g_string_append(str, "🟊"); + n = n - 1; + } + ret = g_strdup(str->str); + g_string_free(str, TRUE); + } + + return ret; +} + /* List of custom formatted pseudo-exif tags */ #define EXIF_FORMATTED_TAG(name, label) { EXIF_FORMATTED()#name, label, exif_build_formatted##_##name } @@ -873,6 +899,7 @@ EXIF_FORMATTED_TAG(GPSAltitude, N_("GPS altitude")), EXIF_FORMATTED_TAG(localtime, N_("Local time")), EXIF_FORMATTED_TAG(timezone, N_("Time zone")), + EXIF_FORMATTED_TAG(star_rating, N_("Star rating")), {"file.size", N_("File size"), NULL}, {"file.date", N_("File date"), NULL}, {"file.mode", N_("File mode"), NULL},
--- a/src/main.h Thu May 31 19:00:02 2018 +0100 +++ b/src/main.h Sun Jun 03 11:39:01 2018 +0100 @@ -115,7 +115,8 @@ "(%number%/%total%) [%zoom%] <b>%name%</b>\n" \ "%res%|%date%|%size%\n" \ "%formatted.Aperture%|%formatted.ShutterSpeed%|%formatted.ISOSpeedRating:ISO *%|%formatted.FocalLength%|%formatted.ExposureBias:* Ev%\n" \ - "%formatted.Camera:40%|%formatted.Flash%" + "%formatted.Camera:40%|%formatted.Flash%\n" \ + "%formatted.star_rating%" #define GQ_LINK_STR "↗" #include "typedefs.h"