Fix #700: Rating -1 is displayed as 65535
authorColin Clark <colin.clark@cclark.uk>
Sat, 21 Sep 2019 11:34:23 +0000 (12:34 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sat, 21 Sep 2019 11:34:23 +0000 (12:34 +0100)
https://github.com/BestImageViewer/geeqie/issues/700

Rating is a short.

src/bar_comment.c
src/bar_exif.c

index b5eb290..4bee4d2 100644 (file)
@@ -70,10 +70,19 @@ static void bar_pane_comment_update(PaneCommentData *pcd)
        gchar *comment = NULL;
        gchar *orig_comment = NULL;
        gchar *comment_not_null;
+       gshort rating;
        GtkTextBuffer *comment_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(pcd->comment_view));
 
        orig_comment = text_widget_text_pull(pcd->comment_view);
-       comment = metadata_read_string(pcd->fd, pcd->key, METADATA_PLAIN);
+       if (g_strcmp0(pcd->key, "Xmp.xmp.Rating") == 0)
+               {
+               rating = metadata_read_int(pcd->fd, pcd->key, 0);
+               comment = g_strdup_printf("%d", rating);
+               }
+       else
+               {
+               comment = metadata_read_string(pcd->fd, pcd->key, METADATA_PLAIN);
+               }
        comment_not_null = (comment) ? comment : "";
 
        if (strcmp(orig_comment, comment_not_null) != 0)
index cb6c5e9..077b50c 100644 (file)
@@ -229,9 +229,18 @@ static void bar_pane_exif_update_entry(PaneExifData *ped, GtkWidget *entry, gboo
 {
        gchar *text;
        ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
+       gshort rating;
 
        if (!ee) return;
-       text = metadata_read_string(ped->fd, ee->key, ee->editable ? METADATA_PLAIN : METADATA_FORMATTED);
+       if (g_strcmp0(ee->key, "Xmp.xmp.Rating") == 0)
+               {
+               rating = metadata_read_int(ee->ped->fd, ee->key, 0);
+               text = g_strdup_printf("%d", rating);
+               }
+       else
+               {
+               text = metadata_read_string(ped->fd, ee->key, ee->editable ? METADATA_PLAIN : METADATA_FORMATTED);
+               }
 
        if (!ped->show_all && ee->if_set && !ee->editable && (!text || !*text))
                {