Make the send-to-Micro.blog command work. Need some tweaking, but it mostly does the job.

This commit is contained in:
Brent Simmons
2018-01-11 22:18:46 -08:00
parent 811084c106
commit c3bcf82713
7 changed files with 115 additions and 18 deletions

View File

@@ -6,16 +6,45 @@
// Copyright © 2018 Ranchero Software. All rights reserved.
//
import Foundation
import Cocoa
final class SendToMarsEditCommand: SendToCommand {
let title = NSLocalizedString("Send to MarsEdit", comment: "Send to command")
var image: NSImage? {
return appSpecifierToUse()?.icon ?? nil
}
private let marsEditApps = [ApplicationSpecifier(bundleID: "com.red-sweater.marsedit4"), ApplicationSpecifier(bundleID: "com.red-sweater.marsedit")]
func canSendObject(_ object: Any?, selectedText: String?) -> Bool {
if let _ = appSpecifierToUse() {
return true
}
return false
}
func sendObject(_ object: Any?, selectedText: String?) {
if !canSendObject(object, selectedText: selectedText) {
return
}
}
}
private extension SendToMarsEditCommand {
func appSpecifierToUse() -> ApplicationSpecifier? {
for specifier in marsEditApps {
specifier.update()
if specifier.existsOnDisk {
return specifier
}
}
return nil
}
}