Text Fixes.

- Replaced URL with URI where appropriate.
- Fixed some typos
- Updated README (and corrected the attribution of the SynchronizedArray code)
This commit is contained in:
Gregorio Litenstein
2019-06-17 00:46:23 -04:00
parent c8d961c035
commit dcafe50852
10 changed files with 67 additions and 67 deletions
@@ -10,7 +10,7 @@
import AppKit
/** Represents information about an application and its associated URL Schemes and UTIs as an object. */
/** Represents information about an application and its associated URI Schemes and UTIs as an object. */
class SWDAApplicationInfo: NSObject {
var displayName: String?
var appPath: String?
@@ -25,7 +25,7 @@ class SWDAApplicationInfo: NSObject {
var wrappedHandlers: [String: [String:[SWDAContentHandler]?]] = [:]
if let handlers = LSWrappers.copySchemesAndUTIsForApp(self.appPath!) {
var wrappedURLHandlers: [String:[SWDAContentHandler]] = ["Viewer":[]]
var wrappedURIHandlers: [String:[SWDAContentHandler]] = ["Viewer":[]]
var wrappedUTIHandlers: [String:[SWDAContentHandler]] = ["Viewer":[],"Editor":[],"Shell":[]]
for handlerRole in handlers["UTIs"]! {
@@ -41,28 +41,28 @@ class SWDAApplicationInfo: NSObject {
}
}
for handlerRole in handlers["URLs"]! {
for handlerRole in handlers["URIs"]! {
let role = String(describing:handlerRole.key)
var handler: SWDAContentHandler?
for urlHandler in handlerRole.value {
handler = SWDAContentHandler(SWDAContentItem(type:SWDAContentType(rawValue:"URL")!, urlHandler), appName: self.appBundleID!, role: SourceListRoleTypes(rawValue:role)!)
handler = SWDAContentHandler(SWDAContentItem(type:SWDAContentType(rawValue:"URI")!, urlHandler), appName: self.appBundleID!, role: SourceListRoleTypes(rawValue:role)!)
if let handler = handler {
wrappedURLHandlers[role]!.append(handler)
wrappedURIHandlers[role]!.append(handler)
}
}
}
wrappedHandlers["UTIs"] = wrappedUTIHandlers
wrappedHandlers["URLs"] = wrappedURLHandlers
wrappedHandlers["URIs"] = wrappedURIHandlers
return wrappedHandlers
}
else { return ["URLs":["Viewer":[]],"UTIs":["Editor":[], "Viewer":[], "Shell":[]]] }
else { return ["URIs":["Viewer":[]],"UTIs":["Editor":[], "Viewer":[], "Shell":[]]] }
}()
/** Only applications that handle at least one URL Scheme or UTI will show up in the "Applications" tab. */
lazy var handlesURLs: Bool = {
for role in (self.handledContent["URLs"]!).values {
/** Only applications that handle at least one URI Scheme or UTI will show up in the "Applications" tab. */
lazy var handlesURIs: Bool = {
for role in (self.handledContent["URIs"]!).values {
if !(role!.isEmpty) { return true }
}
return false
@@ -21,7 +21,7 @@ internal protocol SWDAContentProtocol: class {
var getExtensions: String { get }
}
/** The main class adopting SWDAContentProtocol, represents either a UTI or an URL; it's name, associated handlers, description in the case of URL Schemes and associated file-extensions in the case of UTIs.*/
/** The main class adopting SWDAContentProtocol, represents either a UTI or an URL; it's name, associated handlers, description in the case of URI Schemes and associated file-extensions in the case of UTIs.*/
class SWDAContentItem: NSObject, SWDAContentProtocol {
/** Generates the NSTreeView displaying all the handlers associated to this content type. Results are sorted alphabetically, with the exception of the special "Other..." and "Do Nothing" entries. */
@@ -31,14 +31,14 @@ class SWDAContentItem: NSObject, SWDAContentProtocol {
switch self.contentType {
case .UTI:
rolesArray = [.Viewer, .Editor, .Shell]
case .URL:
case .URI:
rolesArray = [.Viewer]
case .Application: return []
}
for role in rolesArray {
var tempChildren: [SWDATreeRow] = []
let category = SWDATreeRow(role.rawValue)
if let handlerAppNames = (self.contentType == .URL) ? LSWrappers.Schemes.copyAllHandlers(self.contentName, asPath:true) : LSWrappers.UTType.copyAllHandlers(self.contentName, inRoles: LSRolesMask(from: role), asPath:true) {
if let handlerAppNames = (self.contentType == .URI) ? LSWrappers.Schemes.copyAllHandlers(self.contentName, asPath:true) : LSWrappers.UTType.copyAllHandlers(self.contentName, inRoles: LSRolesMask(from: role), asPath:true) {
for app in handlerAppNames {
let handler = SWDAContentHandler(self, appName:app, role:role)
if let tempName = handler.application?.displayName {
@@ -97,7 +97,7 @@ class SWDAContentItem: NSObject, SWDAContentProtocol {
func getDescription () -> String {
switch self.contentType {
case .URL:
case .URI:
if let contentDescription = LSWrappers.Schemes.getNameForScheme(self.contentName as String) {
self.setValue(contentDescription, forKey: "contentDescription")
return self.contentDescription
@@ -114,26 +114,26 @@ class SWDAContentItem: NSObject, SWDAContentProtocol {
@objc var appIcon: NSImage? = nil
}
/** Our other NSObject subclass adopting the SWDAContentProtocol, represents an Application and all of its associated URL Schemes and UTIs. If an application declares no UTIs, it looks for File Extensions and displays the UTI preferred to represent that extension. */
/** Our other NSObject subclass adopting the SWDAContentProtocol, represents an Application and all of its associated URI Schemes and UTIs. If an application declares no UTIs, it looks for File Extensions and displays the UTI preferred to represent that extension. */
class SWDAApplicationItem: NSObject, SWDAContentProtocol {
@objc lazy var contentHandlers: [SWDATreeRow] = {
var allHandlers: [SWDATreeRow] = []
if let bundle = self.appBundleInfo {
let handledContent = bundle.handledContent
if (bundle.handlesURLs == true) {
let URLs = SWDATreeRow("URL Schemes")
if (bundle.handlesURIs == true) {
let URIs = SWDATreeRow("URI Schemes")
let roles = ["Viewer"]
for role in roles {
let row = SWDATreeRow(role)
for handler in ((handledContent["URLs"]![role]!)!) {
for handler in ((handledContent["URIs"]![role]!)!) {
let content = handler.content as! SWDAContentItem
let rowName = content.contentName
let child = SWDATreeRow(rowName, content: handler)
row.addChild(child)
}
if (row.children.count > 0) { URLs.addChildren(of: row) }
if (row.children.count > 0) { URIs.addChildren(of: row) }
}
allHandlers.append(URLs)
allHandlers.append(URIs)
}
if (bundle.handlesUTIs == true) {
let UTIs = SWDATreeRow("Uniform Type Identifiers")
@@ -165,7 +165,7 @@ class SWDAApplicationItem: NSObject, SWDAContentProtocol {
self.contentType = .Application
if let appInfo = SWDAApplicationInfo(app) {
self.appBundleInfo = appInfo
guard (appInfo.handlesURLs == true || appInfo.handlesUTIs == true) else { return nil }
guard (appInfo.handlesURIs == true || appInfo.handlesUTIs == true) else { return nil }
}
else { return nil }
super.init()
@@ -16,7 +16,7 @@ enum SourceListRoleTypes:String {
/** Represent possible kinds of NSObject conforming to SWDAContentProtocol */
internal enum SWDAContentType: String {
case UTI, URL, Application
case UTI, URI, Application
}
@@ -29,7 +29,7 @@ class SWDAHandlersModel: NSObject {
/**
This function is indirectly called by the contentArray variable in each SWDATabTemplate instance, it's responsible for asynchronously populating each model array with the appropriate content and sending messages for the ProgressAlert to update itself.
- Parameter view: The SWDATabView instance that requested the content. We pass this so we can then modify it's backing-store in a KVO-compliant manner via setValue(_:forKey:)
- Parameter view: The SWDATabView instance that requested the content. We pass this so we can then modify its backing-store in a KVO-compliant manner via setValue(_:forKey:)
- Parameter type: String representation of what that SWDATabTemplate is asking for.
- Parameter competionHandler: Code block to execute upon completion. In practice, what this does is invoke setValue(_:forKey:) with the resulting array as the value.
*/
@@ -54,16 +54,16 @@ class SWDAHandlersModel: NSObject {
switch type {
case "Internet":
sourceItems = ["http","mailto","news","rss","ftp","im"]
sourceDescriptions = ["http":"Web Browser","mailto":"E-Mail","news":"News","rss":"RSS","ftp":"FTP","im":"Instant Messaging"] // In practice, these are just shortcuts for the most commonly-used URL Schemes.
sourceDescriptions = ["http":"Web Browser","mailto":"E-Mail","news":"News","rss":"RSS","ftp":"FTP","im":"Instant Messaging"] // In practice, these are just shortcuts for the most commonly-used URI Schemes.
codeBlock = {
index in
let i = Int(index)
(outputItems as! SynchronizedArray<SWDAContentItem>).append(SWDAContentItem(type:SWDAContentType(rawValue: "URL")!, sourceItems[i], sourceDescriptions[sourceItems[i]]))
(outputItems as! SynchronizedArray<SWDAContentItem>).append(SWDAContentItem(type:SWDAContentType(rawValue: "URI")!, sourceItems[i], sourceDescriptions[sourceItems[i]]))
DispatchQueue.main.async { [weak progressAlert] in
progressAlert?.increment(by: 1)
}
}
case "URLs":
case "URIs":
if let schemesHandlers = LSWrappers.Schemes.copySchemesAndHandlers() {
sourceItems = Array(schemesHandlers.keys)
}
@@ -72,7 +72,7 @@ class SWDAHandlersModel: NSObject {
index in
let i = Int(index)
if sourceItems[i] != "*" {
(outputItems as! SynchronizedArray<SWDAContentItem>).append(SWDAContentItem(type:SWDAContentType(rawValue: "URL")!, sourceItems[i]))
(outputItems as! SynchronizedArray<SWDAContentItem>).append(SWDAContentItem(type:SWDAContentType(rawValue: "URI")!, sourceItems[i]))
}
DispatchQueue.main.async { [weak progressAlert] in
progressAlert?.increment(by: 1)