GTK: add action to show the GTK inspector (#7468)

The default keybinds for showing the GTK inspector (`ctrl+shift+i` and
`ctrl+shift+d`) don't work reliably in Ghostty due to the way Ghostty
handles input. You can show the GTK inspector by setting the environment
variable `GTK_DEBUG` to `interactive` before starting Ghostty but that's
not always convenient.

This adds a keybind action that will show the GTK inspector. Due to API
limitations toggling the GTK inspector using the keybind action is
impractical because GTK does not provide a convenient API to determine
if the GTK inspector is already showing. Thus we limit ourselves to
strictly showing the GTK inspector. To close the GTK inspector the user
must click the close button on the GTK inspector window. If the GTK
inspector window is already visible but is hidden, calling the keybind
action will not bring the GTK inspector window to the front.
This commit is contained in:
Mitchell Hashimoto
2025-05-30 07:13:34 -07:00
committed by GitHub
8 changed files with 38 additions and 1 deletions

View File

@@ -404,6 +404,9 @@ pub const Action = union(enum) {
/// keybind = cmd+i=inspector:toggle
inspector: InspectorMode,
/// Show the GTK inspector.
show_gtk_inspector,
/// Open the configuration file in the default OS editor. If your default OS
/// editor isn't configured then this will fail. Currently, any failures to
/// open the configuration will show up only in the logs.
@@ -802,6 +805,7 @@ pub const Action = union(enum) {
.toggle_quick_terminal,
.toggle_visibility,
.check_for_updates,
.show_gtk_inspector,
=> .app,
// These are app but can be special-cased in a surface context.

View File

@@ -298,6 +298,12 @@ fn actionCommands(action: Action.Key) []const Command {
.description = "Toggle the inspector.",
}},
.show_gtk_inspector => comptime &.{.{
.action = .show_gtk_inspector,
.title = "Show the GTK Inspector",
.description = "Show the GTK inspector.",
}},
.open_config => comptime &.{.{
.action = .open_config,
.title = "Open Config",