Re: deprecated gtk_cairo_create



On 2016-12-30 05:45 AM, Colomban Wendling wrote:
Hi,

Le 30/12/2016 à 12:20, Sergei Kolomeeyets a écrit :
Hi, everyone
[…]

{draw_callback}

gboolean draw_callback(GtkWidget *area, GdkEventExpose *event, GArray
*ptLinePoints) {
That's not the right signature for the GtkWidget::draw signal: it takes
a cairo_t* as the second parameter, not a GdkEventExpose like did
::expose.  And here you have your Cairo context :)

See
https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget-draw [1]

Also, read
https://developer.gnome.org/gtk3/stable/ch26s02.html#id-1.6.3.4.11, and
more generally
https://developer.gnome.org/gtk3/stable/gtk-migrating-2-to-3.html

So basically you don't need gdk_cairo_create() at all.  If you want to
draw outside of the ::draw() handler and paint the cached thing then,
use a cairo_surface_t as the offscreen surface, and paint it then.

Hope this helps.

Cheers,
Colomban

[1] which says "CairoContext", but that's a weird lie on the API… not
sure why, maybe the GType has this name so introspection is confused.
Anyway, it's cairo_t.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

If one does want to draw into a cairo_surface_t, one can create a cairo context for drawing? E.g.

cairo_t <https://cairographics.org/manual/cairo-cairo-t.html#cairo-t>  *
cairo_create (/|cairo_surface_t <https://cairographics.org/manual/cairo-cairo-surface-t.html#cairo-surface-t> *target|/);

That use of cairo_create() is not deprecated... (I assume).

https://developer.gnome.org/gtk3/stable/ch01s05.html

jim...






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