User UserApp with SendToMarsEditCommand.

This commit is contained in:
Brent Simmons 2018-01-14 11:00:42 -08:00
parent 75d0752a67
commit b05d2f8f5f
1 changed files with 12 additions and 8 deletions

View File

@ -7,20 +7,21 @@
//
import Cocoa
import RSCore
final class SendToMarsEditCommand: SendToCommand {
let title = NSLocalizedString("Send to MarsEdit", comment: "Send to command")
var image: NSImage? {
return appSpecifierToUse()?.icon ?? nil
return appToUse()?.icon ?? nil
}
private let marsEditApps = [ApplicationSpecifier(bundleID: "com.red-sweater.marsedit4"), ApplicationSpecifier(bundleID: "com.red-sweater.marsedit")]
private let marsEditApps = [UserApp(bundleID: "com.red-sweater.marsedit4"), UserApp(bundleID: "com.red-sweater.marsedit")]
func canSendObject(_ object: Any?, selectedText: String?) -> Bool {
if let _ = appSpecifierToUse() {
if let _ = appToUse() {
return true
}
return false
@ -36,12 +37,15 @@ final class SendToMarsEditCommand: SendToCommand {
private extension SendToMarsEditCommand {
func appSpecifierToUse() -> ApplicationSpecifier? {
func appToUse() -> UserApp? {
for specifier in marsEditApps {
specifier.update()
if specifier.existsOnDisk {
return specifier
for app in marsEditApps {
app.updateStatus()
if app.isRunning {
return app
}
if app.existsOnDisk {
return app
}
}