Re: drawing with GTK 3.0

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,
                gpointer data)

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?

Allin Cottrell

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