Update mark-as-starred toolbar item tooltip during validation.

This commit is contained in:
Brent Simmons 2018-02-17 10:32:32 -08:00
parent 1603d0b3f2
commit ce5b60cfe8
1 changed files with 9 additions and 6 deletions

View File

@ -190,23 +190,26 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
private func validateToggleStarred(_ item: NSValidatedUserInterfaceItem) -> Bool { private func validateToggleStarred(_ item: NSValidatedUserInterfaceItem) -> Bool {
let validationStatus = timelineViewController?.markStarredCommandStatus() ?? .canDoNothing let validationStatus = timelineViewController?.markStarredCommandStatus() ?? .canDoNothing
let showStar: Bool let starring: Bool
let result: Bool let result: Bool
switch validationStatus { switch validationStatus {
case .canMark: case .canMark:
showStar = true starring = true
result = true result = true
case .canUnmark: case .canUnmark:
showStar = false starring = false
result = true result = true
case .canDoNothing: case .canDoNothing:
showStar = true starring = true
result = false result = false
} }
if let button = (item as? NSToolbarItem)?.view as? NSButton { if let toolbarItem = item as? NSToolbarItem {
button.image = NSImage(named: showStar ? .star : .unstar) toolbarItem.toolTip = starring ? NSLocalizedString("Mark as Starred", comment: "Command") : NSLocalizedString("Mark as Unstarred", comment: "Command")
if let button = toolbarItem.view as? NSButton {
button.image = NSImage(named: starring ? .star : .unstar)
}
} }
return result return result