Re: drawing with GTK 3.0
- From: Allin Cottrell <cottrell wfu edu>
- To: gtk-app-devel-list gnome org
- Subject: Re: drawing with GTK 3.0
- Date: Sat, 12 Feb 2011 11:55:37 -0500 (EST)
On Sat, 12 Feb 2011, Allin Cottrell wrote:
I've got my app to build against gtk 3.0 but I'm having trouble
getting some drawing code ported...
Ah, I now see what part of my problem was: I hadn't looked up the
latest signature for the GtkWidget "draw" callback. I had this as
void plot_draw (GtkWidget *canvas, GdkRectangle *rect,
but the second argument should now be a cairo_t * (the doc
actually says a "CairoContext *", but does that type exist?).
So my revised callback looks like this:
void plot_draw (GtkWidget *widget, cairo_t *cr, gpointer data)
png_plot *plot = data;
gdk_cairo_set_source_pixbuf(cr, plot->pixbuf, 0, 0);
Now my image will display, but dynamic changes to the image (e.g.
rubber-banding of a selection rectangle) that were smooth in gtk
2.24 are now jerky, and I guess this is because the above code
(re-)paints the entire image, whereas the gtk 2.24 version gets an
event rectangle from the "expose-event" signal and so redraws only
the affected area. If that diagnosis is plausible (?) how can we
avoid doing a full redraw with the new mechanism?
] [Thread Prev