Re: GdkDrawable from GtkDrawingArea and it's cairo surface
- From: Maarten Bosmans <mkbosmans gmail com>
- To: Carlos López Camey <c lopez kmels net>
- Cc: gtk-list gnome org
- Subject: Re: GdkDrawable from GtkDrawingArea and it's cairo surface
- Date: Sun, 24 Jul 2011 10:42:14 +0200
2011/7/24 Carlos López Camey <c lopez kmels net>:
> Hello again,
> Let's say I'd like to save a GtkDrawingArea 'screenshot' to a file.
> I'm able to do
> cairo_t *cr = gtkDrawingAreaWidget->window;
> cairo_surface_t *screenshot = cairo_get_target(cr);
> but what this code does is save a screenshot for the *entire window*,
> including other widgets in it (e.g. toolbar). I can't get a cairo
> context for a GtkDrawingArea since it's not GdkDrawable, and it's not
> possible to have child GtkWindow. I've seen
> gtk_widget_set_has_window() but it didn't work, I think because it
> says "This function should only be called by widget implementations".
> Is there a work-around?
First, create a similar surface with the size of the GtkDrawingArea's
Then call cairo_set_source_surface on the new surface's context with
x, y from GtkDrawingArea's allocation.
Set the operator to OPERATOR_SOURCE and then cairo_paint().
> What I'm really trying to do: Save my drawing area surface everytime
> it's modified (drawn on it), so I can later do "undos" and set the
> surface source to a previous one.
] [Thread Prev