After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 651043 - Foreign struct conversion fails for cairo.Matrix
Foreign struct conversion fails for cairo.Matrix
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-05-25 09:30 UTC by Tristan Brindle
Modified: 2018-03-20 09:38 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tristan Brindle 2011-05-25 09:30:10 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):
  • File "./cairo-matrix-test.py", line 12 in <module>
    t.set_transform(matrix)
  • File "/usr/lib64/python2.7/site-packages/gi/types.py", line 44 in function
    return info.invoke(*args)
TypeError: Couldn't find conversion for foreign struct 'cairo.Matrix'

Comment 1 johnp 2011-05-26 16:07:42 UTC
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.
Comment 2 johnp 2011-05-26 16:08:38 UTC
btw, you can look at gi/pygi-foreign-cairo.[c|h]  for the code.
Comment 3 John 2017-07-01 18:06:10 UTC
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))
Comment 4 GNOME Infrastructure Team 2018-01-10 20:08:51 UTC
-- 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.
Comment 5 Christoph Reiter (lazka) 2018-03-20 09:38:09 UTC
Fixed in master: https://gitlab.gnome.org/GNOME/pygobject/commit/88e2ef3448397ab406e8278a53ce6297972a6fa0