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 {
let validationStatus = timelineViewController?.markStarredCommandStatus() ?? .canDoNothing
let showStar: Bool
let starring: Bool
let result: Bool
switch validationStatus {
case .canMark:
showStar = true
starring = true
result = true
case .canUnmark:
showStar = false
starring = false
result = true
case .canDoNothing:
showStar = true
starring = true
result = false
}
if let button = (item as? NSToolbarItem)?.view as? NSButton {
button.image = NSImage(named: showStar ? .star : .unstar)
if let toolbarItem = item as? NSToolbarItem {
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