Add macro for single-option menu
This commit is contained in:
parent
30f9cfc05b
commit
29f2e01c06
|
@ -30,12 +30,6 @@ public protocol UIDescriptible {
|
||||||
var uiDescription: String { get }
|
var uiDescription: String { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String: UIDescriptible {
|
|
||||||
public var uiDescription: String {
|
|
||||||
return description
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extension OpenVPN.Cipher: UIDescriptible {
|
extension OpenVPN.Cipher: UIDescriptible {
|
||||||
public var uiDescription: String {
|
public var uiDescription: String {
|
||||||
return description
|
return description
|
||||||
|
|
|
@ -138,6 +138,14 @@ extension NSMenu {
|
||||||
}
|
}
|
||||||
return menu
|
return menu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func withString(_ string: String) -> NSMenu {
|
||||||
|
let menu = NSMenu()
|
||||||
|
let item = NSMenuItem(title: string, action: nil, keyEquivalent: "")
|
||||||
|
item.representedObject = string
|
||||||
|
menu.addItem(item)
|
||||||
|
return menu
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension String {
|
extension String {
|
||||||
|
|
|
@ -141,12 +141,12 @@ class ConfigurationViewController: NSViewController, ProfileCustomization {
|
||||||
rowMenus[.compressionAlgorithm] = NSMenu.withDescriptibles(availableCA)
|
rowMenus[.compressionAlgorithm] = NSMenu.withDescriptibles(availableCA)
|
||||||
|
|
||||||
// single-option menus (unselectable)
|
// single-option menus (unselectable)
|
||||||
rowMenus[.client] = NSMenu.withDescriptibles([configuration.uiDescriptionForClientCertificate])
|
rowMenus[.client] = NSMenu.withString(configuration.uiDescriptionForClientCertificate)
|
||||||
rowMenus[.tlsWrapping] = NSMenu.withDescriptibles([configuration.uiDescriptionForTLSWrap])
|
rowMenus[.tlsWrapping] = NSMenu.withString(configuration.uiDescriptionForTLSWrap)
|
||||||
rowMenus[.eku] = NSMenu.withDescriptibles([configuration.uiDescriptionForEKU])
|
rowMenus[.eku] = NSMenu.withString(configuration.uiDescriptionForEKU)
|
||||||
rowMenus[.keepAlive] = NSMenu.withDescriptibles([configuration.uiDescriptionForKeepAlive])
|
rowMenus[.keepAlive] = NSMenu.withString(configuration.uiDescriptionForKeepAlive)
|
||||||
rowMenus[.renegSeconds] = NSMenu.withDescriptibles([configuration.uiDescriptionForRenegotiatesAfter])
|
rowMenus[.renegSeconds] = NSMenu.withString(configuration.uiDescriptionForRenegotiatesAfter)
|
||||||
rowMenus[.randomEndpoint] = NSMenu.withDescriptibles([configuration.uiDescriptionForRandomizeEndpoint])
|
rowMenus[.randomEndpoint] = NSMenu.withString(configuration.uiDescriptionForRandomizeEndpoint)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Actions
|
// MARK: Actions
|
||||||
|
@ -229,7 +229,7 @@ extension ConfigurationViewController: NSTableViewDataSource, NSTableViewDelegat
|
||||||
|
|
||||||
case Columns.value:
|
case Columns.value:
|
||||||
guard let menu = rowMenus[rowObject], let cell = tableColumn?.dataCell(forRow: row) as? NSPopUpButtonCell else {
|
guard let menu = rowMenus[rowObject], let cell = tableColumn?.dataCell(forRow: row) as? NSPopUpButtonCell else {
|
||||||
return nil
|
break
|
||||||
}
|
}
|
||||||
cell.menu = menu
|
cell.menu = menu
|
||||||
cell.imageDimsWhenDisabled = false
|
cell.imageDimsWhenDisabled = false
|
||||||
|
|
Loading…
Reference in New Issue