After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 604901 - Provide generic offscreen rendering container
Provide generic offscreen rendering container
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: Other
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Cody Russell
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-12-18 12:07 UTC by Cody Russell
Modified: 2009-12-28 15:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (11.79 KB, patch)
2009-12-18 12:44 UTC, Cody Russell
none Details | Review
Updated patch (13.94 KB, patch)
2009-12-18 13:59 UTC, Cody Russell
none Details | Review
Add some docs (16.95 KB, patch)
2009-12-18 20:33 UTC, Cody Russell
none Details | Review
Add inline docs, remove .sgml, add getters to gtk.symbols (17.03 KB, patch)
2009-12-19 12:11 UTC, Cody Russell
none Details | Review
Add a note about damage-event signal in docs. (17.14 KB, patch)
2009-12-19 15:11 UTC, Cody Russell
accepted-commit_now Details | Review

Description Cody Russell 2009-12-18 12:07:49 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?
Comment 1 Cody Russell 2009-12-18 12:44:17 UTC
Created attachment 149987 [details] [review]
Patch
Comment 2 Alexander Larsson 2009-12-18 12:51:36 UTC
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.
Comment 3 Cody Russell 2009-12-18 13:59:14 UTC
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.
Comment 4 Alexander Larsson 2009-12-18 14:31:28 UTC
No docs...
Comment 5 Cody Russell 2009-12-18 20:33:25 UTC
Created attachment 150027 [details] [review]
Add some docs
Comment 6 Javier Jardón (IRC: jjardon) 2009-12-19 00:30:22 UTC
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
Comment 7 Matthias Clasen 2009-12-19 02:20:55 UTC
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.
Comment 8 Cody Russell 2009-12-19 11:42:00 UTC
(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.
Comment 9 Cody Russell 2009-12-19 12:11:28 UTC
Created attachment 150060 [details] [review]
Add inline docs, remove .sgml, add getters to gtk.symbols
Comment 10 Cody Russell 2009-12-19 15:11:26 UTC
Created attachment 150065 [details] [review]
Add a note about damage-event signal in docs.
Comment 11 Alexander Larsson 2009-12-19 19:47:39 UTC
Not only snapshots, you can even get it to render with alpha is you set a rgba visual.
Comment 12 Alexander Larsson 2009-12-20 08:02:21 UTC
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.
Comment 13 Javier Jardón (IRC: jjardon) 2009-12-20 21:37:59 UTC
A little comment: the new functions missed the "Since: 2.20" tag
Comment 14 Matthias Clasen 2009-12-21 16:45:06 UTC
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.