From 3fdc55d6059c6fc46eb3ffff4d99a990cc71ba38 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sun, 17 Mar 2019 19:01:28 -0700 Subject: [PATCH] Start Accounts preferences pane. --- NetNewsWire.xcodeproj/project.pbxproj | 6 + NetNewsWire/Base.lproj/Preferences.storyboard | 118 +++++++++++++++++- .../AccountsPreferencesViewController.swift | 9 ++ .../PreferencesWindowController.swift | 10 +- 4 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 NetNewsWire/Preferences/AccountsPreferencesViewController.swift diff --git a/NetNewsWire.xcodeproj/project.pbxproj b/NetNewsWire.xcodeproj/project.pbxproj index f03d17506..c87ece915 100644 --- a/NetNewsWire.xcodeproj/project.pbxproj +++ b/NetNewsWire.xcodeproj/project.pbxproj @@ -299,6 +299,8 @@ 84CC88181FE59CBF00644329 /* SmartFeedsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84CC88171FE59CBF00644329 /* SmartFeedsController.swift */; }; 84D52E951FE588BB00D14F5B /* DetailStatusBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */; }; 84DAEE301F86CAFE0058304B /* OPMLImporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */; }; + 84E01AFD223F3050009D63C3 /* AccountsPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E01AFC223F3050009D63C3 /* AccountsPreferencesViewController.swift */; }; + 84E01AFE223F3050009D63C3 /* AccountsPreferencesViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E01AFC223F3050009D63C3 /* AccountsPreferencesViewController.swift */; }; 84E185B3203B74E500F69BFA /* SingleLineTextFieldSizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E185B2203B74E500F69BFA /* SingleLineTextFieldSizer.swift */; }; 84E185C3203BB12600F69BFA /* MultilineTextFieldSizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E185C2203BB12600F69BFA /* MultilineTextFieldSizer.swift */; }; 84E46C7D1F75EF7B005ECFB3 /* AppDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */; }; @@ -898,6 +900,7 @@ 84CC88171FE59CBF00644329 /* SmartFeedsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SmartFeedsController.swift; sourceTree = ""; }; 84D52E941FE588BB00D14F5B /* DetailStatusBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailStatusBarView.swift; sourceTree = ""; }; 84DAEE2F1F86CAFE0058304B /* OPMLImporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OPMLImporter.swift; sourceTree = ""; }; + 84E01AFC223F3050009D63C3 /* AccountsPreferencesViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AccountsPreferencesViewController.swift; path = NetNewsWire/Preferences/AccountsPreferencesViewController.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 = ""; }; 84E46C7C1F75EF7B005ECFB3 /* AppDefaults.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = AppDefaults.swift; path = NetNewsWire/AppDefaults.swift; sourceTree = ""; }; @@ -1125,6 +1128,7 @@ 849A97A41ED9F94D007D329B /* Preferences.storyboard */, 849A97841ED9ECCD007D329B /* PreferencesWindowController.swift */, 84754C89213E471B009CFDFB /* GeneralPrefencesViewController.swift */, + 84E01AFC223F3050009D63C3 /* AccountsPreferencesViewController.swift */, 84595CA121E9C880003E15A4 /* AdvancedPreferencesViewController.swift */, ); name = Preferences; @@ -2487,6 +2491,7 @@ 840F7C8321BDA4B40057E851 /* Feed+Scriptability.swift in Sources */, 840F7C8421BDA4B40057E851 /* AuthorAvatarDownloader.swift in Sources */, 840F7C8521BDA4B40057E851 /* SingleLineTextFieldSizer.swift in Sources */, + 84E01AFE223F3050009D63C3 /* AccountsPreferencesViewController.swift in Sources */, 840F7C8721BDA4B40057E851 /* TimelineTableCellView.swift in Sources */, 840F7C8821BDA4B40057E851 /* TimelineCellAppearance.swift in Sources */, 840F7C8921BDA4B40057E851 /* InitialFeedDownloader.swift in Sources */, @@ -2556,6 +2561,7 @@ 84FF69B11FC3793300DC198E /* FaviconURLFinder.swift in Sources */, 84B7178C201E66580091657D /* SidebarViewController+ContextualMenus.swift in Sources */, 842611A21FCB769D0086A189 /* RSHTMLMetadata+Extension.swift in Sources */, + 84E01AFD223F3050009D63C3 /* AccountsPreferencesViewController.swift in Sources */, 84A1500520048DDF0046AD9A /* SendToMarsEditCommand.swift in Sources */, D5907DB22004BB37005947E5 /* ScriptingObjectContainer.swift in Sources */, 849A978A1ED9ECEF007D329B /* ArticleStylesManager.swift in Sources */, diff --git a/NetNewsWire/Base.lproj/Preferences.storyboard b/NetNewsWire/Base.lproj/Preferences.storyboard index 3ff2770b0..fdaa07195 100644 --- a/NetNewsWire/Base.lproj/Preferences.storyboard +++ b/NetNewsWire/Base.lproj/Preferences.storyboard @@ -244,7 +244,123 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NetNewsWire/Preferences/AccountsPreferencesViewController.swift b/NetNewsWire/Preferences/AccountsPreferencesViewController.swift new file mode 100644 index 000000000..3e5089612 --- /dev/null +++ b/NetNewsWire/Preferences/AccountsPreferencesViewController.swift @@ -0,0 +1,9 @@ +// +// AccountsPreferencesViewController.swift +// NetNewsWire +// +// Created by Brent Simmons on 3/17/19. +// Copyright © 2019 Ranchero Software. All rights reserved. +// + +import Foundation diff --git a/NetNewsWire/Preferences/PreferencesWindowController.swift b/NetNewsWire/Preferences/PreferencesWindowController.swift index ca51b2b23..26b3f7bd6 100644 --- a/NetNewsWire/Preferences/PreferencesWindowController.swift +++ b/NetNewsWire/Preferences/PreferencesWindowController.swift @@ -23,6 +23,7 @@ private struct PreferencesToolbarItemSpec { private struct ToolbarItemIdentifier { static let General = "General" + static let Accounts = "Accounts" static let Advanced = "Advanced" } @@ -34,12 +35,12 @@ class PreferencesWindowController : NSWindowController, NSToolbarDelegate { private let toolbarItemSpecs: [PreferencesToolbarItemSpec] = { var specs = [PreferencesToolbarItemSpec]() specs += [PreferencesToolbarItemSpec(identifierRawValue: ToolbarItemIdentifier.General, name: NSLocalizedString("General", comment: "Preferences"), imageName: NSImage.preferencesGeneralName)] + specs += [PreferencesToolbarItemSpec(identifierRawValue: ToolbarItemIdentifier.Accounts, name: NSLocalizedString("Accounts", comment: "Preferences"), imageName: NSImage.userAccountsName)] specs += [PreferencesToolbarItemSpec(identifierRawValue: ToolbarItemIdentifier.Advanced, name: NSLocalizedString("Advanced", comment: "Preferences"), imageName: NSImage.advancedName)] return specs }() override func windowDidLoad() { - let toolbar = NSToolbar(identifier: NSToolbar.Identifier("PreferencesToolbar")) toolbar.delegate = self toolbar.autosavesConfiguration = false @@ -83,17 +84,14 @@ class PreferencesWindowController : NSWindowController, NSToolbarDelegate { } func toolbarDefaultItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - return toolbarItemSpecs.map { $0.identifier } } func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - return toolbarDefaultItemIdentifiers(toolbar) } func toolbarSelectableItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] { - return toolbarDefaultItemIdentifiers(toolbar) } } @@ -105,18 +103,15 @@ private extension PreferencesWindowController { } func toolbarItemSpec(for identifier: String) -> PreferencesToolbarItemSpec? { - return toolbarItemSpecs.first(where: { $0.identifier.rawValue == identifier }) } func switchToViewAtIndex(_ index: Int) { - let identifier = toolbarItemSpecs[index].identifier switchToView(identifier: identifier.rawValue) } func switchToView(identifier: String) { - guard let toolbarItemSpec = toolbarItemSpec(for: identifier) else { assertionFailure("Preferences window: no toolbarItemSpec matching \(identifier).") return @@ -149,7 +144,6 @@ private extension PreferencesWindowController { } func viewController(identifier: String) -> NSViewController? { - if let cachedViewController = viewControllers[identifier] { return cachedViewController }