[cl-gtk2-devel] gtk_widget_destroy

Andrey Kutejko andy128k at gmail.com
Wed Mar 2 09:08:53 UTC 2011


Hello,

2011/3/2 Peter Keller <psilord at cs.wisc.edu>:
> 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.
>

There is no need to add gtk-widget-destroy to cl-gtk2.
gtk:object-destroy already exists.

> 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...


Try to invoke (gtk:object-destroy top-level) after main loop.

>
> Thank you.
>
> -pete
>
>
>
> _______________________________________________
> cl-gtk2-devel mailing list
> cl-gtk2-devel at common-lisp.net
> http://common-lisp.net/cgi-bin/mailman/listinfo/cl-gtk2-devel
>




More information about the cl-gtk2-devel mailing list