Lisp HUG Maillist Archive

Progress bars

Hi

I have a problem with progress bars on LWM due to the single-threadness 
of Cocoa.

Essentially I want to display a "progress bar" that advances 
independently of the porcess it is tracking.

This is the code I wrote to make it work (and it works fine under LWW, 
and at a certain point under LWL)

==================================================================================
(defun popup-progress-dialog (message &key (start 0) (end 100) 
(cancel-button "Cancel") (title "Progress"))
   (let ((pb (make-instance 'capi:progress-bar :start start :end end)))
     (values pb
             (mp:process-run-function "Progress bar process"
                                      ()
                                      'capi:popup-confirmer
                                      pb
                                      message
                                      :modal nil
                                      :ok-button nil
                                      :cancel-button cancel-button
                                      :title title))))


(defun run-with-progress-dialog (funct message
                                        &key
                                        (start 0)
                                        (end 100)
                                        (cancel-button "Cancel")
                                        (arguments ())
                                        )
   (let* ((pb (popup-progress-dialog message
                                     :start start
                                     :end end
                                     :cancel-button cancel-button))
          (pb-update-process
           (mp:process-run-function "Progress bar updating"
                                    ()
                                    (lambda ()
                                      (loop with max = (capi:range-end pb)
                                            for i from 0
                                            do (sleep 1)
                                            do (update-progress-bar pb 
(mod i max))))))
          )
     (mp:ensure-process-cleanup
      (lambda (funct-process)
        (declare (ignore funct-process))
        (mp:process-kill pb-update-process)
        (popdown-progress-dialog pb))
      (apply #'mp:process-run-function
             "While progress bar is running"
             ()
             funct
             arguments))
     nil))

==================================================================================

Even if I wrap the call to RUN-WITH-PROGRESS-DIALOG in a 
EXECUTE-WITH-INTERFACE, LWM still hangs (due to the processes inside the 
call I surmise)

Does anybody have some insights about how to write a cross-platform 
progress dialog?

(I know I am lazy to ask here :) )

Thanks
--
Marco


Re: Progress bars

Unable to parse email body. Email id is 4439

Updated at: 2020-12-10 08:50 UTC