;;;; Gtk+ 3 tutorial for Common Lisp ;;;; https://lisp-journey.gitlab.io/blog/gui-programming-in-common-lisp-part-3-of-5-gtk3/ (ql:quickload :cl-cffi-gtk) (defpackage :gtk-tutorial (:use :gtk :gdk :gdk-pixbuf :gobject :glib :gio :pango :cairo :common-lisp)) (in-package :gtk-tutorial) (defun hello-world () ;; in the docs, this is example-upgraded-hello-world-2. (within-main-loop (let ((window (make-instance 'gtk-window :type :toplevel :title "Hello Buttons" :default-width 250 :default-height 75 :border-width 12)) (box (make-instance 'gtk-box :orientation :horizontal :spacing 6))) (g-signal-connect window "destroy" (lambda (widget) (declare (ignore widget)) (leave-gtk-main))) (let ((button (gtk-button-new-with-label "Button 1"))) (g-signal-connect button "clicked" (lambda (widget) (declare (ignore widget)) (format t "Button 1 was pressed.~%"))) (gtk-box-pack-start box button)) (let ((button (gtk-button-new-with-label "Button 2"))) (g-signal-connect button "clicked" (lambda (widget) (declare (ignore widget)) (format t "Button 2 was pressed.~%"))) (gtk-box-pack-start box button)) (gtk-container-add window box) (gtk-widget-show-all window))))