GtkInspector is the built-in interactive debugging support in GTK+. It was added in GTK+ 3.14, based on a copy of the well-established gtkparasite.
The debugger is disabled by default. To enable it run in a terminal:
gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true
To launch the GTK Inspector, focus your GTK application and press Control-Shift-D. Alternatively, move your mouse cursor to your desired widget and press Control-Shift-I to specifically inspect the widget under the mouse cursor.
If you don't want to use the shortcuts, you can also open the Inspector directly when running your app with:
Ideas for further development
GtkInspector is already pretty useful, but it could be even better. Here are some ideas for things to work on, in no particular order. Your help is appreciated!
Show mainloop statistics: how many sources are attached, how often do they fire, how long they take ... Needs support in GLib 710723
- Add a more structured css editor. Look at any major web browser for ideas
- Show overridden styles
- Capture g_log output and show it - recursion danger here, if showing the log generates more logs
- Add logging (property changes, traced signal emissions, etc)
- Visual box model debugging: highlight margin, borders, etc
- Add a D-Bus api; being able to introspect the application and inject changes from an IDE is a powerful idea
- Isolate the inspector window from global state changes (style, text direction, visual debugging,...) if they come from the inspector itself. This has been improved by using a separate display connection for the inspector. Left to do are baselines, pixel cache and touch simulation.
- Show child types (ie. 'center', 'title', 'tab' etc). Needs GTK+ api
- Indicate modified properties in the UI, and add a way to reset them
Store the ui file/resource foshortcuts Controlr each object constructed by GtkBuilder, and have a 'jump to definition' link in the inspector
- Recorder: Record a widget and allow playing back the recording. Allows debugging animations.