How do I redraw only portion of a GtkWidget

I want to redraw only part of a GtkTextView widget. I make sure that application-paintable flag for the widget is turned on and connect the draw signal handler.

I tried many things for example:

GdkRectangle rect;

gdk_cairo_get_clip_rectangle(cr, &rect);

cairo_surface_t* surface = cairo_get_target(cr);
cairo_surface_t* newsurf = cairo_surface_create_similar(surface, cairo_surface_get_content(surface), rect.width - 50, rect.height);

cairo_push_group(cr);
cairo_set_source_surface(cr, newsurf, rect.x + 10, rect.y + 40);
cairo_fill_preserve(cr);
cairo_stroke(cr);
cairo_pop_group_to_source(cr);
cairo_paint(cr);

except that nothing really happens. How do I re-draw only a rect of the dirty clip region in cr or how (as I am trying) to modify cr so that the surface area has different dimensions?

Maybe it will be helpful
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-queue-draw-area

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.