From 29996415728dd7c6bd362dd7f5dd95c91ea99685 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 4 Feb 2018 11:19:24 -0800 Subject: [PATCH] Move MainWindowController+ContextualMenus to SidebarViewController+ContextualMenus, where it always should have been. --- Evergreen.xcodeproj/project.pbxproj | 16 ++++------------ Evergreen/MainWindow/MainWindowController.swift | 2 -- .../SidebarViewController+ContextualMenus.swift} | 16 ++++++++-------- .../Sidebar/SidebarViewController.swift | 7 +++---- 4 files changed, 15 insertions(+), 26 deletions(-) rename Evergreen/MainWindow/{ContextualMenus/MainWindowController+ContextualMenus.swift => Sidebar/SidebarViewController+ContextualMenus.swift} (89%) diff --git a/Evergreen.xcodeproj/project.pbxproj b/Evergreen.xcodeproj/project.pbxproj index eb46d8676..70a5f6e6c 100644 --- a/Evergreen.xcodeproj/project.pbxproj +++ b/Evergreen.xcodeproj/project.pbxproj @@ -108,7 +108,7 @@ 84B06FFE1ED3818D00F0B54B /* RSTree.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84B06FFA1ED3818000F0B54B /* RSTree.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 84B0700A1ED3822600F0B54B /* RSTextDrawing.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 84B070071ED3821900F0B54B /* RSTextDrawing.framework */; }; 84B0700B1ED3822600F0B54B /* RSTextDrawing.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 84B070071ED3821900F0B54B /* RSTextDrawing.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - 84B7178C201E66580091657D /* MainWindowController+ContextualMenus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B7178B201E66580091657D /* MainWindowController+ContextualMenus.swift */; }; + 84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B7178B201E66580091657D /* SidebarViewController+ContextualMenus.swift */; }; 84B99C671FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C661FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift */; }; 84B99C691FAE36B800ECDEDB /* FeedListFolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C681FAE36B800ECDEDB /* FeedListFolder.swift */; }; 84B99C6B1FAE370B00ECDEDB /* FeedListFeed.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84B99C6A1FAE370B00ECDEDB /* FeedListFeed.swift */; }; @@ -584,7 +584,7 @@ 84B06FF41ED3818000F0B54B /* RSTree.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSTree.xcodeproj; path = Frameworks/RSTree/RSTree.xcodeproj; sourceTree = ""; }; 84B070011ED3821800F0B54B /* RSTextDrawing.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RSTextDrawing.xcodeproj; path = Frameworks/RSTextDrawing/RSTextDrawing.xcodeproj; sourceTree = ""; }; 84B23425202689F5007C5900 /* Evergreen-iOS.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = "Evergreen-iOS.xcodeproj"; sourceTree = ""; }; - 84B7178B201E66580091657D /* MainWindowController+ContextualMenus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "MainWindowController+ContextualMenus.swift"; sourceTree = ""; }; + 84B7178B201E66580091657D /* SidebarViewController+ContextualMenus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SidebarViewController+ContextualMenus.swift"; sourceTree = ""; }; 84B99C661FAE35E600ECDEDB /* FeedListTreeControllerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListTreeControllerDelegate.swift; sourceTree = ""; }; 84B99C681FAE36B800ECDEDB /* FeedListFolder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListFolder.swift; sourceTree = ""; }; 84B99C6A1FAE370B00ECDEDB /* FeedListFeed.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeedListFeed.swift; sourceTree = ""; }; @@ -699,7 +699,6 @@ 849A977C1ED9EC42007D329B /* Detail */, 849A97551ED9EAC3007D329B /* Add Feed */, 849A97411ED9EAA9007D329B /* Add Folder */, - 84B7178A201E66580091657D /* ContextualMenus */, ); name = MainWindow; path = Evergreen/MainWindow; @@ -840,6 +839,7 @@ isa = PBXGroup; children = ( 849A97621ED9EB96007D329B /* SidebarViewController.swift */, + 84B7178B201E66580091657D /* SidebarViewController+ContextualMenus.swift */, 849A97601ED9EB96007D329B /* SidebarOutlineView.swift */, 849A97611ED9EB96007D329B /* SidebarTreeControllerDelegate.swift */, 849A97631ED9EB96007D329B /* UnreadCountView.swift */, @@ -1124,14 +1124,6 @@ name = Products; sourceTree = ""; }; - 84B7178A201E66580091657D /* ContextualMenus */ = { - isa = PBXGroup; - children = ( - 84B7178B201E66580091657D /* MainWindowController+ContextualMenus.swift */, - ); - path = ContextualMenus; - sourceTree = ""; - }; 84BB4B621F1174D400858766 /* Products */ = { isa = PBXGroup; children = ( @@ -1693,7 +1685,7 @@ 84A14FF320048CA70046AD9A /* SendToMicroBlogCommand.swift in Sources */, 849A97891ED9ECEF007D329B /* ArticleStyle.swift in Sources */, 84FF69B11FC3793300DC198E /* FaviconURLFinder.swift in Sources */, - 84B7178C201E66580091657D /* MainWindowController+ContextualMenus.swift in Sources */, + 84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */, 842611A21FCB769D0086A189 /* RSHTMLMetadata+Extension.swift in Sources */, 84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */, D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */, diff --git a/Evergreen/MainWindow/MainWindowController.swift b/Evergreen/MainWindow/MainWindowController.swift index cd9c5402d..3132c8149 100644 --- a/Evergreen/MainWindow/MainWindowController.swift +++ b/Evergreen/MainWindow/MainWindowController.swift @@ -25,8 +25,6 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { return false } - var renameWindowController: RenameWindowController? - // MARK: NSWindowController private let windowAutosaveName = NSWindow.FrameAutosaveName(rawValue: kWindowFrameKey) diff --git a/Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift similarity index 89% rename from Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift rename to Evergreen/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift index 2f6253210..8f91fcfa4 100644 --- a/Evergreen/MainWindow/ContextualMenus/MainWindowController+ContextualMenus.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController+ContextualMenus.swift @@ -1,5 +1,5 @@ // -// MainWindowController+ContextualMenus.swift +// SidebarViewController+ContextualMenus.swift // Evergreen // // Created by Brent Simmons on 1/28/18. @@ -11,7 +11,7 @@ import Data import Account import RSCore -extension MainWindowController { +extension SidebarViewController { func menu(for objects: [Any]?) -> NSMenu? { @@ -35,7 +35,7 @@ extension MainWindowController { // MARK: Contextual Menu Actions -extension MainWindowController { +extension SidebarViewController { @objc func openHomePageFromContextualMenu(_ sender: Any?) { @@ -64,7 +64,7 @@ extension MainWindowController { @objc func renameFromContextualMenu(_ sender: Any?) { - guard let window = window, let menuItem = sender as? NSMenuItem, let object = menuItem.representedObject as? DisplayNameProvider, object is Feed || object is Folder else { + guard let window = view.window, let menuItem = sender as? NSMenuItem, let object = menuItem.representedObject as? DisplayNameProvider, object is Feed || object is Folder else { return } @@ -76,7 +76,7 @@ extension MainWindowController { } } -extension MainWindowController: RenameWindowControllerDelegate { +extension SidebarViewController: RenameWindowControllerDelegate { func renameWindowController(_ windowController: RenameWindowController, didRenameObject object: Any, withNewName name: String) { @@ -91,14 +91,14 @@ extension MainWindowController: RenameWindowControllerDelegate { // MARK: Build Contextual Menus -private extension MainWindowController { +private extension SidebarViewController { func menuForNoSelection() -> NSMenu { let menu = NSMenu(title: "") - menu.addItem(withTitle: NSLocalizedString("New Feed", comment: "Command"), action: #selector(showAddFeedWindow(_:)), keyEquivalent: "") - menu.addItem(withTitle: NSLocalizedString("New Folder", comment: "Command"), action: #selector(showAddFolderWindow(_:)), keyEquivalent: "") + menu.addItem(withTitle: NSLocalizedString("New Feed", comment: "Command"), action: #selector(MainWindowController.showAddFeedWindow(_:)), keyEquivalent: "") + menu.addItem(withTitle: NSLocalizedString("New Folder", comment: "Command"), action: #selector(MainWindowController.showAddFolderWindow(_:)), keyEquivalent: "") return menu } diff --git a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift index 58721cefa..788051ae5 100644 --- a/Evergreen/MainWindow/Sidebar/SidebarViewController.swift +++ b/Evergreen/MainWindow/Sidebar/SidebarViewController.swift @@ -25,6 +25,8 @@ import RSCore private var animatingChanges = false private var sidebarCellAppearance: SidebarCellAppearance! + var renameWindowController: RenameWindowController? + var selectedObjects: [AnyObject] { return selectedNodes.representedObjects() } @@ -195,10 +197,7 @@ import RSCore func contextualMenuForSelectedObjects() -> NSMenu? { - guard let mainWindowController = view.window?.windowController as? MainWindowController else { - return nil - } - return mainWindowController.menu(for: selectedObjects) + return menu(for: selectedObjects) } // MARK: NSOutlineViewDelegate