From 9bcd90c44fbd5599cb295a810eb18c78f4a6e1df Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 18 Sep 2026 08:18:26 -0700 Subject: [PATCH] Convert Inspector from storyboard to xib. Add localization. --- Mac/AppDelegate.swift | 2 +- .../Base.lproj/BuiltinSmartFeedInspector.xib | 52 +++ Mac/Inspector/Base.lproj/FeedInspector.xib | 127 ++++++++ Mac/Inspector/Base.lproj/FolderInspector.xib | 58 ++++ Mac/Inspector/Base.lproj/InspectorWindow.xib | 27 ++ Mac/Inspector/Base.lproj/NothingInspector.xib | 51 +++ ...ltinSmartFeedInspectorViewController.swift | 4 + .../FeedInspectorViewController.swift | 4 + .../FolderInspectorViewController.swift | 4 + Mac/Inspector/Inspector.storyboard | 300 ------------------ Mac/Inspector/InspectorWindowController.swift | 19 +- .../NothingInspectorViewController.swift | 4 + .../mul.lproj/FeedInspector.xcstrings | 78 +++++ .../mul.lproj/NothingInspector.xcstrings | 42 +++ 14 files changed, 458 insertions(+), 314 deletions(-) create mode 100644 Mac/Inspector/Base.lproj/BuiltinSmartFeedInspector.xib create mode 100644 Mac/Inspector/Base.lproj/FeedInspector.xib create mode 100644 Mac/Inspector/Base.lproj/FolderInspector.xib create mode 100644 Mac/Inspector/Base.lproj/InspectorWindow.xib create mode 100644 Mac/Inspector/Base.lproj/NothingInspector.xib delete mode 100644 Mac/Inspector/Inspector.storyboard create mode 100644 Mac/Inspector/mul.lproj/FeedInspector.xcstrings create mode 100644 Mac/Inspector/mul.lproj/NothingInspector.xcstrings diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index d8dc56c2a..69f46f647 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -650,7 +650,7 @@ let appName = "NetNewsWire" @IBAction func toggleInspectorWindow(_ sender: Any?) { if inspectorWindowController == nil { - inspectorWindowController = (windowControllerWithName("Inspector") as! InspectorWindowController) + inspectorWindowController = InspectorWindowController() } if inspectorWindowController!.isOpen { diff --git a/Mac/Inspector/Base.lproj/BuiltinSmartFeedInspector.xib b/Mac/Inspector/Base.lproj/BuiltinSmartFeedInspector.xib new file mode 100644 index 000000000..e06751ff6 --- /dev/null +++ b/Mac/Inspector/Base.lproj/BuiltinSmartFeedInspector.xib @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mac/Inspector/Base.lproj/FeedInspector.xib b/Mac/Inspector/Base.lproj/FeedInspector.xib new file mode 100644 index 000000000..80f6af24c --- /dev/null +++ b/Mac/Inspector/Base.lproj/FeedInspector.xib @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mac/Inspector/Base.lproj/FolderInspector.xib b/Mac/Inspector/Base.lproj/FolderInspector.xib new file mode 100644 index 000000000..3d347329f --- /dev/null +++ b/Mac/Inspector/Base.lproj/FolderInspector.xib @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mac/Inspector/Base.lproj/InspectorWindow.xib b/Mac/Inspector/Base.lproj/InspectorWindow.xib new file mode 100644 index 000000000..7dc4a24a5 --- /dev/null +++ b/Mac/Inspector/Base.lproj/InspectorWindow.xib @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mac/Inspector/Base.lproj/NothingInspector.xib b/Mac/Inspector/Base.lproj/NothingInspector.xib new file mode 100644 index 000000000..10fe258eb --- /dev/null +++ b/Mac/Inspector/Base.lproj/NothingInspector.xib @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift b/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift index 71d3a9243..76bcc4cbd 100644 --- a/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift +++ b/Mac/Inspector/BuiltinSmartFeedInspectorViewController.swift @@ -39,6 +39,10 @@ final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector // MARK: NSViewController + convenience init() { + self.init(nibName: "BuiltinSmartFeedInspector", bundle: nil) + } + override func viewDidLoad() { updateUI() diff --git a/Mac/Inspector/FeedInspectorViewController.swift b/Mac/Inspector/FeedInspectorViewController.swift index fa029b6df..62f1f2ac0 100644 --- a/Mac/Inspector/FeedInspectorViewController.swift +++ b/Mac/Inspector/FeedInspectorViewController.swift @@ -48,6 +48,10 @@ final class FeedInspectorViewController: NSViewController, Inspector { // MARK: NSViewController + convenience init() { + self.init(nibName: "FeedInspector", bundle: nil) + } + override func viewDidLoad() { updateUI() NotificationCenter.default.addObserver(self, selector: #selector(imageDidBecomeAvailable(_:)), name: .imageDidBecomeAvailable, object: nil) diff --git a/Mac/Inspector/FolderInspectorViewController.swift b/Mac/Inspector/FolderInspectorViewController.swift index d7d50bbd9..653935f8e 100644 --- a/Mac/Inspector/FolderInspectorViewController.swift +++ b/Mac/Inspector/FolderInspectorViewController.swift @@ -43,6 +43,10 @@ final class FolderInspectorViewController: NSViewController, Inspector { // MARK: NSViewController + convenience init() { + self.init(nibName: "FolderInspector", bundle: nil) + } + override func viewDidLoad() { updateUI() diff --git a/Mac/Inspector/Inspector.storyboard b/Mac/Inspector/Inspector.storyboard deleted file mode 100644 index 8fc55778c..000000000 --- a/Mac/Inspector/Inspector.storyboard +++ /dev/null @@ -1,300 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Feed -Name -Field - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Folder -Name -Field - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Mac/Inspector/InspectorWindowController.swift b/Mac/Inspector/InspectorWindowController.swift index 1ebbd6fa0..b73eeb500 100644 --- a/Mac/Inspector/InspectorWindowController.swift +++ b/Mac/Inspector/InspectorWindowController.swift @@ -49,16 +49,14 @@ final class InspectorWindowController: NSWindowController { static let windowOrigin = "FloatingInspectorOrigin" } + convenience init() { + self.init(windowNibName: "InspectorWindow") + } + override func windowDidLoad() { - let nothingInspector = window?.contentViewController as! InspectorViewController - - let storyboard = NSStoryboard(name: NSStoryboard.Name("Inspector"), bundle: nil) - let feedInspector = inspector("Feed", storyboard) - let folderInspector = inspector("Folder", storyboard) - let builtinSmartFeedInspector = inspector("BuiltinSmartFeed", storyboard) - - inspectors = [feedInspector, folderInspector, builtinSmartFeedInspector, nothingInspector] + let nothingInspector = NothingInspectorViewController() + inspectors = [FeedInspectorViewController(), FolderInspectorViewController(), BuiltinSmartFeedInspectorViewController(), nothingInspector] currentInspector = nothingInspector window?.title = currentInspector.windowTitle @@ -95,11 +93,6 @@ final class InspectorWindowController: NSWindowController { private extension InspectorWindowController { - func inspector(_ identifier: String, _ storyboard: NSStoryboard) -> InspectorViewController { - - return storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(identifier)) as! InspectorViewController - } - func show(_ inspector: InspectorViewController) { guard let window = window else { diff --git a/Mac/Inspector/NothingInspectorViewController.swift b/Mac/Inspector/NothingInspectorViewController.swift index f23ad9b64..836515757 100644 --- a/Mac/Inspector/NothingInspectorViewController.swift +++ b/Mac/Inspector/NothingInspectorViewController.swift @@ -26,6 +26,10 @@ final class NothingInspectorViewController: NSViewController, Inspector { return true } + convenience init() { + self.init(nibName: "NothingInspector", bundle: nil) + } + override func viewDidLoad() { updateTextFields() diff --git a/Mac/Inspector/mul.lproj/FeedInspector.xcstrings b/Mac/Inspector/mul.lproj/FeedInspector.xcstrings new file mode 100644 index 000000000..17b9bb316 --- /dev/null +++ b/Mac/Inspector/mul.lproj/FeedInspector.xcstrings @@ -0,0 +1,78 @@ +{ + "sourceLanguage" : "en", + "strings" : { + "aRe-yV-R0h.title" : { + "comment" : "Class = \"NSButtonCell\"; title = \"Always use Reader view\"; ObjectID = \"aRe-yV-R0h\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Always use Reader view" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Usar siempre la vista de lector" + } + } + } + }, + "Bw5-c7-yDX.title" : { + "comment" : "Class = \"NSButtonCell\"; title = \"Show notifications for new articles\"; ObjectID = \"Bw5-c7-yDX\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Show notifications for new articles" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Mostrar notificaciones de artículos nuevos" + } + } + } + }, + "Fg8-rA-G5J.title" : { + "comment" : "Class = \"NSTextFieldCell\"; title = \"Home Page\"; ObjectID = \"Fg8-rA-G5J\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Home Page" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Página de inicio" + } + } + } + }, + "zzB-rX-1dK.title" : { + "comment" : "Class = \"NSTextFieldCell\"; title = \"Feed\"; ObjectID = \"zzB-rX-1dK\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Feed" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Fuente" + } + } + } + } + }, + "version" : "1.2" +} diff --git a/Mac/Inspector/mul.lproj/NothingInspector.xcstrings b/Mac/Inspector/mul.lproj/NothingInspector.xcstrings new file mode 100644 index 000000000..806ee63fd --- /dev/null +++ b/Mac/Inspector/mul.lproj/NothingInspector.xcstrings @@ -0,0 +1,42 @@ +{ + "sourceLanguage" : "en", + "strings" : { + "5oG-0x-T8O.title" : { + "comment" : "Class = \"NSTextFieldCell\"; title = \"Multiple selection\"; ObjectID = \"5oG-0x-T8O\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Multiple selection" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Selección múltiple" + } + } + } + }, + "iLD-8q-EAJ.title" : { + "comment" : "Class = \"NSTextFieldCell\"; title = \"Nothing to inspect\"; ObjectID = \"iLD-8q-EAJ\";", + "extractionState" : "extracted_with_value", + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : "Nothing to inspect" + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nada que inspeccionar" + } + } + } + } + }, + "version" : "1.2" +}