Re: Using Cairo from introspected GTK3



On Fri, Dec 2, 2011 at 10:38, Conscious User <conscioususer gmail com> wrote:
>
> Hi,
>
> When using GTK3 via PyGI, I can connect a method to the
> "draw" signal of a GtkWidget and this method will receive
> a cairo.Context object. If I do some cairo work just
> using this object, it works fine.
>
> The problem is that I'm trying to do some drawing using
> this cairo.Context and the cairo.Pattern taken from the
> "background-image" property of the GtkStyleContext of
> another widget. When I try, for example, to do a
> set_source using this pattern I get
>
> TypeError: must be cairo.Pattern, not Pattern
>
> So it seems I'm trying to mix introspected and
> non-introspected Cairos here, and this is not acceptable.
> What should I be doing in this case?

Actually, Cairo isn't a GObject library so it's not accessible using
introspection. What we have is a typelib that allows Cairo classes to
be mentioned in other typelibs, marked as "foreign" to denote that the
actual bindings are somewhere else:

http://git.gnome.org/browse/gobject-introspection/tree/gir/cairo-1.0.gir.in

In this case, I think PyGObject just lacks the glue code that allows
it to pass the statically-wrapped cairo.Pattern to introspected
methods, it should be done in a similar way to what we do now with
Context and Surface:

http://git.gnome.org/browse/pygobject/tree/gi/pygi-foreign-cairo.c#n127

Should be pretty easy to write a patch that adds this support. If this
is your first time, this link may help:

https://live.gnome.org/GnomeLove/SubmittingPatches

Regards,

Tomeu

> I also tried to obtain the pattern using the
> get_background_pattern() method of the widget GdkWindow,
> but this gave me a
>
> TypeError: Couldn't find conversion for foreign struct 'cairo.Pattern'
>
> Thanks in advance,
> Marcelo
> _______________________________________________
> python-hackers-list mailing list
> python-hackers-list gnome org
> http://mail.gnome.org/mailman/listinfo/python-hackers-list


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]