Skip to content

Commit 6c26992

Browse files
committed
Fix bug with (image-xmp)
1 parent 4043b1f commit 6c26992

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ tracked solely by the application.
1313
- [png-image](https://github.com/lehitoskin/png-image)
1414
- [racquel](https://github.com/brown131/racquel)
1515
- [rsvg](https://github.com/takikawa/rsvg) (which uses librsvg)
16+
- [sugar](https://github.com/mbutterick/sugar)
17+
- [txexpr](https://github.com/mbutterick/txexpr)
1618

1719
### Compilation
1820

base.rkt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
; pict of the currently displayed image
4747
(define image-pict #f)
4848
; the cached XMP metadata of the image
49-
(define image-xmp (make-parameter ""))
49+
(define image-xmp (make-parameter empty))
5050
; bitmap to actually display
5151
; eliminate image "jaggies"
5252
; reduce amount of times we use pict->bitmap, as this takes a very long time
@@ -519,7 +519,7 @@
519519
(unless (empty? embed-lst)
520520
; the embedded tags may come back unsorted
521521
(incoming-tags (string-join (sort embed-lst string<?) ", ")))]
522-
[else (image-xmp "")])
522+
[else (image-xmp empty)])
523523

524524
; ...put them in the tfield
525525
(send tag-tfield set-value (incoming-tags))

meta-editor.rkt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@
120120
(txexpr (string->symbol type) attr-lst (list elems)))]
121121
; attr stuff
122122
[("xmp:BaseURL" "xmp:Label" "xmp:Rating")
123-
(define xexpr (string->xexpr (image-xmp)))
123+
(define xexpr (string->xexpr (if (empty? (image-xmp))
124+
""
125+
(first (image-xmp)))))
124126
; these go inside rdf:Description as attrs
125127
(define rdf:desc (findf-txexpr xexpr is-rdf:Description?))
126128
(attr-set rdf:desc (string->symbol type) elems)]
@@ -135,14 +137,18 @@
135137
(case type
136138
[("xmp:BaseURL" "xmp:Label" "xmp:Rating")
137139
((set-xmp-tag 'rdf:Description)
138-
(string->xexpr (image-xmp))
140+
(string->xexpr (if (empty? (image-xmp))
141+
""
142+
(first (image-xmp))))
139143
(create-dc-meta type elems attrs))]
140144
[else
141145
((set-xmp-tag (string->symbol type))
142-
(string->xexpr (first (image-xmp)))
146+
(string->xexpr (if (empty? (image-xmp))
147+
""
148+
(first (image-xmp))))
143149
(create-dc-meta type elems attrs))]))
144-
(image-xmp (xexpr->string setted))
145-
(set-embed-xmp! (image-path) (image-xmp))
150+
(image-xmp (list (xexpr->string setted)))
151+
(set-embed-xmp! (image-path) (first (image-xmp)))
146152
(fields-defaults))
147153

148154
(define (fields-defaults)
@@ -169,15 +175,17 @@
169175
(define dc-choice
170176
(new choice%
171177
[parent dc-hpanel]
172-
[label "XMP Tags "]
178+
[label "XMP Tags "]
173179
[choices (append dublin-core xmp-base)]
174180
[selection 11]
175181
[stretchable-height #f]
176182
[callback
177183
(λ (choice evt)
178184
; when the choice is selected, fill the tfield with its contents
179185
(define sel (string->symbol (send choice get-string-selection)))
180-
(define xexpr (string->xexpr (image-xmp)))
186+
(define xexpr (string->xexpr (if (empty? (image-xmp))
187+
""
188+
(first (image-xmp)))))
181189
(define found (findf*-txexpr xexpr (is-tag? sel)))
182190
(cond [found
183191
(case sel
@@ -230,7 +238,7 @@
230238
(define attr-choice
231239
(new choice%
232240
[parent attr-hpanel]
233-
[label "Attribute val "]
241+
[label "Attribute val "]
234242
[choices attrs]
235243
[selection 0]
236244
[stretchable-height #f]))

0 commit comments

Comments
 (0)