Package: gtk

Macro gtk:within-main-loop

Lambda List

gtk:within-main-loop (&body body)

Details

The gtk:within-main-loop macro is a wrapper around a GTK program. The functionality of the macro corresponds to the gtk_init() and gtk_main() C functions which initialize and start a GTK program. Both functions have corresponding Lisp functions. The gtk_main() function is exported as the gtk:main Lisp function. The corresponding Lisp function to the gtk_init() function is called internally when loading the library, but is not exported.

To stop the execution of the main loop the gtk:leave-gtk-main function is called.

Examples

An example with a simple window from the GTK Lisp tutorial which shows the usage of the gtk:within-main-loop macro:
(defun example-simple-window ()
  (gtk:within-main-loop
    (let (;; Create a toplevel window.
          (window (gtk:window-new :toplevel)))
      ;; Signal handler for the window to handle the "destroy" signal.
      (g:signal-connect window "destroy"
                        (lambda (widget)
                          (declare (ignore widget))
                          (gtk:leave-gtk-main)))
      ;; Show the window.
      (gtk-widget-show-all window))))    
 

See also

2023-12-26