summaryrefslogtreecommitdiffstats
path: root/pkg/gui/types
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-09-05 21:49:33 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-09-18 10:15:11 +0200
commit7f9818cfa2a3115ecd0f043b5e94044be1346cda (patch)
tree083497230ebd23c6232d2628d97ec87c7a852bf1 /pkg/gui/types
parent679148449a27486196e4d5aa7f1bf27d8853e9fe (diff)
Add DisabledReason field to MenuItem
This is useful to disable items that are not applicable right now because of some condition (e.g. the "delete branch" menu item when the currently checked-out branch is selected). When a DisabledReason is set on a menu item, we - show it in a tooltip (below the regular tooltip of the item, if it has one) - strike through the item's key, if it has one - show an error message with the DisabledReason if the user tries to invoke the command
Diffstat (limited to 'pkg/gui/types')
-rw-r--r--pkg/gui/types/common.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go
index 6eacd882b..21ba78d9a 100644
--- a/pkg/gui/types/common.go
+++ b/pkg/gui/types/common.go
@@ -204,6 +204,10 @@ 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,
+ // and refuse to invoke the command
+ DisabledReason string
+
// Can be used to group menu items into sections with headers. MenuItems
// with the same Section should be contiguous, and will automatically get a
// section header. If nil, the item is not part of a section.