Add windowTitle var to Inspector protocol

This commit is contained in:
Angelo Stavrow 2020-09-07 13:34:37 -04:00
parent ef63c18265
commit c7aa5656d8
No known key found for this signature in database
GPG Key ID: 1A49C7064E060EEE
5 changed files with 7 additions and 24 deletions

View File

@ -26,6 +26,7 @@ final class BuiltinSmartFeedInspectorViewController: NSViewController, Inspector
updateSmartFeed()
}
}
var windowTitle: String = NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {

View File

@ -30,6 +30,7 @@ final class FolderInspectorViewController: NSViewController, Inspector {
updateFolder()
}
}
var windowTitle: String = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {

View File

@ -12,6 +12,7 @@ protocol Inspector: class {
var objects: [Any]? { get set }
var isFallbackInspector: Bool { get } // Can handle nothing-to-inspect or unexpected type of objects.
var windowTitle: String { get }
func canInspect(_ objects: [Any]) -> Bool
}
@ -62,6 +63,7 @@ final class InspectorWindowController: NSWindowController {
inspectors = [feedInspector, folderInspector, builtinSmartFeedInspector, nothingInspector]
currentInspector = nothingInspector
window?.title = currentInspector.windowTitle
if let savedOrigin = originFromDefaults() {
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
@ -109,30 +111,7 @@ private extension InspectorWindowController {
return
}
switch inspector {
case is NothingInspectorViewController:
window.title = NSLocalizedString("Inspector", comment: "Inspector window title")
case is FolderInspectorViewController:
if let folderName = (inspector as? FolderInspectorViewController)?.nameTextField?.stringValue {
window.title = folderName
} else {
window.title = NSLocalizedString("Folder Inspector", comment: "Folder Inspector window title")
}
case is WebFeedInspectorViewController:
if let feedName = (inspector as? WebFeedInspectorViewController)?.nameTextField?.stringValue {
window.title = feedName
} else {
window.title = NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
}
case is BuiltinSmartFeedInspectorViewController:
if let smartFeedName = (inspector as? BuiltinSmartFeedInspectorViewController)?.nameTextField?.stringValue {
window.title = smartFeedName
} else {
window.title = NSLocalizedString("Smart Feed Inspector", comment: "Smart Feed Inspector window title")
}
default:
window.title = NSLocalizedString("Inspector", comment: "Inspector window title")
}
window.title = inspector.windowTitle
let flippedOrigin = window.flippedOrigin

View File

@ -19,6 +19,7 @@ final class NothingInspectorViewController: NSViewController, Inspector {
updateTextFields()
}
}
var windowTitle: String = NSLocalizedString("Inspector", comment: "Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {

View File

@ -38,6 +38,7 @@ final class WebFeedInspectorViewController: NSViewController, Inspector {
updateFeed()
}
}
var windowTitle: String = NSLocalizedString("Feed Inspector", comment: "Feed Inspector window title")
func canInspect(_ objects: [Any]) -> Bool {
return objects.count == 1 && objects.first is WebFeed