Tracing GTK+ drawing operations

Sunday 10 February, 2008 @ 11:44

I spent last week messing around in Python with a concept I had in the back of my head, and a problem I bumped into was figuring out what widget was drawing what on the screen in GTK+. So yesterday I sat down and wrote a set of tools to do that.

First part is a GDB script that automates the process of breaking on a gtk_paint_* operation and dumping the necessary information. This was written with The Widget Factory in mind, so if your application needs parameters, or is written in Python, it needs adjustment. I’ve also uploaded some gzipped sample output of The Widget Factory.

Second part is a Python script that reads the redirected GDB output and visualizes it like so: (click the thumbnail for the full version)

Screenshot

It doesn’t draw images, text or polygons, but it shows most of the original. I found it helpful in figuring out what kind of calls widgets make when drawing, but also seeing from the theme engine point of view how the methods are invoked.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
(c) 2010 Shtééf | powered by WordPress with Barecity