WIP use cairo types
https://stackoverflow.com/questions/64625955/cairosolidpattern-is-not-of-type-goocanvas2cairopattern explains part of the problem.
I'm trying to use library via Perl bindings:
my $canvas = GooCanvas2::Canvas->new;
my $pattern = Cairo::SolidPattern->create_rgba(0, 0, 0, 0);
my $rect = GooCanvas2::CanvasRect->new(
parent => $canvas->get_root_item,
x => 0, y => 0, width => 100, height => 100,
'fill-pattern' => $pattern,
'line-dash' => GooCanvas2::CanvasLineDash->newv([5, 5]),
'line-width' => 1,
'stroke-color' => 'black',
);
This fails with the error Cairo::SolidPattern=SCALAR(0x558de4acb260) is not of type GooCanvas2::CairoPattern
. The problem here (as far as I understand) is that goocanvas wraps cairo types with its own typedefs, which are picked up by the gobject-introspection compiler to produce an imcompatible boxed glib wrapper type for the same underlying C type. The other copy of the type comes from gobject introspection itself.
https://stackoverflow.com/questions/64625955/cairosolidpattern-is-not-of-type-goocanvas2cairopattern has more details.
Another part of the problem is that I want to call $canvas_image->get('pattern')->set_filter('nearest')
but the returned GooCanvas2::CairoPattern
doesn't have set_filter
or any other methods. This patch fixes both these issues.
But before this can be merged, I have several questions:
-
What's the correct branch to merge this into? master also needs to be fixed (actually, same applies to !8 (merged))- switched to
goocanvas-3.0
branch
- switched to
- Same should probably be done to the other wrapped types here. I started from Pattern because that's what I got blocked on in my project.
- Re compatibility. Does anything rely on the
GooCanvas.CairoPattern
types? Instead, if necessary, I can add a new set of properties and leave thepattern
one as is. E.g. they would befill-cairo-pattern
andstroke-cairo-pattern
in addition to existing convenience propertiesfill-color
andfill-color-gdk-rgba
.