Re: Re: gtk_main?
Espen S Johnsen <[email protected]> 11 Apr 2006 20:12:35 +0200
| Newsgroups | gmane.lisp.clg.devel |
|---|---|
| Message-ID | <[email protected]> |
ephrem boudonnet <[email protected]> writes: > Hi Espen, Hi > How can we run the main loop waiting the return value for a dialog for > example. > > I've tried the function (main) to wait the return value of the OK > button of a file chooser > for example, but it doesn't seem to work. If I understand it correctly, you want to create a function which pops up at dialog box, freeze the rest of the application until the dialog box is destroyed and then return a value. > Isn't it possible to make something like that: With a few modifications this should work, but you need to set the dialog box as modal by giving the keyword argument ':modal t' to make-instance or doing '(setf (window-modal dialog) t)'. When the dialog is destroyed, the main loop also has to be exited, which is done by adding a destroy signal. Finally I think there is a small bug in your callback for the ok button. The modified function should look like this: (defun my-choose-file-dialog () (let ((dialog (make-instance 'file-chooser-dialog :modal t)) (return-value nil)) (signal-connect dialog 'destroy #'main-quit) (dialog-add-button dialog "gtk-cancel" #'widget-destroy :object t) (dialog-add-button dialog "gtk-ok" #'(lambda () (when (slot-boundp dialog 'filename) (setq return-value (file-chooser-filename dialog))) (widget-destroy dialog))) (widget-show-all dialog) (main) return-value)) -- Espen ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642