Closed bigos closed 1 year ago
You can obtain and close all windows with:
(let ((windows (mapcar (lambda (ptr)
(gobj:pointer-object ptr 'window))
(glib:glist-list (application-windows gio:*application*)))))
(mapc #'window-destroy windows))
Having closed all windows, the application quits automatically. Also, you may use (gtk::destroy-all-windows-and-quit)
, which is currently internal and can get changed or removed in the future, however.
READ error during LOAD:
Symbol "GLIST-LIST" not found in the GLIB package.
Line: 661, Column: 94, File-Position: 25012
I use my fork of your project, could that be a problem?
(gir:invoke (glib:*ns* "List" 'foreach)
(gtk4:application-windows app)
#'gtk4:window-close
nil)
This approach did not work.
I also tried to add wrappers for glib, but they do not expose all the symbols I need.
When I read /usr/share/gir-1.0/GLib-2.0.gir and search for g_list_foreach I get the impression that the symbols are not introspectable. Do you have any suggestions on how to solve it?
Could that be a solution?
(loop for aw = (gtk4:application-active-window app)
until (null aw)
do (gtk4:window-close aw))
I use my fork of your project, could that be a problem?
Please update cl-gobject-introspection-wrapper, cl-glib, and cl-gtk4 to the latest Git version, where I added some new APIs a few days ago.
I get the impression that the symbols are not introspectable. Do you have any suggestions on how to solve it?
Although they cannot be introspected via GIR, they are accessible through CFFI. The latest cl-glib
provides glist-list
, by which you can convert a GLib.List
to a list in Lisp: https://github.com/bohonghuang/cl-glib/blob/84b128192d6b11cf03f1150e474a23368f07edff/glib/glist.lisp#L179
Could that be a solution?
I may not recommend this method, since it's not guaranteed that window-close
affects application-active-window
in one event loop, especially when you attach a custom handler to the close-request
signal for a window.
I get the impression that the symbols are not introspectable. Do you have any suggestions on how to solve it?
Although they cannot be introspected via GIR, they are accessible through CFFI. The latest
cl-glib
providesglist-list
, by which you can convert aGLib.List
to a list in Lisp: https://github.com/bohonghuang/cl-glib/blob/84b128192d6b11cf03f1150e474a23368f07edff/glib/glist.lisp#L179
That is the nice response I was looking for. I thought about it as well, but my CFFI skills are very limited and I could not translate CFFI manual to the case I was working on. Your example taught me how to solve those problems where I encounter gir imperfections. Thank you very much!
You are welcome.
https://docs.gtk.org/gtk4/method.Application.get_windows.html
I am trying to find the list of windows associated with the application. Also, how do I programmatically exit from Gtk4 application close all windows and return to REPL?