Package: gtk

Function gtk:application-add-window

Lambda List

gtk:application-add-window (application window)

Arguments

application -- a gtk:application instance
window -- a gtk:window widget

Details

Adds a window to the application. This call is equivalent to setting the application property of window to application.

Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it with the gtk:application-remove-window function.

GTK will keep the application running as long as it has any windows.

Examples

This is a code fragment from the GTK Demo. The function creates a window and adds the window to the list of application windows. The application is passed in as an argument.
(defun example-window-simple-demo (&optional application)
  (gtk:within-main-loop
    (let (;; Create a toplevel window.
          (window (gtk:window-new :toplevel)))
      ;; Add the window to the list of windows of the application
      (when application
        (gtk:application-add-window application window))
      ... )    
This is equivalent to the following code
      ...
      ;; Add the window to the list of windows of the application
      (when application
        (setf (gtk:window-application window) application))
      ... )    
Finally, we can add the window to the list of application windows in one step when we create the window. This is the preferred way to do this in a Lisp program.
(defun example-window-simple-demo (&optional application)
  (gtk:within-main-loop
    (let (;; Create a toplevel window.
          (window (make-instance 'gtk:window
                                 :type :toplevel
                                 :application application)))
      ... )    
 

See also

2024-3-15