(in-package :gtk)
+(define-condition gtk-call-aborted (error)
+ ((condition :initarg :condition :reader gtk-call-aborted-condition))
+ (:report (lambda (c stream)
+ (format stream "Call within main loop aborted because of error:~%~A" (gtk-call-aborted-condition c)))))
+
(defun call-within-main-loop-and-wait (fn)
(let ((lock (bt:make-lock))
(cv (bt:make-condition-variable))
+ error
result)
(bt:with-lock-held (lock)
(within-main-loop
- (setf result (multiple-value-list (funcall fn)))
+ (handler-case
+ (setf result (multiple-value-list (funcall fn)))
+ (error (e) (setf error e)))
(bt:with-lock-held (lock)
(bt:condition-notify cv)))
(bt:condition-wait cv lock)
- (values-list result))))
+ (if error
+ (error 'gtk-call-aborted :condition error)
+ (values-list result)))))
(export 'call-within-main-loop-and-wait)
(with-progress-bar ("Texts" 10)
(loop
repeat 10
- do (with-progress-bar-action (sleep 1))))))))
\ No newline at end of file
+ do (with-progress-bar-action (sleep 1))))))))
+
+(defun show-message (message &key (buttons :ok) (message-type :info) (use-markup nil))
+ (let ((dialog (make-instance 'message-dialog
+ :text message
+ :buttons buttons
+ :message-type message-type
+ :use-markup use-markup)))
+ (prog1
+ (dialog-run dialog)
+ (object-destroy dialog))))
+
+(export 'show-message)