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()" menu-file-save "triggered()"
(qt:receiver (qt:receiver
(lambda () (lambda ()
(call-with-output-file *vcard-pathname* (save-vcard-file window)))))
(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. ;; If they want a new contact, create a new, blank, window.
;; That is, a new process. ;; That is, a new process.
(if menu-file-new (if menu-file-new
@ -246,6 +242,26 @@
title: "File error" type: 'critical)])))) 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 ;; Simply map vCard property-names to their corresponding name in the windows
;; fields. ;; fields.
(define property->formname-alist (define property->formname-alist