From 6c26992bfc2da7d4fbdbef4f8264acf1e0fc2987 Mon Sep 17 00:00:00 2001 From: Lehi Toskin Date: Thu, 22 Dec 2016 21:25:02 -0800 Subject: [PATCH] Fix bug with (image-xmp) --- README.md | 2 ++ base.rkt | 4 ++-- meta-editor.rkt | 24 ++++++++++++++++-------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f23d09b..c828cde 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ tracked solely by the application. - [png-image](https://github.com/lehitoskin/png-image) - [racquel](https://github.com/brown131/racquel) - [rsvg](https://github.com/takikawa/rsvg) (which uses librsvg) +- [sugar](https://github.com/mbutterick/sugar) +- [txexpr](https://github.com/mbutterick/txexpr) ### Compilation diff --git a/base.rkt b/base.rkt index 7a9ff39..8de127a 100644 --- a/base.rkt +++ b/base.rkt @@ -46,7 +46,7 @@ ; pict of the currently displayed image (define image-pict #f) ; the cached XMP metadata of the image -(define image-xmp (make-parameter "")) +(define image-xmp (make-parameter empty)) ; bitmap to actually display ; eliminate image "jaggies" ; reduce amount of times we use pict->bitmap, as this takes a very long time @@ -519,7 +519,7 @@ (unless (empty? embed-lst) ; the embedded tags may come back unsorted (incoming-tags (string-join (sort embed-lst stringsymbol type) attr-lst (list elems)))] ; attr stuff [("xmp:BaseURL" "xmp:Label" "xmp:Rating") - (define xexpr (string->xexpr (image-xmp))) + (define xexpr (string->xexpr (if (empty? (image-xmp)) + "" + (first (image-xmp))))) ; these go inside rdf:Description as attrs (define rdf:desc (findf-txexpr xexpr is-rdf:Description?)) (attr-set rdf:desc (string->symbol type) elems)] @@ -135,14 +137,18 @@ (case type [("xmp:BaseURL" "xmp:Label" "xmp:Rating") ((set-xmp-tag 'rdf:Description) - (string->xexpr (image-xmp)) + (string->xexpr (if (empty? (image-xmp)) + "" + (first (image-xmp)))) (create-dc-meta type elems attrs))] [else ((set-xmp-tag (string->symbol type)) - (string->xexpr (first (image-xmp))) + (string->xexpr (if (empty? (image-xmp)) + "" + (first (image-xmp)))) (create-dc-meta type elems attrs))])) - (image-xmp (xexpr->string setted)) - (set-embed-xmp! (image-path) (image-xmp)) + (image-xmp (list (xexpr->string setted))) + (set-embed-xmp! (image-path) (first (image-xmp))) (fields-defaults)) (define (fields-defaults) @@ -169,7 +175,7 @@ (define dc-choice (new choice% [parent dc-hpanel] - [label "XMP Tags "] + [label "XMP Tags "] [choices (append dublin-core xmp-base)] [selection 11] [stretchable-height #f] @@ -177,7 +183,9 @@ (λ (choice evt) ; when the choice is selected, fill the tfield with its contents (define sel (string->symbol (send choice get-string-selection))) - (define xexpr (string->xexpr (image-xmp))) + (define xexpr (string->xexpr (if (empty? (image-xmp)) + "" + (first (image-xmp))))) (define found (findf*-txexpr xexpr (is-tag? sel))) (cond [found (case sel @@ -230,7 +238,7 @@ (define attr-choice (new choice% [parent attr-hpanel] - [label "Attribute val "] + [label "Attribute val "] [choices attrs] [selection 0] [stretchable-height #f]))