Add error dialogue for failed contact-saving

This commit is contained in:
Jaidyn Ann 2024-02-22 12:41:52 -06:00
parent bb7816727e
commit 3baeacb82c

View File

@ -168,11 +168,7 @@
menu-file-save "triggered()"
(qt:receiver
(lambda ()
(call-with-output-file *vcard-pathname*
(lambda (in-port)
(vcard:write-vcard
(populate-vcard-with-window window *vcard-alist*)
in-port)))))))
(save-vcard-file window)))))
;; If they want a new contact, create a new, blank, window.
;; That is, a new process.
(if menu-file-new
@ -246,6 +242,26 @@
title: "File error" type: 'critical)]))))
;; 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 ()
(qt:message
(string-join (list "Failed to save the file:"
((condition-property-accessor 'exn 'message) exn)
"Try saving to a another location with “File→Save as…”.")
"\n")
title: "Saving error")]))))
;; Simply map vCard property-names to their corresponding name in the windows
;; fields.
(define property->formname-alist