Introducing GtkInspector

If you need to solve a tricky GTK+ problem in your application, gtkparasite is a very useful tool to have around. It lets you explore the widget hierarchy, change properties, tweak theme settings, and so on.

Unfortunately, gtkparasite is a tool for people ‘in the know’ – it is not part of GTK+, not advertised on our website, and not available out of the box on your average GTK+ installation.

At the Developer Experience hackfest in Berlin a few weeks ago, the assembled GTK+ developers discussed fixing this situation by making an interactive debugger like gtkparasite part of GTK+ itself. This way, it will be available whenever you run a GTK+ application, and we can develop and improve the debugging tools alongside the toolkit.

So, I’ve spent some of my spare time on this since the hackfest. The results are now in GTK+ master.  I’ve started from the gtkparasite code, but things have changed quite a bit, and some new things have appeared.

GtkInspectorIf you want to give it a try yourself, you can just use the Control-Shift-I or Control-Shift-D shortcuts to open an inspector window in any application that is using GTK+ master, or you can just set the GTK_DEBUG=interactive environment variable. Note that the keybinding will only work if GTK+ can find the org.gtk.Debug settings schema, so you probably want to run the application under jhbuild.

Here is a video of GtkInspector in action.

Among the things you can see in the video are interactive picking of widgets for inspection, visual debugging of graphic updates and baseline alignment, changing of widget properties, theme tweaks and general version and environment information.

I’ve also put together a page with ideas for future improvements to this debugging tool. If you are looking for a fun project to work on, this might just be it!

Thanks to Christian Hammond for creating gtkparasite and maintaining (over many years) such a useful debugging tool.  The GTK+ inspector would not exist without it.

15 thoughts on “Introducing GtkInspector”

  1. OMG! You are great! This is best tool ever i seen! Thanks you so much! I will use it. Thx 🙂

  2. Nice.

    How about geometic visualization like all the other web debuggers? Showing margin, padding, expand, fill.

    Also maybe inheritance relattion-ship about the properties.

  3. So, is the “consensus” amongst gtk+ devs that gtk+ should be used for “large applications” (
    The kind of tool you’re talking about here is a bit like the tools we get for the web, which is all to the good if it’s intended that people will actually be writing gtk+ apps.

  4. It’s not clear if that’s Control-Shift-I or Control-Shift-D without any special setup?

    What if an application wants to use those shortcuts? I’m sure something like GIMP or Inkscape must have a use for one (and most likely both) of those.

  5. <3 it!

    It would be great if the inspector window doesn't get affected by the changes.

    1. The wiki answered me: “Isolate the inspector window from global state changes” is under Ideas.

Comments are closed.