guile-gi icon indicating copy to clipboard operation
guile-gi copied to clipboard

RFE: guile-gi for use in GIMP extensions

Open spk121 opened this issue 4 years ago • 4 comments

In #106 we began a side discussion about the possibility of make GIMP extensions in Guile using guile-gi to wrap the required GIMP classes.

https://github.com/spk121/guile-gi/issues/106#issuecomment-782699048

https://github.com/spk121/guile-gi/issues/106#issuecomment-782701843

spk121 avatar Feb 24 '21 18:02 spk121

Hello!

Nice to see this report here, as I was testing this weekend whether guile-gui would work well for Scheme plug-ins. We are indeed interested into Scheme plug-ins, possibly to even replace the historical script-fu if the CI binding works well (because script-fu is limited to a specific set of functions whereas a CI binding would give developers the full power of the whole libgimp API).

So I built guile-gi (tested with GNU Guile 2.2.7 from Fedora 33 repositories, as I couldn't find a package for Guile 3.0; make test works well except for one test #109), set up a few environment variable, then tried to import the gi module in it:

scheme@(guile-user)> (use-modules (gi)
             (gi repository)
             (gi types)
             (gi util))
[… snip …]
scheme@(guile-user)> (use-typelibs ("GObject" "2.0") ("Gio" "2.0") ("Gtk" "3.0") ("Gdk" "3.0") ("Babl" "0.1") ("Gegl" "0.4"))

(process:16504): GuileGI-WARNING **: 16:38:02.907: no way of determining array size, coercing to pointer

(process:16504): GuileGI-WARNING **: 16:38:02.907: no way of determining array size, coercing to pointer

(process:16504): GuileGI-WARNING **: 16:38:02.909: Unrepresentable type: (unnamed), VaClosureMarshal, unresolved

(process:16504): GuileGI-WARNING **: 16:38:03.031: no way of determining array size, coercing to pointer

(process:16504): GuileGI-WARNING **: 16:38:03.342: Editable - non-Object interface wants signals

(process:16504): GuileGI-WARNING **: 16:38:03.424: no way of determining array size, coercing to pointer

(process:16504): GuileGI-WARNING **: 16:38:03.424: no way of determining array size, coercing to pointer

(process:16504): GuileGI-WARNING **: 16:38:04.064: no way of determining array size, coercing to pointer

Well apart from a few warnings, at least it seems to work so far. Now I still have a few questions:

  • How do you force namespacing? I saw some #:renamer usage in example files, but you seem to use this per-function. What if I want to have all GI module functions prefixed with gtk::, babl:: and whatnot? We just can't expect to have no collision. Even just basic functions gives out warning:
scheme@(guile-user)> (display "hello world") (newline)
WARNING: (guile-user): `display' imported from both (ice-9 r5rs) and (gi Gdk-3.0)
hello world

Anyway now for trying to import libgimp itself:

scheme@(guile-user)> (use-typelibs ("Gimp" "3.0"))

(process:30538): GuileGI-ERROR **: 17:28:03.115: unhandled type GimpConfigPath derived from gchararray
Trace/breakpoint trap (core dumped)

So guile crashes. GimpConfigPath is registered like this: https://gitlab.gnome.org/GNOME/gimp/-/blob/master/libgimpconfig/gimpconfig-path.c#L64

Doesn't guile-gi support static types derived from G_TYPE_STRING?

Jehan avatar Apr 05 '21 15:04 Jehan

You can surely use #:prefix if you so want. Just do (use-typelibs (("GObject" "2.0") #:prefix g-) ...) As for inheritance, Guile-GI currently only supports inheritance from object types, boxed types and enums. See and modify src/gig_type.c to your needs.

LordYuuma avatar Apr 12 '21 08:04 LordYuuma

You can surely use #:prefix if you so want. Just do (use-typelibs (("GObject" "2.0") #:prefix g-) ...)

Hmmm… I think I saw this syntax in one of the files and tried it, but it didn't work. Though I'll try again, maybe I did it wrong.

Guile-GI currently only supports inheritance from object types, boxed types and enums.

But not also the basic types such as string? 😢

Jehan avatar Apr 12 '21 10:04 Jehan

You can surely use #:prefix if you so want. Just do (use-typelibs (("GObject" "2.0") #:prefix g-) ...)

Hmmm… I think I saw this syntax in one of the files and tried it, but it didn't work. Though I'll try again, maybe I did it wrong.

That'd be very weird. Guile-GI passes these options to use-modules as-is.

Guile-GI currently only supports inheritance from object types, boxed types and enums.

But not also the basic types such as string?

Not currently, see https://github.com/spk121/guile-gi/blob/master/src/gig_type.c#L272-L375 for full context.

LordYuuma avatar Apr 12 '21 10:04 LordYuuma