bohonghuang / cl-gtk4

GTK4/Libadwaita/WebKit2 bindings for Common Lisp.
GNU Lesser General Public License v3.0
215 stars 9 forks source link

Returning from dialogs #42

Closed jonathanabennett closed 1 year ago

jonathanabennett commented 1 year ago

I'm trying to understand what the lambda used to connect to a response signal from a dialog. Here's what I've got currently

(gtk:connect dialog "response"
                      (lambda (response) (format t "I'm in the response!")))

When I run this, I get the following error:

debugger invoked on a SB-INT:SIMPLE-PROGRAM-ERROR @7005729BE0 in thread
#<THREAD "main thread" RUNNING {7006070573}>:
  invalid number of arguments: 2

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [REPLACE-FUNCTION      ] Call a different function with the same arguments
  1: [CALL-FORM             ] Call a different form
  2: [RETURN                ] Return from current handler.
  3: [RETURN-AND-ABORT      ] Return from current handler and abort the GTK application.
  4: [RETURN-VALUE          ] Return from current handler with specified value.
  5: [RETURN-VALUE-AND-ABORT] Return from current handler with specified value and abort the GTK application.
  6: [CONTINUE              ] Ignore runtime option --eval "(megastrike)".
  7: [ABORT                 ] Skip rest of --eval and --load options.
  8:                          Skip to toplevel READ/EVAL/PRINT loop.
  9: [EXIT                  ] Exit SBCL (calling #'EXIT, killing the process).

((LAMBDA (RESPONSE) :IN BUILD-COMMAND-BAR) #<GIR::OBJECT-INSTANCE {7009F083D3}> -2) [external]
   source: (LAMBDA (RESPONSE) (FORMAT T "I'm in the response!"))

I'm guessing that means there should be 2 arguments to the function, but I can't tell what they would be from the documentation

bohonghuang commented 1 year ago

In fact, the response signal handler accepts 2 arguments, namely self and response_id. The passing of user_data can be achieved using closures in Lisp, so it is omitted.