Closed phntxx closed 2 years ago
@phntxx It may boil down to the upstream library handling signal parameters incorrectly, for which I have opened issue #84. However, it's possible to address this problem via cffi
currently. The solution may seem tricky, but it does work though:
(defpackage test-application-open
(:use #:cl #:gtk4))
(in-package #:test-application-open)
(defun main ()
(let ((app (make-application :application-id "org.bohonghuang.test-application-open"
:flags gio:+application-flags-handles-open+)))
(connect app "activate" (lambda (app)
(gio:application-open app (list (gio:file-new-for-path "/home/coco24/.emacs.d/init.el")
(gio:file-new-for-path "/home/coco24/.emacs.d/local.el"))
"")))
(connect app "open" (lambda (app files n-files hint)
(declare (ignore app hint))
(let ((files (loop :for i :below n-files
:collect (make-instance 'gir::object-instance
:class (gir:nget gio:*ns* "File")
:this (cffi:mem-aref files :pointer i)))))
(print (mapcar #'gio:file-basename files))))) ;; This outputs ("init.el" "local.el")
(gio:application-run app nil)))
Words cannot describe how thankful I am for your support in this. Thank you very much for the code example, I'll make sure to follow the progress of the issue in the upstream repository.
Hi!
I'm fairly new to LISP and am currently using this library to create an image viewing program. However, I've hit a roadblock when trying to handle the "open" signal. According to the official GTK documentation, the type of
files
isGFile**
, i.e. a pointer to an array ofGFile
elements.I have tried the following:
I have not been able to figure out how to convert this into a LISP-usable list. Could you perhaps point me to a solution or documentation that might aid me in this?