diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2024-01-13 20:02:10 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-01-14 17:45:35 +0100 |
commit | 84e1d15079ab688d3a7379868c8b6b71a3a6edb1 (patch) | |
tree | 5a2bff2714213033e900660e3db0ee7d1aeaf75e /pkg/gui/types | |
parent | 09a24ee97dfa7fd38706e73e0ff7eaef3457c4e7 (diff) |
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.
Diffstat (limited to 'pkg/gui/types')
-rw-r--r-- | pkg/gui/types/common.go | 8 | ||||
-rw-r--r-- | pkg/gui/types/keybindings.go | 2 |
2 files changed, 7 insertions, 3 deletions
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 |