This is the mail archive of the guile-gtk@sources.redhat.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

timer and progress-bar-update related question


Hello,

i am trying to trigger a timer, while the application should see if the computer
is connected to a network and can ping a specific host

i have defined a dialog, modal, that contains a progress-bar, user information
... (see code below).

there is no bug, but the timer seems 'to be activated', but nothing gets displayed
on the screen (no progress bar update) until the call to (gping "picpic") returns:

how can i force ou flush the progress-bar-update so that the user sees something
while (gping "picpic") is performed?

   - if the host that is pinged is there, it's ok because the all taked less
     then 1 sec
   - but if the network connection (i.e.) is not physically there (or what ever)
     it can take 10 sec for gping to return

thanks for some help
david

;; 

(define (gping host)
  (system (format #f "ping -c 2 -w 5 ~A" host)))

(define (sp/get-ser-vec timer-a timer-r pgbar)
  (timer-a pgbar "trying to connect to picpic ...")
  (if (>= *uid* 500)
      (if  (= (gping "picpic") 0)
	   (begin
	     (timer-r pgbar "connection OK")
	     ;; ...
	     )
	    (begin
	      (timer-r pgbar "connection NOT OK)
	      ;; ...
	      ))
     ))

(define (select-project-gui)
  (let* ((dialog (gtk-dialog-new))

	 (vbox-area (gtk-dialog-vbox dialog))
	 (action-area (gtk-dialog-action-area dialog))
	 
	 (table (gtk-table-new 4 4 #f))
	 (hseperator0 (gtk-hseparator-new))

	 (prog-bar (gtk-progress-bar-new))
=>	 (timer #f)
=>	 (timeout-f (let ((val 0))
		      (lambda ()
			(set! val (+ 0.02 (if (>= val 1) 0 val)))
			(gtk-progress-bar-update prog-bar val)
			#t)))
	 ...
	 (ok-but (gtk-button-new-with-label "OK"))
	 ...
	 )

    (define (timer-add pgbar msg)
      (gtk-progress-set-format-string pgbar msg)
      (set! timer (gtk-timeout-add 100 timeout-f))
      )

    (define (timer-remove pgbar msg)
      (gtk-progress-set-format-string pgbar msg)
      (gtk-timeout-remove timer)
      (set! timer #f))    

    ...

    (gtk-signal-connect ok-but "clicked" 
			(lambda () 
			  (sp/get-ser-vec timer-add timer-remove prog-bar)
			  ))
    ...
        (gtk-widget-show-all dialog)
    ;; (gtk-standalone-main dialog)
    (gtk-main)
    ))
(select-project-gui)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]