Skip to content

Commit

Permalink
Fix bug with (image-xmp)
Browse files Browse the repository at this point in the history
  • Loading branch information
lehitoskin committed Dec 23, 2016
1 parent 4043b1f commit 6c26992
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions base.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -519,7 +519,7 @@
(unless (empty? embed-lst)
; the embedded tags may come back unsorted
(incoming-tags (string-join (sort embed-lst string<?) ", ")))]
[else (image-xmp "")])
[else (image-xmp empty)])

; ...put them in the tfield
(send tag-tfield set-value (incoming-tags))
Expand Down
24 changes: 16 additions & 8 deletions meta-editor.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@
(txexpr (string->symbol 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)]
Expand All @@ -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)
Expand All @@ -169,15 +175,17 @@
(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]
[callback
(λ (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
Expand Down Expand Up @@ -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]))
Expand Down

0 comments on commit 6c26992

Please sign in to comment.