GNOME Bugzilla – Bug 604901
Provide generic offscreen rendering container
Last modified: 2009-12-28 15:57:26 UTC
To take an arbitrary widget and render it to an offscreen buffer without having it displayed anywhere onscreen turns out to be quite tricky, so can we add a general-purpose container widget for doing this?
Created attachment 149987 [details] [review] Patch
Note: I helped out writing this code, so it seems ok to me. The widget needs to derive from GtkWindow, because otherwise it won't be in the toplevel list and things like theme changes won't work. Additionally I think we need to focus stuff in GtkWindow. Of course, GtkWindow has a bunch of calls that don't make sense for GtkOffscreenWindow, so calling e.g. gtk_window_begin_resize_drag() on a GtkOffscreenWindow will just be bad news. Not sure what to do about this.
Created attachment 149995 [details] [review] Updated patch Adds gtk_offscreen_window_get_type() and gtk_offscreen_window_new() to gtk.symbols, adds headers to the tops of the files, and a couple other minor changes.
No docs...
Created attachment 150027 [details] [review] Add some docs
Hello Cody, I'd like to suggest you to use inline comments in the documentation. I think is the new 'standard' now, see http://live.gnome.org/GtkTasks#T7
Review of attachment 150027 [details] [review]: Hmm, is the only purpose of this really just to obtain snapshots ? That seems kinda limited. The docs should explain in some more details what parts of handling offscreen stuff are automatically taken care of, and what parts still need to be handled by the app. ::: gtk/gtk.symbols @@ +2716,3 @@ +#if IN_FILE(__GTK_OFFSCREEN_WINDOW_C__) +gtk_offscreen_window_get_type G_GNUC_CONST +gtk_offscreen_window_new Seems to miss the getters here.
(In reply to comment #7) > Review of attachment 150027 [details] [review]: > > Hmm, is the only purpose of this really just to obtain snapshots ? That seems > kinda limited. Well, there wasn't a way to do this before for a widget that isn't actually part of a widget hierarchy and shown on the screen. If you wanted to take a widget that is offscreen, and render that to a buffer that is also offscreen then you were out of luck.. gtk_widget_get_snapshot() wouldn't do it. Thanks for the reviews, I'm fixing it up now and I'll post a new revision with inline docs and a fixed gtk.symbols.
Created attachment 150060 [details] [review] Add inline docs, remove .sgml, add getters to gtk.symbols
Created attachment 150065 [details] [review] Add a note about damage-event signal in docs.
Not only snapshots, you can even get it to render with alpha is you set a rgba visual.
Review of attachment 150065 [details] [review]: ::: gtk/gtkoffscreenwindow.c @@ +36,3 @@ + * with it since you cannot pack a toplevel widget in another toplevel. + * + * The idea is to take a widget and manually set the size and state of You don't have to set the size of it, the container will pick the requested size of the children if not set.
A little comment: the new functions missed the "Since: 2.20" tag
Apart from alex' and javier's comments, looks fine to me. Just add it to gtk-sections.txt and gtk-docs.sgml when committing. Thanks.