@@ -12,16 +12,16 @@ final class ActionMenu: NSMenu {
1212
1313 private weak var application : Application !
1414
15- private static let standardActions : [ ApplicationActionable ] = [
16- RevealInFinderAction ( ) ,
17- CopyToPasteboardAction ( ) ,
18- OpenInTerminalAction ( ) ,
19- UninstallAction ( )
15+ private static let standardActions : [ ApplicationActionable . Type ] = [
16+ RevealInFinderAction . self ,
17+ CopyToPasteboardAction . self ,
18+ OpenInTerminalAction . self ,
19+ UninstallAction . self
2020 ]
2121
22- private static let extraActions : [ ApplicationActionable ] = [
23- OpenInItermAction ( ) ,
24- OpenRealmAction ( )
22+ private static let extraActions : [ ApplicationActionable . Type ] = [
23+ OpenInItermAction . self ,
24+ OpenRealmAction . self
2525 ]
2626
2727 private var appInfoItem : NSMenuItem {
@@ -43,8 +43,10 @@ final class ActionMenu: NSMenu {
4343 }
4444
4545 private func buildMenuItems( ) {
46- self . buildMenuSection ( title: NSLocalizedString ( " Actions " , comment: " " ) , actions: ActionMenu . standardActions)
47- self . buildMenuSection ( title: NSLocalizedString ( " Extensions " , comment: " " ) , actions: ActionMenu . extraActions)
46+ let createAction : ( ApplicationActionable . Type ) -> ApplicationActionable = { $0. init ( application: self . application) }
47+
48+ self . buildMenuSection ( title: NSLocalizedString ( " Actions " , comment: " " ) , actions: ActionMenu . standardActions. map ( createAction) )
49+ self . buildMenuSection ( title: NSLocalizedString ( " Extensions " , comment: " " ) , actions: ActionMenu . extraActions. map ( createAction) )
4850 self . addItem ( self . buildSectionTitle ( title: NSLocalizedString ( " App Information " , comment: " " ) ) )
4951 self . addItem ( appInfoItem)
5052 }
@@ -79,7 +81,7 @@ final class ActionMenu: NSMenu {
7981 }
8082
8183 @objc private func actionMenuItemClicked( _ sender: NSMenuItem ) {
82- ( sender. representedObject as? ApplicationActionable ) ? . perform ( with : application )
84+ ( sender. representedObject as? ApplicationActionable ) ? . perform ( )
8385 }
8486
8587}
0 commit comments