Giter Club home page Giter Club logo

Comments (2)

bohonghuang avatar bohonghuang commented on August 20, 2024 1

For example, some dialog classes and methods seem missing or being mapped to different names compared to official document, like Adw.AlertDialog (the adw:message-dialog seems the identical one), the constructor function of AlertDialog (there isn't a make-alert-dialog in my environment...), and present functions like adw_dialog_present (But it works well by just using window-present).

Both AlertDialog and Dialog are only available in libadwaita versions higher than 1.5, but most distributions currently offer versions lower than that.

I can't make it works, the user_data argument cannot automatically convert to correct pointer type, and the application will get stuck while running the callback.

The last 2 parameters should be given as CFFI callback and pointer, like:

(adw:message-dialog-choose dialog nil (cffi:callback foo) (cffi:null-pointer))

It seems this pattern is quite common in libadwaita, so I will develop a pattern for passing Lisp closures to such functions later on. Actually, similar functionality already exists in my glib bindings, but I haven't exposed it yet.

Most callbacks in GTK4 are implemented through signals, and AdwMessageDialog also provides a response signal. Perhaps at this stage, you could try going forward using signals:

(in-package #:gtk4.example)

(define-application (:name message-dialog-test
                     :id "org.bohonghuang.gtk4-example.message-dialog-test")
  (define-main-window (window (make-application-window :application *application*))
    (adw:init)
    (setf (window-title window) "Message Dialog Test")
    (let ((box (make-box :orientation +orientation-vertical+ :spacing 4)))
      (let ((button (make-button :label "Show Message Dialog")))
        (connect button "clicked" (lambda (button)
                                    (let ((dialog (adw:make-message-dialog :parent window :heading "Test Message" :body "Test Message Body")))
                                      (adw:message-dialog-add-response dialog "cancel" "Cancel")
                                      (adw:message-dialog-add-response dialog "ok" "OK")
                                      (connect dialog "response" (lambda (dialog respose)
                                                                   (declare (ignore dialog))
                                                                   (alexandria:eswitch (respose :test #'string=)
                                                                     ("ok" (setf (widget-sensitive-p button) nil))
                                                                     ("cancel"))))
                                      (window-present dialog))))
        (box-append box button))
      (setf (window-child window) box))
    (unless (widget-visible-p window)
      (window-present window))))

My environment is CCL (due to unsolvable floating points error under SBCL), Windows11 with msys.

Just quickload float-features and:

(float-features:with-float-traps-masked t (run-your-application))

from cl-gtk4.

apr3vau avatar apr3vau commented on August 20, 2024 1

Thank you, your explanations really save my life :D! Thanks for your effort!

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.