[cl-gtk2-devel] gtk_widget_destroy
Peter Keller
psilord at cs.wisc.edu
Wed Mar 2 03:59:12 UTC 2011
Hello,
I noticed that gtk_widget_destroy() isn't in the cl-gtk2 bindings, so here
is a piece of code one can stick into gtk.widget.lisp to support it:
(defcfun gtk-widget-destroy :void
(widget g-object))
(defun widget-destroy (widget)
(gtk-widget-destroy widget))
(export 'widget-destroy)
Instead of just exporting gtk-widget-destroy, I made it be symmetrical
in exported symbol name to widget-show.
I also have a question.
Normally, when writing GTK in C, after gtk_main() finishes, one does some
various cleanup and exit(). This causes all the windows to go away.
However, suppose I have this type of code in Lisp which loads a
hello-world style GUI that has a quit button made with glade:
;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun clicked-callback (w)
(declare (ignore w))
(format t "Quitting~%")
(gtk:gtk-main-quit))
(defun doit ()
(let ((builder (make-instance 'gtk:builder)))
(gtk:builder-add-from-file builder "./hello.xml")
(gtk:builder-connect-signals-simple
builder `(("clicked_cb" ,#'clicked-callback)))
(let ((top-level (gtk:builder-get-object builder "top_level")))
(gtk:widget-show top-level :all t)
(gtk:gtk-main)
(format t "After main. Shutting down.~%"))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;
When I click the button. I get the output after the main function,
but the actual toplevel doesn't disappear, presumably because I didn't
actually exit the REPL. It just sits there with the depressed button and
doesn't respond to events anymore. How can I remove all of the widgets
after gtk-main is finished? There seems to be a chicken and egg problem...
Thank you.
-pete
More information about the cl-gtk2-devel
mailing list