A Coruña
January 15, 2010 General No CommentsI’ve been meaning to post something for awhile, and just never seem to get around to it. But I’ve gotten a few emails from people asking about GtkOffscreenWindow, so I figured I should post something about it.
So last month there was a WebkitGTK hackfest in A Coruña, and that was really cool. Nice to see some friends again and to meet some cool new people.
We wanted to explore the possibility of rendering GTK+ widgets offscreen, rather than calling into the theming system to draw the widget. It turned out there wasn’t a convenient way to do this. There’s gtk_widget_get_snapshot(), but it seems to be more about taking screenshots of things that are displayed because you can’t really get a snapshot of something that you can’t already see. The window embedding stuff seemed a little low-level, complicated to setup, and in general not quite right for a task like this.
So now there is GtkOffscreenWindow. This is a totally offscreen, toplevel container widget that facilitates retrieving snapshots of widgets without them needing to be on the screen anywhere. You can setup a widget or a hierarchy of widgets and throw them in the container. You’ll have to wait until it’s processed an expose event, but then you can call gtk_offscreen_window_get_pixbuf() or gtk_offscreen_window_get_pixmap().
I must confess one obvious problem in this widget’s API, though. The widget derives from GtkWindow, but you should treat it as though it derives from GtkBin. This is kind of weird and unfortunate, but it’s for kind of internal reasons relating to the GTK+ theme system. If I (or someone else) is able to find a solution that can make the theming work correctly when this widget derives from GtkBin, then I will try to change it in GTK+ 3.0. So you’ve been warned!
The cool news is that GtkOffscreenWindow will be available soon in the upcoming release of GTK+ 2.20.
And just before I left I got a chance to meet with Gabriel and Fumika, who both played violin in my old string quartet during undergrad. They are married now and live in A Coruña, and they play violin in the orchestra that is based there, Orquesta Sinfónica de Galicia. Interestingly, back when our quartet was together we were invited to perform at the opening of the Meadows Museum in Dallas and we had the opportunity to perform for the Spanish royal family. It was really nice to get to see them again finally and to see their children, Claudio Kenta and Lidia Aimi.
So I must say, the trip was really awesome. It was great to meet everyone, great to do some hacking. Thanks to the GNOME Foundation for sponsoring people and the event, thanks to Igalia for hosting the WebKitGTK hackfest, and thanks to Canonical for giving me a few days off to go and hack on open source with other people!