This is kind of an old question, Anyway there is a new GTK GUI inspection tool added with GTK v3.14.
GtkInspector is the built-in interactive debugging support in GTK+. It was added in GTK+ 3.14, based on a copy of the well-estabished gtkparasite.
To enable the debugger, either start your app with GTK_DEBUG=interactive
in your environment, or run gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true
and launch the debugger with the ControlShiftI or ControlShiftD keyboard shortcuts.
Source: Gnome Projects: GtkInspector
It is more convenient to know the runtime GUI shell directly than following code, as many applications out there using chunks to construct GUI dynamically.
I didn't need to use the shortcut running for example GTK_DEBUG=interactive gedit
brings up the GTK Inspector.