From 84e1d15079ab688d3a7379868c8b6b71a3a6edb1 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 13 Jan 2024 20:02:10 +0100 Subject: Make DisabledReason a struct This is a pure refactoring, no change in behavior yet. We'll add another field to the struct in the next commit. --- pkg/gui/types/common.go | 8 ++++++-- pkg/gui/types/keybindings.go | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'pkg/gui/types') diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index afa4156c8..79b4e153c 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -201,6 +201,10 @@ type MenuSection struct { Column int // The column that this section title should be aligned with } +type DisabledReason struct { + Text string +} + type MenuItem struct { Label string @@ -219,9 +223,9 @@ type MenuItem struct { // The tooltip will be displayed upon highlighting the menu item Tooltip string - // If non-empty, show this in a tooltip, style the menu item as disabled, + // If non-nil, show this in a tooltip, style the menu item as disabled, // and refuse to invoke the command - DisabledReason string + DisabledReason *DisabledReason // Can be used to group menu items into sections with headers. MenuItems // with the same Section should be contiguous, and will automatically get a diff --git a/pkg/gui/types/keybindings.go b/pkg/gui/types/keybindings.go index 4c3d02c6f..bb125d4e5 100644 --- a/pkg/gui/types/keybindings.go +++ b/pkg/gui/types/keybindings.go @@ -31,7 +31,7 @@ type Binding struct { // disabled and we show the given text in an error message when trying to // invoke it. When left nil, the command is always enabled. Note that this // function must not do expensive calls. - GetDisabledReason func() string + GetDisabledReason func() *DisabledReason } // A guard is a decorator which checks something before executing a handler -- cgit v1.2.3