[cl-gtk2-devel] gtk_widget_destroy

Peter Keller psilord at cs.wisc.edu
Thu Mar 3 05:17:46 UTC 2011


On Wed, Mar 02, 2011 at 11:08:53AM +0200, Andrey Kutejko wrote:
> There is no need to add gtk-widget-destroy to cl-gtk2.
> gtk:object-destroy already exists.

Fair enough.

> > I also have a question.
[snip]
> > 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...
> 
> 
> Try to invoke (gtk:object-destroy top-level) after main loop.

I tried this, but it doesn't change the behavior.

Here is my sample code. The hello.xml is just a simple glade ui definition
with a quit button to which I attach a function.

(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 `(("quit_button_clicked" ,#'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.~%")

      (gtk:object-destroy top-level))))

Upon clicking the quit button, I get the output indicated "quitting"
and "After main...", but the window stays shown and present with the
depressed quit button and stops responding to any events.

Thank you.

-pete




More information about the cl-gtk2-devel mailing list