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 }
|
||||
}
|
||||
|
||||
extension String: UIDescriptible {
|
||||
public var uiDescription: String {
|
||||
return description
|
||||
}
|
||||
}
|
||||
|
||||
extension OpenVPN.Cipher: UIDescriptible {
|
||||
public var uiDescription: String {
|
||||
return description
|
||||
|
|
|
@ -138,6 +138,14 @@ extension NSMenu {
|
|||
}
|
||||
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 {
|
||||
|
|
|
@ -141,12 +141,12 @@ class ConfigurationViewController: NSViewController, ProfileCustomization {
|
|||
rowMenus[.compressionAlgorithm] = NSMenu.withDescriptibles(availableCA)
|
||||
|
||||
// single-option menus (unselectable)
|
||||
rowMenus[.client] = NSMenu.withDescriptibles([configuration.uiDescriptionForClientCertificate])
|
||||
rowMenus[.tlsWrapping] = NSMenu.withDescriptibles([configuration.uiDescriptionForTLSWrap])
|
||||
rowMenus[.eku] = NSMenu.withDescriptibles([configuration.uiDescriptionForEKU])
|
||||
rowMenus[.keepAlive] = NSMenu.withDescriptibles([configuration.uiDescriptionForKeepAlive])
|
||||
rowMenus[.renegSeconds] = NSMenu.withDescriptibles([configuration.uiDescriptionForRenegotiatesAfter])
|
||||
rowMenus[.randomEndpoint] = NSMenu.withDescriptibles([configuration.uiDescriptionForRandomizeEndpoint])
|
||||
rowMenus[.client] = NSMenu.withString(configuration.uiDescriptionForClientCertificate)
|
||||
rowMenus[.tlsWrapping] = NSMenu.withString(configuration.uiDescriptionForTLSWrap)
|
||||
rowMenus[.eku] = NSMenu.withString(configuration.uiDescriptionForEKU)
|
||||
rowMenus[.keepAlive] = NSMenu.withString(configuration.uiDescriptionForKeepAlive)
|
||||
rowMenus[.renegSeconds] = NSMenu.withString(configuration.uiDescriptionForRenegotiatesAfter)
|
||||
rowMenus[.randomEndpoint] = NSMenu.withString(configuration.uiDescriptionForRandomizeEndpoint)
|
||||
}
|
||||
|
||||
// MARK: Actions
|
||||
|
@ -229,7 +229,7 @@ extension ConfigurationViewController: NSTableViewDataSource, NSTableViewDelegat
|
|||
|
||||
case Columns.value:
|
||||
guard let menu = rowMenus[rowObject], let cell = tableColumn?.dataCell(forRow: row) as? NSPopUpButtonCell else {
|
||||
return nil
|
||||
break
|
||||
}
|
||||
cell.menu = menu
|
||||
cell.imageDimsWhenDisabled = false
|
||||
|
|
Loading…
Reference in New Issue