plug-ins: fix script-fu-font-map error receiving GStrv

Why: MR !389 changed the signature of PDB procedures to return GStrv instead of (int, GimpStringArray)
This changes handling of results from a call to such a changed signature, in a Scheme script.

The symptom was a cryptic TinyScheme "Error: car: argument 1 must be : pair"

Most changed procedures are named like "-list".
I did a cursory grep to look for other instances.

Updated porting guide doc.
This commit is contained in:
lloyd konneker 2022-05-07 15:10:42 -04:00 committed by Lloyd Konneker
parent b072a42bb7
commit 5e9c92c5de
2 changed files with 30 additions and 4 deletions

View File

@ -28,6 +28,8 @@ This table summarizes the changes:
| pass drawable | GimpDrawable | gint, GimpObjectArray | int (an ID) | int (a length) vector |
| Pass obj array | gint, GimpInt32Array | gint, GimpObjectArray | int vector | int vector |
| Recv obj array | gint, GimpInt32Array | gint, GimpObjectArray | int vector | int vector |
| Pass set of str | gint, GimpStringArray | GStrv | int list | list |
| Recv set of str | gint, GimpStringArray | GStrv | int list | list |
(Where "obj" means an object of a GIMP type such as GimpDrawable or similar.)
@ -123,6 +125,21 @@ would print:
Meaning a list length of zero, and an empty vector.
(Since a new image has no layers.)
### Passing or receiving a set of strings
Formerly, you passed an integer count of strings, and a list of strings.
Now you only pass the list.
ScriptFu converts to/from the C type GStrv
(which is an object knowing its own length.)
An example is the PDB procedure file-gih-save.
Formerly, you received an integer count of strings, and a list of strings.
Now you only receive the list
(and subsequently get its length using "(length list)").
Examples are the many PDB procedures whose name ends in "-list".
Remember that the result of a call to the PDB is a list of values,
in this case the result is a list containing a list,
and for example you get the list of strings like "(car (gimp-fonts-get-list ".*"))"
## Changes in error messages

View File

@ -1,6 +1,14 @@
;; font-select
;; font-map
;; Spencer Kimball
;; To test, open the Font tool dialog,
;; press right mouse button in the list of fonts, choose "Render Font Map"
;; Test cases for font filter regex
;; ".*" expect render all installed fonts
;; "foo" expect render blank image (no matching fonts)
;; "Sans" expect render subset of installed fonts
(define (script-fu-font-map text
use-name
labels
@ -64,9 +72,10 @@
)
(let* (
(font-data (gimp-fonts-get-list font-filter))
(font-list (cadr font-data))
(num-fonts (car font-data))
; gimp-fonts-get-list returns a one element list of results,
; the only element is itself a list of fonts, possibly empty.
(font-list (car (gimp-fonts-get-list font-filter)))
(num-fonts (length font-list))
(label-size (/ font-size 2))
(border (+ border (* labels (/ label-size 2))))
(y border)