Giter Club home page Giter Club logo

Comments (10)

bohonghuang avatar bohonghuang commented on July 19, 2024

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.

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

READ error during LOAD:

Symbol "GLIST-LIST" not found in the GLIB package.

Line: 661, Column: 94, File-Position: 25012

https://github.com/bigos/Pyrulis/blob/a80b6e18534ed89f59b2e1e596fc8532ac9be9e9/Lisp/cl-gtk4-tictactoe.lisp#L661

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

I use my fork of your project, could that be a problem?

https://github.com/bigos/cl-gtk4

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024
       (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?

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

Could that be a solution?

    (loop for aw = (gtk4:application-active-window app)
                                                             until (null aw)
                                                             do (gtk4:window-close aw))

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

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.

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

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

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

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.

from cl-gtk4.

bigos avatar bigos commented on July 19, 2024

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

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!

from cl-gtk4.

bohonghuang avatar bohonghuang commented on July 19, 2024

You are welcome.

from cl-gtk4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.