diff --git a/Passepartout/App/Descriptible.swift b/Passepartout/App/Descriptible.swift index ca90a8de..b1993ae1 100644 --- a/Passepartout/App/Descriptible.swift +++ b/Passepartout/App/Descriptible.swift @@ -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 diff --git a/Passepartout/App/macOS/Global/Macros.swift b/Passepartout/App/macOS/Global/Macros.swift index 0f04ae99..99035fc9 100644 --- a/Passepartout/App/macOS/Global/Macros.swift +++ b/Passepartout/App/macOS/Global/Macros.swift @@ -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 { diff --git a/Passepartout/App/macOS/Scenes/Service/Customization/ConfigurationViewController.swift b/Passepartout/App/macOS/Scenes/Service/Customization/ConfigurationViewController.swift index 7068bfcb..cb6f6f81 100644 --- a/Passepartout/App/macOS/Scenes/Service/Customization/ConfigurationViewController.swift +++ b/Passepartout/App/macOS/Scenes/Service/Customization/ConfigurationViewController.swift @@ -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