GNOME Bugzilla – Bug 651043
Foreign struct conversion fails for cairo.Matrix
Last modified: 2018-03-20 09:38:09 UTC
The CanvasItem API in GooCanvas has methods which involve Cairo matrices. In trying to put together GI-based bindings for GooCanvas, I've run into a problem where the introspected cairo.Matrix type can't be interchanged with the PyCairo Matrix type, unlike cairo.Context or cairo.Surface. Trying to do so raises a TypeError: Traceback (most recent call last):
+ Trace 227242
t.set_transform(matrix)
return info.invoke(*args)
That is because we don't have an implementation for a cairo.Matrix foreign type. Please look at how we implemented cairo.Surface and provide a patch if you can. It is fairly easy and most of it is boilerplate/copy-paste code. If you can't get to it, it may be a bit before someone has time to work on it.
btw, you can look at gi/pygi-foreign-cairo.[c|h] for the code.
Has there ever been progress on this issue? I've been having what I assume is the same problem. from GooCanvas.CanvasRect.get_transform (xf = self.rect.get_transform()): TypeError: Could not caller allocate argument 1 of callable GooCanvas.CanvasItem.get_transform and in the inverse direction (self.rect.set_transform(matrix) KeyError: 'could not find foreign type Matrix' I've been looking at the code, but I'm afraid this is above my comfort level. I'll still have a try though. Here's a small program showing the issue: import gi gi.require_version('GooCanvas', '2.0') gi.require_foreign('cairo', 'Matrix') from gi.repository import GooCanvas #import cairocffi as cairo import cairo def main(args): matrix = cairo.Matrix(xx = 1, xy = 0, yx = 0, yy = 1, x0 = 0, y0 = 0) canvas = GooCanvas.Canvas() cv_root = canvas.get_root_item() cv_root.set_transform(matrix) return 0 if __name__ == '__main__': import sys sys.exit(main(sys.argv))
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/16.
Fixed in master: https://gitlab.gnome.org/GNOME/pygobject/commit/88e2ef3448397ab406e8278a53ce6297972a6fa0