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:
@@ -13,7 +13,7 @@ class ReadCommand: OptionCommand {
|
||||
|
||||
let name = "getHandler"
|
||||
let signature = ""
|
||||
let shortDescription = "Returns the default application registered for the URL scheme or <subtype> you specify."
|
||||
let shortDescription = "Returns the default application registered for the URI Scheme or <subtype> you specify."
|
||||
|
||||
private var kind: String = ""
|
||||
private var getAll = false;
|
||||
|
||||
@@ -14,14 +14,14 @@ class GetSchemes: Command {
|
||||
|
||||
let name = "getSchemes"
|
||||
let signature = ""
|
||||
let shortDescription = "Returns a list of all known URL schemes, accompanied by their default handler."
|
||||
let shortDescription = "Returns a list of all known URI schemes, accompanied by their default handler."
|
||||
|
||||
func execute(arguments: CommandArguments) throws {
|
||||
|
||||
if let output = copyDictionaryAsString(LSWrappers.Schemes.copySchemesAndHandlers()?.sorted(by: { $0.0 < $1.0 })) {
|
||||
print(output)
|
||||
}
|
||||
else { throw CLIError.error("There was an error generating the list.") }
|
||||
else { throw CLIError.error("SwiftDefaultApps ERROR: Couldn't generate list of URI Schemes.") }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ class LSWrappers {
|
||||
- appNotFound: Application not found at given path/URL.
|
||||
- notAnApp: Found item at given path/URL but it is not an application bundle.
|
||||
- invalidFileURL: Trying to locate a file with a scheme different from file://
|
||||
- invalidScheme: Supplied URL Scheme is malformed or contains invalid characters.
|
||||
- deletedApp: An application bundle was found, but it is currently in the Trash.
|
||||
- serverErr: Can't communicate with the Launch Services server.
|
||||
- incompatibleSys: A valid application bundle was found, but it is not compatible with the current version of macOS.
|
||||
- invalidBundle: The specified bundle does not have a valid CFBundlePackageType entry.
|
||||
- defaultErr: Unknown error, for cases not covered above.
|
||||
- invalidScheme: Supplied URI Scheme is malformed or contains invalid characters.
|
||||
*/
|
||||
internal enum LSErrors:OSStatus {
|
||||
case appNotFound = -10814
|
||||
@@ -60,7 +60,7 @@ class LSWrappers {
|
||||
|
||||
- Parameter argument:
|
||||
app: The application specified by the user, which could conceivably be a URL, a file-path, a bundle identifier or even a display name.
|
||||
content: This is only used in the case the user supplies a malformed URL Scheme.
|
||||
content: This is only used in the case the user supplies a malformed URI Scheme.
|
||||
|
||||
- Returns: Human-readable error message specifying the problem, or unknown error if the problem is something not accounted for here.
|
||||
*/
|
||||
@@ -68,13 +68,13 @@ class LSWrappers {
|
||||
switch self {
|
||||
case .notAnApp: return "\(argument.app) is not a valid application."
|
||||
case .appNotFound: return "No application found for \(argument.app)"
|
||||
case .invalidScheme: return "\(argument.content) is not a valid URL Scheme."
|
||||
case .invalidFileURL: return "\(argument.app) is not a valid filesystem URL."
|
||||
case .deletedApp: return "\(argument.app) cannot be accessed because it is in the Trash."
|
||||
case .serverErr: return "There was an error trying to communicate with the Launch Services Server."
|
||||
case .incompatibleSys: return "\(argument.app) is not compatible with the currently installed version of macOS."
|
||||
case .invalidBundle: return "\(argument.app) is not a valid Package."
|
||||
case .defaultErr: return "An unknown error has occurred."
|
||||
case .invalidScheme: retValue += "\(argument.content!) is not a valid URI Scheme."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,12 +174,12 @@ class LSWrappers {
|
||||
}
|
||||
}
|
||||
/**
|
||||
Groups functions dealing with URL Schemes.
|
||||
Groups functions dealing with URI Schemes.
|
||||
*/
|
||||
class Schemes {
|
||||
/**
|
||||
Traverses Info dictionaries of possible handlers for an URL Scheme and gets a display name, if available.
|
||||
- Parameter inScheme: An URL Scheme.
|
||||
Traverses Info dictionaries of possible handlers for an URI Scheme and gets a display name, if available.
|
||||
- Parameter inScheme: An URI Scheme.
|
||||
- Returns: A display name, or `nil` if none was found.
|
||||
*/
|
||||
static func getNameForScheme (_ inScheme: String) -> String? {
|
||||
@@ -207,8 +207,8 @@ class LSWrappers {
|
||||
return schemeName
|
||||
}
|
||||
/**
|
||||
Creates a list of all currently registered URL Schemes and their default handler.
|
||||
- Returns: A dictionary with URL Schemes as keys and bundle identifiers as values.
|
||||
Creates a list of all currently registered URI Schemes and their default handler.
|
||||
- Returns: A dictionary with URI Schemes as keys and bundle identifiers as values.
|
||||
*/
|
||||
static func copySchemesAndHandlers() -> [String:String]? {
|
||||
var schemes_array: NSArray?
|
||||
@@ -229,8 +229,8 @@ class LSWrappers {
|
||||
else { return nil }
|
||||
}
|
||||
/**
|
||||
Copies the bundle identifier of the application currently registered as the default handler for a given URL Scheme.
|
||||
- Parameter inScheme: A valid URL Scheme.
|
||||
Copies the bundle identifier of the application currently registered as the default handler for a given URI Scheme.
|
||||
- Parameter inScheme: A valid URI Scheme.
|
||||
- Returns: The Bundle identifier or POSIX path of an application, or nil if no valid handler was found.
|
||||
*/
|
||||
static func copyDefaultHandler (_ inScheme:String, asPath: Bool = true) -> String? {
|
||||
@@ -248,8 +248,8 @@ class LSWrappers {
|
||||
else { return nil }
|
||||
}
|
||||
/**
|
||||
Creates a list of all currently registered handlers for a given URL Scheme.
|
||||
- Parameter inScheme: A valid URL Scheme.
|
||||
Creates a list of all currently registered handlers for a given URI Scheme.
|
||||
- Parameter inScheme: A valid URI Scheme.
|
||||
- Returns: An array of strings corresponding to the Bundle identifiers or POSIX paths of all currently registered handlers, or nil of none were found.
|
||||
*/
|
||||
static func copyAllHandlers (_ inScheme:String, asPath: Bool = true) -> Array<String>? {
|
||||
@@ -270,11 +270,11 @@ class LSWrappers {
|
||||
return (handlers.isEmpty ? nil : handlers)
|
||||
}
|
||||
/**
|
||||
Changes the default handler for a given URL Scheme.
|
||||
Changes the default handler for a given URI Scheme.
|
||||
- See Also: `enum LSErrors` above.
|
||||
- Parameters:
|
||||
- inScheme: A valid URL Scheme.
|
||||
- inBundleID: A bundle-identifier referring to a valid application bundle. Specifying "None" will disable the default handler for that URL Scheme.
|
||||
- inScheme: A valid URI Scheme.
|
||||
- inBundleID: A bundle-identifier referring to a valid application bundle. Specifying "None" will disable the default handler for that URI Scheme.
|
||||
- Returns: A status-code. `0` on success, or a value corresponding to various possible errors.
|
||||
*/
|
||||
static func setDefaultHandler (_ inScheme: String, _ inBundleID: String) -> OSStatus {
|
||||
@@ -416,13 +416,13 @@ class LSWrappers {
|
||||
return kLSUnknownErr
|
||||
}
|
||||
/**
|
||||
Creates a list of UTIs and URL Schemes an application claims to be able to handle.
|
||||
Creates a list of UTIs and URI Schemes an application claims to be able to handle.
|
||||
- Note: We perform little if any sanity checks in this function because it is not intended to be exposed to user input.
|
||||
- Parameter inApp: A POSIX path corresponding to a valid application bundle.
|
||||
- Returns: A dictionary of sets containing a list of strings corresponding to URL Schemes and Uniform Type Identifiers listed in CFBundleURLTypes and CFBundleDocumentTypes respectively.
|
||||
- Returns: A dictionary of sets containing a list of strings corresponding to URI Schemes and Uniform Type Identifiers listed in CFBundleURLTypes and CFBundleDocumentTypes respectively.
|
||||
*/
|
||||
static func copySchemesAndUTIsForApp (_ inApp: String) -> [String:[String:Set<String>]]? {
|
||||
var handledUrlSchemes: [String:Set<String>] = ["Viewer":[]]
|
||||
var handledUriSchemes: [String:Set<String>] = ["Viewer":[]]
|
||||
var handledUTIs: [String:Set<String>] = ["Editor":[],"Viewer":[],"Shell":[]]
|
||||
var handledTypes: [String:[String:Set<String>]] = [:]
|
||||
if let infoDict = Bundle(path: inApp)?.infoDictionary {
|
||||
@@ -430,7 +430,7 @@ class LSWrappers {
|
||||
if let schemeDicts = (infoDict["CFBundleURLTypes"] as? [[String:AnyObject]]) {
|
||||
for schemeDict in schemeDicts {
|
||||
if let schemesArray = (schemeDict["CFBundleURLSchemes"] as? [String]) {
|
||||
handledUrlSchemes["Viewer"]!.formUnion(schemesArray)
|
||||
handledUriSchemes["Viewer"]!.formUnion(schemesArray)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -455,7 +455,7 @@ class LSWrappers {
|
||||
}
|
||||
}
|
||||
}
|
||||
handledTypes["URLs"] = !handledUrlSchemes.isEmpty ? handledUrlSchemes : [:]
|
||||
handledTypes["URIs"] = !handledUriSchemes.isEmpty ? handledUriSchemes : [:]
|
||||
handledTypes["UTIs"] = !handledUTIs.isEmpty ? handledUTIs : [:]
|
||||
return handledTypes
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -27,14 +27,14 @@ final internal class ControllersRef: NSObject {
|
||||
/** Transform Tab names to abstract cases. */
|
||||
enum tabNames:String {
|
||||
case Internet
|
||||
case URLs
|
||||
case URIs
|
||||
case UTIs
|
||||
case Applications
|
||||
init? (value: String?) {
|
||||
if let value = value {
|
||||
switch value {
|
||||
case "Internet": self = .Internet
|
||||
case "URL Schemes": self = .URLs
|
||||
case "URI Schemes": self = .URIs
|
||||
case "Uniform Type Identifiers": self = .UTIs
|
||||
case "Applications": self = .Applications
|
||||
default: return nil
|
||||
@@ -55,7 +55,7 @@ final internal class ControllersRef: NSObject {
|
||||
if let Tab = Tab {
|
||||
switch Tab {
|
||||
case "Internet": return "contentDescription"
|
||||
case "URLs": return "contentName"
|
||||
case "URIs": return "contentName"
|
||||
case "UTIs": return "contentName"
|
||||
case "Applications": return "displayName"
|
||||
default: return "contentName"
|
||||
@@ -71,7 +71,7 @@ final internal class ControllersRef: NSObject {
|
||||
|
||||
switch Tab {
|
||||
case "Internet": modelArray = #keyPath(SWDAHandlersModel.internetSchemes)
|
||||
case "URLs": modelArray = #keyPath(SWDAHandlersModel.allSchemes)
|
||||
case "URIs": modelArray = #keyPath(SWDAHandlersModel.allSchemes)
|
||||
case "UTIs": modelArray = #keyPath(SWDAHandlersModel.allUTIs)
|
||||
case "Applications": modelArray = #keyPath(SWDAHandlersModel.allApps)
|
||||
default: modelArray = ""
|
||||
@@ -102,7 +102,7 @@ final internal class ControllersRef: NSObject {
|
||||
if let Tab = Tab {
|
||||
switch Tab {
|
||||
case "Internet": return false
|
||||
case "URLs": return true
|
||||
case "URIs": return true
|
||||
case "UTIs": return true
|
||||
case "Applications": return true
|
||||
default: return true
|
||||
@@ -111,11 +111,11 @@ final internal class ControllersRef: NSObject {
|
||||
else { return true }
|
||||
}
|
||||
|
||||
/** Determines whether to show the "Add" button for custom URL Schemes. */
|
||||
/** Determines whether to show the "Add" button for custom URI Schemes. */
|
||||
static var shouldShowAddRemove: Bool {
|
||||
if let Tab = Tab {
|
||||
switch Tab {
|
||||
case "URLs": return true
|
||||
case "URIs": return true
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ internal class SWDATreeRow:NSObject {
|
||||
guard (self.rowContent != nil) else { return false }
|
||||
let contentType = self.rowContent?.content.contentType
|
||||
guard (contentType != .Application) else { return false }
|
||||
let defaultHandler = (contentType == .URL) ? LSWrappers.Schemes.copyDefaultHandler(self.rowTitle, asPath: false) : LSWrappers.UTType.copyDefaultHandler(self.rowTitle, inRoles: LSRolesMask(from:self.roleMask!), asPath: false)
|
||||
let defaultHandler = (contentType == .URI) ? LSWrappers.Schemes.copyDefaultHandler(self.rowTitle, asPath: false) : LSWrappers.UTType.copyDefaultHandler(self.rowTitle, inRoles: LSRolesMask(from:self.roleMask!), asPath: false)
|
||||
return self.rowContent?.application?.appBundleID?.lowercased() == defaultHandler?.lowercased()
|
||||
}
|
||||
set {
|
||||
@@ -137,7 +137,7 @@ internal class SWDATreeRow:NSObject {
|
||||
switch content.contentType {
|
||||
case .Application: return false
|
||||
case .UTI: handler = LSWrappers.UTType.copyDefaultHandler(content.contentName, inRoles:LSRolesMask(from:self.roleMask!), asPath: false)
|
||||
case .URL: handler = LSWrappers.Schemes.copyDefaultHandler(content.contentName, asPath: false)
|
||||
case .URI: handler = LSWrappers.Schemes.copyDefaultHandler(content.contentName, asPath: false)
|
||||
}
|
||||
guard (handler != nil) else { return false }
|
||||
return (handler?.lowercased() == rowContent?.application?.appBundleID?.lowercased())
|
||||
|
||||
@@ -38,7 +38,7 @@ extension DRYView {
|
||||
return NSNumber(booleanLiteral:ControllersRef.TabData.shouldShowAppPath)
|
||||
}
|
||||
|
||||
/** The only tab where an "Add" button is at all meaningful is the URL Schemes. */
|
||||
/** The only tab where an "Add" button is at all meaningful is the URI Schemes. */
|
||||
@objc var showAddRemoveBool: NSNumber {
|
||||
guard (self.currentTab != nil) else { return NSNumber(booleanLiteral:false) }
|
||||
return NSNumber(booleanLiteral:ControllersRef.TabData.shouldShowAddRemove)
|
||||
@@ -103,7 +103,7 @@ class SWDATabTemplate: DRYView {
|
||||
}
|
||||
}
|
||||
|
||||
/** Add a custom URL Scheme and assign our dummy app as the default handler. In practice this should almost never be necessary but sometimes Launch Services move in mysterious ways. */
|
||||
/** Add a custom URI Scheme and assign our dummy app as the default handler. In practice this should almost never be necessary but sometimes Launch Services move in mysterious ways. */
|
||||
@IBAction func addCustomScheme(_ sender: NSButton) {
|
||||
guard (customNewScheme?.stringValue != nil) && (customNewScheme?.stringValue != "") else { return }
|
||||
let result = LSWrappers.Schemes.setDefaultHandler(customNewScheme!.stringValue, "cl.fail.lordkamina.ThisAppDoesNothing")
|
||||
@@ -216,7 +216,7 @@ class SWDATabViewController: NSTabViewController {
|
||||
top.identifier = "TabView Top"
|
||||
let bottom = NSLayoutConstraint(item: ControllersRef.sharedInstance.theMainView!, attribute: .bottom , relatedBy: .equal, toItem: self.tabView, attribute: .bottom , multiplier: 1, constant: 10)
|
||||
bottom.identifier = "TabView Bottom"
|
||||
let tabs = ["Internet", "URL Schemes", "Uniform Type Identifiers", "Applications"]
|
||||
let tabs = ["Internet", "URI Schemes", "Uniform Type Identifiers", "Applications"]
|
||||
|
||||
ControllersRef.sharedInstance.theMainView.addConstraints([centerX, leading, trailing, bottom, top])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user