bohonghuang / cl-gtk4

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

Bad FFI methood name attach #24

Closed davidbe closed 1 year ago

davidbe commented 1 year ago

I've experiences with gtk, but I'm new to Lisp. I've been trying to make a simple front-end using a Grid.

I guess I need to use grid-attach to attach a widget to the grid. But when running that code, I got a Bad FFI method name attacherror. What am I doing wrong?

My code is below. Thanks in advance!


(define-application (:name recycle-app
                     :id "org.recycle-app")
  (define-main-window
      (window (make-application-window :application *application*))
    (setf (window-title window) "recycle-app")
    (let ((box (make-box :orientation +orientation-vertical+
                         :spacing 4))
          (grid-input (make-grid-layout))
          (label-postalcode (make-label :str "Postal code:"))
          ;(label-streetname (make-label :str "Streetname:"))
          ;(label-housenumber (make-label :str "Housenumber:"))
          (button-collect (make-button :label "get collections")))
      (setf (grid-column-spacing grid-input) 8)
      (setf (grid-row-spacing grid-input) 4)
      (grid-attach grid-input label-postalcode 0 0 1 1)
      (box-append box grid-input)
      (box-append box button-collect)
      (setf (window-child window) box))
    (unless (widget-visible-p window)
      (window-present window))))``
bohonghuang commented 1 year ago

As the debugger points out:

Bad FFI method name attach
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [RETURN] Return from current handler.
 1: [RETURN-AND-ABORT] Return from current handler and abort the GTK application.
 2: [RETURN-VALUE] Return from current handler with specified value.
 3: [RETURN-VALUE-AND-ABORT] Return from current handler with specified value and abort the GTK application.
 4: [RETRY] Retry SLY mREPL evaluation request.
 5: [*ABORT] Return to SLY's top level.
 --more--

Backtrace:
 0: (GIR::OBJECT-CLASS-FIND-BUILD-METHOD #O<GridLayout> "attach")
...

You are invoking the method attach on GridLayout instead of Grid. Simply replacing make-grid-layout with make-grid can solve this problem.