Compare commits

..

No commits in common. "1dcb30ea7e801e2b283bdf7f1588b20218bae16b" and "bb7816727e6143c8a1d0ff0d03df59e96dfbfe4d" have entirely different histories.

View File

@ -68,7 +68,7 @@
(let [(qt-thread (thread-start! qt-loop))
(last-free-arg (condition-case (last (car cli-args)) (var () #f)))]
(when (string? last-free-arg)
(open-vcard-file *qt-win* last-free-arg #t))
(open-vcard-file *qt-win* last-free-arg))
qt-thread))
@ -168,7 +168,11 @@
menu-file-save "triggered()"
(qt:receiver
(lambda ()
(save-vcard-file window)))))
(call-with-output-file *vcard-pathname*
(lambda (in-port)
(vcard:write-vcard
(populate-vcard-with-window window *vcard-alist*)
in-port)))))))
;; If they want a new contact, create a new, blank, window.
;; That is, a new process.
(if menu-file-new
@ -211,7 +215,7 @@
;; Parse a vCard file and populate the windows forms with its contents.
(define (open-vcard-file window file . exit-on-fail?)
(define (open-vcard-file window file)
(set! *vcard-pathname* file)
(set-window-title! window (pathname-file file))
(thread-start!
@ -227,38 +231,19 @@
(set! *vcard-pathname* #f)
(set! *vcard-alist* #f)
(set-window-title! window "New contact")
(error-message "Parsing error"
(string-join
(list "This file doesnt seem to be a valid vCard file."
"Please make sure you selected the right file, and take a look at it manually.")
"\n")
#f exit-on-fail?)]
(qt:message
(string-join (list "This file doesnt seem to be a valid vCard file."
"Please make sure you selected the right file, and take a look at it manually."))
title: "Parsing error" type: 'critical)]
;; … complain harder, harder!!
[exn (file)
(set! *vcard-pathname* #f)
(set! *vcard-alist* #f)
(set-window-title! window "New contact")
(error-message "File error"
"Failed to open the file."
exn exit-on-fail?)]))))
;; Save the window contents to the currently-selected file-path in vCard format.
(define (save-vcard-file window)
(thread-start!
(lambda ()
(condition-case
(begin
(set! *vcard-alist* (populate-vcard-with-window window *vcard-alist*))
(call-with-output-file *vcard-pathname*
(lambda (in-port)
(vcard:write-vcard *vcard-alist*
in-port))))
[exn ()
(error-message
"Export error"
"Failed to save the file.\nTry saving to another location with “File→Save as…”."
exn)]))))
(qt:message
(string-join (list "Failed to open the file."
((condition-property-accessor 'exn 'message) exn)))
title: "File error" type: 'critical)]))))
;; Simply map vCard property-names to their corresponding name in the windows
@ -331,20 +316,6 @@
vcard-alist)
;; Display an error-message dialogue, optionally exiting after the user
;; dismisses it.
(define (error-message title description #!optional (exn #f) (exit-after-message? #f))
(let [(exn-message (if exn ((condition-property-accessor 'exn 'message) exn)
#f))]
(qt:message
(if exn-message
(string-concatenate (list description "\n“" exn-message "”"))
description)
title: title
type: 'critical)
(when exit-after-message? (exit))))
;; Set a QT windows title, suffixing with the program name (Contact).
(define (set-window-title! window title)
(set! (qt:property window "windowTitle")