Updated: 2023-01
The wiki page for the Inspector seems to be a bit out of date, and at times bugs interfere with documented functionality. What's more, a lot of this functionality is implemented inconsistently in applications, which has clearly led to a lot of people being steered in a lot of wrong directions. (Including by previous versions of this answer.)
If you don't want to use the shortcuts, you can also open the Inspector directly when running your app with:
The handling of GTK_DEBUG
does appear to have been fixed, so that GTK_DEBUG=interactive
in the environment will auto-open the inspector. That wasn't working for me in the past, but in Fedora 37 it works as described.
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.
So, turns out these statements are correct-ish, but they should be accompanied by a whole bunch of caveats.
Ctrl+Shift+D might work, if the application hasn't bound it to something else.
Similarly, Ctrl+Shift+I might work, under the same conditions.
And while it is, technically, a context-sensitive shortcut that will inspect "the widget under the mouse cursor", many applications draw their entire interface inside a big GtkDrawingArea
so don't be surprised if that's the widget that pops up for most mouse locations. (You won't be able to inspect anything inside that area, anyway, as the contents are not Gtk widgets.)
If an application has bound away one or both of the shortcuts, its local bindings will override and there's nothing you can do about that.
Nautilus, in particular, has a different binding for Ctrl+Shift+I (it's "Invert selection"), so that shortcut will never work to open the inspector in Nautilus, and you have to use only Ctrl+Shift+D.
Gnome Terminal actually binds both Ctrl+Shift+D and Ctrl+Shift+I, so neither shortcut will work... which is why they provide a handy Help > Inspector option in the application menubar (if you activate that).
Last but not least, there's a bug in Gtk's handling of Ctrl+Shift+D that might prevent it from working every other time you try to use it. (Ctrl+Shift+I doesn't seem to be affected.)
To get to the inspector, you'll need to satisfy the items on this list:
Install the appropriate gtk3-devel
/ libgtk-3-dev
or gtk4-devel
/ libgtk-4-dev
package. Non-optional.
If using Gtk3, enable the dconf key /org/gtk/settings/debug/enable-inspector-keybinding
/ GSettings key org.gtk.Settings.Debug enable-inspector-keybinding
. (They're the same setting.) Optionally, you can disable org.gtk.Settings.Debug inspector-warning
.
Gtk4 has its own enable-inspector-keybinding
key at org.gtk.gtk4.settings.debug
, but it now defaults True
so you're probably already good there. org.gtk.gtk4.settings.debug.inspector-warning
still also defaults to True
, though, so you may want to turn that off.
Either:
- Run a program with
GTK_DEBUG=interactive
in the environment.
- When the application is open and focused, type Ctrl+Shift+D or Ctrl+Shift+I and hope one of them works. Or look for a menu option to do the same thing.
org
>gtk
>Settings
>Debug
. I think that – 0x2b3bfa0 Mar 22 '15 at 13:24debug
entry. However, did it work the 2nd method? – 0x2b3bfa0 Mar 22 '15 at 13:27libgtk-3-dev
package. – Levente Jan 19 '21 at 14:45