From be9fef60e45bf6fdc0947d90034028689d4a6ab0 Mon Sep 17 00:00:00 2001 From: Brigham Toskin Date: Tue, 8 May 2018 00:01:03 -0700 Subject: [PATCH 1/2] Resolves and merges db vs xmp data when displaying an image. --- base.rkt | 66 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 24 deletions(-) diff --git a/base.rkt b/base.rkt index 35ac6b3..4d321c9 100644 --- a/base.rkt +++ b/base.rkt @@ -94,6 +94,7 @@ (define color-black (make-object color% "black")) (define color-spring-green (make-object color% "spring green")) (define color-gold (make-object color% "gold")) +(define color-red (make-object color% "red")) ; contract for image scaling (define image-scale/c @@ -798,30 +799,47 @@ (string-truncate (path->string name) 30)))])]) ; pick what string to display for tags... - (cond [(db-has-key? 'images img-str) - (define img-obj (make-data-object sqlc image% img-str)) - (define tags (send img-obj get-tags)) - (incoming-tags (string-join tags ", ")) - (when (db-has-key? 'ratings img-str) - (define rating-obj (make-data-object sqlc rating% img-str)) - (define rating (number->string (send rating-obj get-rating))) - (send iar set-string-selection (string-append rating " 🌟")))] - [else (incoming-tags "")]) - ; check to see if the image has embedded tags and use them instead of - ; what's in the DB because it may be out of date - (cond [(embed-support? img-str) - (set-box! image-xmp (get-embed-xmp img-str)) - (define embed-lst (get-embed-tags img-str)) - (unless (empty? embed-lst) - ; the embedded tags may come back unsorted - (incoming-tags (string-join (sort embed-lst stringstring (send rating-obj get-rating))) + "0")) + ; set the label of ivy-actions-rating to the rating of the + ; image (if applicable) + (define embed-rating + (if (and (embed-support? img-str) + (not (empty? (unbox image-xmp)))) + (xmp-rating (first (unbox image-xmp))) + "0")) + ; set the rating widget + (define incoming-rating + (if (string=? "0" embed-rating) + db-rating + embed-rating)) + (send iar set-string-selection (string-append incoming-rating " 🌟")) ; ...put them in the tfield (send tag-tfield set-value (incoming-tags)) From 6a46b7cd30b2b96179aa5345f6219662d9c96660 Mon Sep 17 00:00:00 2001 From: Brigham Toskin Date: Tue, 8 May 2018 22:16:09 -0700 Subject: [PATCH 2/2] Make sure XMP box is cleared, if not in this file. --- base.rkt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base.rkt b/base.rkt index 4d321c9..8b49711 100644 --- a/base.rkt +++ b/base.rkt @@ -814,7 +814,9 @@ (values '() "") ; the embedded tags may come back unsorted (values embed-lst (string-join embed-lst ", ")))] - [else (values '() "")])) + [else + (set-box! image-xmp empty) + (values '() "")])) ; now verify the tags match, and merge them/let the user know if necessary (incoming-tags (cond [(string=? db-tags embed-tags) db-tags] [else