diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index dd9220cb0..d51bcb8c7 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -31,7 +31,6 @@ 840F7C2121BDA4B40057E851 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */; }; 840F7C2221BDA4B40057E851 /* Account+Scriptability.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5907D962004B7EB005947E5 /* Account+Scriptability.swift */; }; 840F7C2321BDA4B40057E851 /* NothingInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 841ABA4D20145E7300980E11 /* NothingInspectorViewController.swift */; }; - 840F7C2421BDA4B40057E851 /* SidebarContextualMenuDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847FA120202BA34100BB56C8 /* SidebarContextualMenuDelegate.swift */; }; 840F7C2521BDA4B40057E851 /* AppNotifications.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842E45CD1ED8C308000A8B52 /* AppNotifications.swift */; }; 840F7C2621BDA4B40057E851 /* TimelineKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B5B5A1FEA00FB00C7C76A /* TimelineKeyboardDelegate.swift */; }; 840F7C2821BDA4B40057E851 /* Browser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 842E45DC1ED8C54B000A8B52 /* Browser.swift */; }; @@ -115,7 +114,6 @@ 840F7C7721BDA4B40057E851 /* TimelineTableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 849A976A1ED9EBC8007D329B /* TimelineTableView.swift */; }; 840F7C7921BDA4B40057E851 /* DetailStatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */; }; 840F7C7A21BDA4B40057E851 /* MainWindowController+Scriptability.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5E4CC63202C1AC1009B4FFC /* MainWindowController+Scriptability.swift */; }; - 840F7C7B21BDA4B40057E851 /* SidebarGearMenuDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D5BA1F201E8FB6009092BD /* SidebarGearMenuDelegate.swift */; }; 840F7C7C21BDA4B40057E851 /* SmallIconProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84411E701FE5FBFA004B527F /* SmallIconProvider.swift */; }; 840F7C7D21BDA4B40057E851 /* SidebarKeyboardDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 844B5B581FE9FE4F00C7C76A /* SidebarKeyboardDelegate.swift */; }; 840F7C7E21BDA4B40057E851 /* FolderTreeMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51EC114B2149FE3300B296E3 /* FolderTreeMenu.swift */; }; @@ -210,7 +208,6 @@ 84702AA41FA27AC0006B8943 /* MarkStatusCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84702AA31FA27AC0006B8943 /* MarkStatusCommand.swift */; }; 8472058120142E8900AD578B /* FeedInspectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8472058020142E8900AD578B /* FeedInspectorViewController.swift */; }; 84754C8A213E471B009CFDFB /* GeneralPrefencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84754C89213E471B009CFDFB /* GeneralPrefencesViewController.swift */; }; - 847FA121202BA34100BB56C8 /* SidebarContextualMenuDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 847FA120202BA34100BB56C8 /* SidebarContextualMenuDelegate.swift */; }; 848B937221C8C5540038DC0D /* CrashReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848B937121C8C5540038DC0D /* CrashReporter.swift */; }; 848D578E21543519005FFAD5 /* PasteboardFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848D578D21543519005FFAD5 /* PasteboardFeed.swift */; }; 848F6AE51FC29CFB002D422E /* FaviconDownloader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 848F6AE41FC29CFA002D422E /* FaviconDownloader.swift */; }; @@ -286,7 +283,6 @@ 84C37FC620DD8E1D00CA8CF5 /* RSDatabase.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84C37FC020DD8E0C00CA8CF5 /* RSDatabase.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CC88171FE59CBF00644329 /* SmartFeedsController.swift */; }; 84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */; }; - 84D5BA20201E8FB6009092BD /* SidebarGearMenuDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D5BA1F201E8FB6009092BD /* SidebarGearMenuDelegate.swift */; }; 84DAEE301F86CAFE0058304B /* OPMLImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */; }; 84E185B3203B74E500F69BFA /* SingleLineTextFieldSizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E185B2203B74E500F69BFA /* SingleLineTextFieldSizer.swift */; }; 84E185C3203BB12600F69BFA /* MultilineTextFieldSizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E185C2203BB12600F69BFA /* MultilineTextFieldSizer.swift */; }; @@ -797,7 +793,6 @@ 8472058020142E8900AD578B /* FeedInspectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedInspectorViewController.swift; sourceTree = ""; }; 84754C89213E471B009CFDFB /* GeneralPrefencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = GeneralPrefencesViewController.swift; path = NetNewsWire/Preferences/GeneralPrefencesViewController.swift; sourceTree = ""; }; 847752FE2008879500D93690 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; }; - 847FA120202BA34100BB56C8 /* SidebarContextualMenuDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarContextualMenuDelegate.swift; sourceTree = ""; }; 848B930921C8B0BF0038DC0D /* Subscribe-to-Feed-MAS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "Subscribe-to-Feed-MAS-Info.plist"; sourceTree = ""; }; 848B937121C8C5540038DC0D /* CrashReporter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrashReporter.swift; sourceTree = ""; }; 848D578D21543519005FFAD5 /* PasteboardFeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasteboardFeed.swift; sourceTree = ""; }; @@ -880,7 +875,6 @@ 84CC08051FF5D2E000C0C0ED /* FeedListSplitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListSplitViewController.swift; sourceTree = ""; }; 84CC88171FE59CBF00644329 /* SmartFeedsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartFeedsController.swift; sourceTree = ""; }; 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailStatusBarView.swift; sourceTree = ""; }; - 84D5BA1F201E8FB6009092BD /* SidebarGearMenuDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarGearMenuDelegate.swift; sourceTree = ""; }; 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPMLImporter.swift; sourceTree = ""; }; 84E185B2203B74E500F69BFA /* SingleLineTextFieldSizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SingleLineTextFieldSizer.swift; sourceTree = ""; }; 84E185C2203BB12600F69BFA /* MultilineTextFieldSizer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultilineTextFieldSizer.swift; sourceTree = ""; }; @@ -1284,8 +1278,6 @@ 848D578D21543519005FFAD5 /* PasteboardFeed.swift */, 84AD1EA92031617300BC20B7 /* FolderPasteboardWriter.swift */, 849A97821ED9EC63007D329B /* SidebarStatusBarView.swift */, - 84D5BA1F201E8FB6009092BD /* SidebarGearMenuDelegate.swift */, - 847FA120202BA34100BB56C8 /* SidebarContextualMenuDelegate.swift */, 844B5B6A1FEA224000C7C76A /* Keyboard */, 845A29251FC928C7007B49E3 /* Cell */, 84A37CB3201ECD610087C5AF /* Renaming */, @@ -2354,7 +2346,6 @@ 840F7C2121BDA4B40057E851 /* AppDefaults.swift in Sources */, 840F7C2221BDA4B40057E851 /* Account+Scriptability.swift in Sources */, 840F7C2321BDA4B40057E851 /* NothingInspectorViewController.swift in Sources */, - 840F7C2421BDA4B40057E851 /* SidebarContextualMenuDelegate.swift in Sources */, 840F7C2521BDA4B40057E851 /* AppNotifications.swift in Sources */, 840F7C2621BDA4B40057E851 /* TimelineKeyboardDelegate.swift in Sources */, 840F7C2821BDA4B40057E851 /* Browser.swift in Sources */, @@ -2438,7 +2429,6 @@ 840F7C7721BDA4B40057E851 /* TimelineTableView.swift in Sources */, 840F7C7921BDA4B40057E851 /* DetailStatusBarView.swift in Sources */, 840F7C7A21BDA4B40057E851 /* MainWindowController+Scriptability.swift in Sources */, - 840F7C7B21BDA4B40057E851 /* SidebarGearMenuDelegate.swift in Sources */, 840F7C7C21BDA4B40057E851 /* SmallIconProvider.swift in Sources */, 840F7C7D21BDA4B40057E851 /* SidebarKeyboardDelegate.swift in Sources */, 840F7C7E21BDA4B40057E851 /* FolderTreeMenu.swift in Sources */, @@ -2477,7 +2467,6 @@ 84E46C7D1F75EF7B005ECFB3 /* AppDefaults.swift in Sources */, D5907D972004B7EB005947E5 /* Account+Scriptability.swift in Sources */, 841ABA4E20145E7300980E11 /* NothingInspectorViewController.swift in Sources */, - 847FA121202BA34100BB56C8 /* SidebarContextualMenuDelegate.swift in Sources */, 842E45CE1ED8C308000A8B52 /* AppNotifications.swift in Sources */, 844B5B5B1FEA00FB00C7C76A /* TimelineKeyboardDelegate.swift in Sources */, 842E45DD1ED8C54B000A8B52 /* Browser.swift in Sources */, @@ -2563,7 +2552,6 @@ 849A976D1ED9EBC8007D329B /* TimelineTableView.swift in Sources */, 84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */, D5E4CC64202C1AC1009B4FFC /* MainWindowController+Scriptability.swift in Sources */, - 84D5BA20201E8FB6009092BD /* SidebarGearMenuDelegate.swift in Sources */, 84411E711FE5FBFA004B527F /* SmallIconProvider.swift in Sources */, 844B5B591FE9FE4F00C7C76A /* SidebarKeyboardDelegate.swift in Sources */, 51EC114C2149FE3300B296E3 /* FolderTreeMenu.swift in Sources */, diff --git a/NetNewsWire/Base.lproj/MainWindow.storyboard b/NetNewsWire/Base.lproj/MainWindow.storyboard index 837618a00..2bc758145 100644 --- a/NetNewsWire/Base.lproj/MainWindow.storyboard +++ b/NetNewsWire/Base.lproj/MainWindow.storyboard @@ -385,8 +385,6 @@ - - @@ -404,24 +402,14 @@ - + - - - - - - - - - - diff --git a/NetNewsWire/MainWindow/Sidebar/SidebarContextualMenuDelegate.swift b/NetNewsWire/MainWindow/Sidebar/SidebarContextualMenuDelegate.swift deleted file mode 100644 index f107e7fc5..000000000 --- a/NetNewsWire/MainWindow/Sidebar/SidebarContextualMenuDelegate.swift +++ /dev/null @@ -1,31 +0,0 @@ -// -// SidebarContextualMenuDelegate.swift -// NetNewsWire -// -// Created by Brent Simmons on 2/7/18. -// Copyright © 2018 Ranchero Software. All rights reserved. -// - -import AppKit -import RSCore - -@objc final class SidebarContextualMenuDelegate: NSObject, NSMenuDelegate { - - @IBOutlet weak var sidebarViewController: SidebarViewController? - - public func menuNeedsUpdate(_ menu: NSMenu) { - - guard let sidebarViewController = sidebarViewController else { - return - } - - menu.removeAllItems() - - guard let contextualMenu = sidebarViewController.contextualMenuForClickedRows() else { - return - } - - menu.takeItems(from: contextualMenu) - } -} - diff --git a/NetNewsWire/MainWindow/Sidebar/SidebarGearMenuDelegate.swift b/NetNewsWire/MainWindow/Sidebar/SidebarGearMenuDelegate.swift deleted file mode 100644 index d777c3105..000000000 --- a/NetNewsWire/MainWindow/Sidebar/SidebarGearMenuDelegate.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// SidebarGearMenuDelegate.swift -// NetNewsWire -// -// Created by Brent Simmons on 1/28/18. -// Copyright © 2018 Ranchero Software. All rights reserved. -// - -import AppKit - -@objc final class SidebarGearMenuDelegate: NSObject, NSMenuDelegate { - - @IBOutlet weak var sidebarViewController: SidebarViewController? - - public func menuNeedsUpdate(_ menu: NSMenu) { - - // Save the first item, since it’s the gear icon itself. - guard let gearMenuItem = menu.item(at: 0) else { - assertionFailure("Expected sidebar gear menu to have at least one item.") - return - } - menu.removeAllItems() - menu.addItem(gearMenuItem) - - guard let sidebarViewController = sidebarViewController else { - return - } - guard let contextualMenu = sidebarViewController.contextualMenuForSelectedObjects() else { - return - } - - let items = contextualMenu.items - contextualMenu.removeAllItems() - for menuItem in items { - menu.addItem(menuItem) - } - } -} diff --git a/NetNewsWire/MainWindow/Sidebar/SidebarViewController.swift b/NetNewsWire/MainWindow/Sidebar/SidebarViewController.swift index dccd9915d..9bf6a37dd 100644 --- a/NetNewsWire/MainWindow/Sidebar/SidebarViewController.swift +++ b/NetNewsWire/MainWindow/Sidebar/SidebarViewController.swift @@ -12,11 +12,9 @@ import Articles import Account import RSCore -@objc class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSOutlineViewDataSource, UndoableCommandRunner { +@objc class SidebarViewController: NSViewController, NSOutlineViewDelegate, NSOutlineViewDataSource, NSMenuDelegate, UndoableCommandRunner { @IBOutlet var outlineView: SidebarOutlineView! - @IBOutlet var gearMenuDelegate: SidebarGearMenuDelegate! - @IBOutlet var contextualMenuDelegate: SidebarContextualMenuDelegate! let treeControllerDelegate = SidebarTreeControllerDelegate() lazy var treeController: TreeController = { @@ -222,6 +220,17 @@ import RSCore return menu(for: [object]) } + // MARK: NSMenuDelegate + + public func menuNeedsUpdate(_ menu: NSMenu) { + menu.removeAllItems() + guard let contextualMenu = contextualMenuForClickedRows() else { + return + } + menu.takeItems(from: contextualMenu) + } + + // MARK: - NSOutlineViewDelegate func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {