Fix lint issues.
This commit is contained in:
parent
8f1379360c
commit
40ada2ba5a
@ -105,8 +105,7 @@ final class AppDefaults {
|
|||||||
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String,
|
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String,
|
||||||
let appGroupDefaults = UserDefaults(suiteName: appGroupID) {
|
let appGroupDefaults = UserDefaults(suiteName: appGroupID) {
|
||||||
return appGroupDefaults
|
return appGroupDefaults
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return UserDefaults.standard
|
return UserDefaults.standard
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -427,8 +426,7 @@ private extension AppDefaults {
|
|||||||
static func setSortDirection(for key: String, _ value: ComparisonResult) {
|
static func setSortDirection(for key: String, _ value: ComparisonResult) {
|
||||||
if value == .orderedAscending {
|
if value == .orderedAscending {
|
||||||
setInt(for: key, ComparisonResult.orderedAscending.rawValue)
|
setInt(for: key, ComparisonResult.orderedAscending.rawValue)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
setInt(for: key, ComparisonResult.orderedDescending.rawValue)
|
setInt(for: key, ComparisonResult.orderedDescending.rawValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,7 @@ import Sparkle
|
|||||||
var appDelegate: AppDelegate!
|
var appDelegate: AppDelegate!
|
||||||
|
|
||||||
@NSApplicationMain
|
@NSApplicationMain
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate
|
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate {
|
||||||
{
|
|
||||||
|
|
||||||
private struct WindowRestorationIdentifiers {
|
private struct WindowRestorationIdentifiers {
|
||||||
static let mainWindow = "mainWindow"
|
static let mainWindow = "mainWindow"
|
||||||
@ -139,8 +138,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
let cacheFolder: String
|
let cacheFolder: String
|
||||||
if let userCacheFolder = try? FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: false).path {
|
if let userCacheFolder = try? FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: false).path {
|
||||||
cacheFolder = userCacheFolder
|
cacheFolder = userCacheFolder
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let bundleIdentifier = (Bundle.main.infoDictionary!["CFBundleIdentifier"]! as! String)
|
let bundleIdentifier = (Bundle.main.infoDictionary!["CFBundleIdentifier"]! as! String)
|
||||||
cacheFolder = (NSTemporaryDirectory() as NSString).appendingPathComponent(bundleIdentifier)
|
cacheFolder = (NSTemporaryDirectory() as NSString).appendingPathComponent(bundleIdentifier)
|
||||||
}
|
}
|
||||||
@ -166,8 +164,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
|
|
||||||
do {
|
do {
|
||||||
try self.softwareUpdater.start()
|
try self.softwareUpdater.start()
|
||||||
}
|
} catch {
|
||||||
catch {
|
|
||||||
NSLog("Failed to start software updater with error: \(error)")
|
NSLog("Failed to start software updater with error: \(error)")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +211,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
refreshTimer = AccountRefreshTimer()
|
refreshTimer = AccountRefreshTimer()
|
||||||
syncTimer = ArticleStatusSyncTimer()
|
syncTimer = ArticleStatusSyncTimer()
|
||||||
|
|
||||||
UNUserNotificationCenter.current().requestAuthorization(options:[.badge]) { (granted, error) in }
|
UNUserNotificationCenter.current().requestAuthorization(options: [.badge]) { (_, _) in }
|
||||||
|
|
||||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||||
if settings.authorizationStatus == .authorized {
|
if settings.authorizationStatus == .authorized {
|
||||||
@ -298,7 +295,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
|
|
||||||
ArticleThemeDownloader.shared.cleanUp()
|
ArticleThemeDownloader.shared.cleanUp()
|
||||||
|
|
||||||
AccountManager.shared.sendArticleStatusAll() {
|
AccountManager.shared.sendArticleStatusAll {
|
||||||
self.isShutDownSyncDone = true
|
self.isShutDownSyncDone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,7 +315,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if key == Feed.FeedSettingKey.homePageURL || key == Feed.FeedSettingKey.faviconURL {
|
if key == Feed.FeedSettingKey.homePageURL || key == Feed.FeedSettingKey.faviconURL {
|
||||||
let _ = faviconDownloader.favicon(for: feed)
|
_ = faviconDownloader.favicon(for: feed)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,8 +527,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
|
|
||||||
if inspectorWindowController!.isOpen {
|
if inspectorWindowController!.isOpen {
|
||||||
inspectorWindowController!.window!.performClose(self)
|
inspectorWindowController!.window!.performClose(self)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
inspectorWindowController!.objects = objectsForInspector()
|
inspectorWindowController!.objects = objectsForInspector()
|
||||||
inspectorWindowController!.showWindow(self)
|
inspectorWindowController!.showWindow(self)
|
||||||
}
|
}
|
||||||
@ -581,7 +577,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
|||||||
Browser.open(URL.releaseNotes.absoluteString, inBackground: false)
|
Browser.open(URL.releaseNotes.absoluteString, inBackground: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@IBAction func openHowToSupport(_ sender: Any?) {
|
@IBAction func openHowToSupport(_ sender: Any?) {
|
||||||
|
|
||||||
Browser.open("https://github.com/brentsimmons/NetNewsWire/blob/main/Technotes/HowToSupportNetNewsWire.markdown", inBackground: false)
|
Browser.open("https://github.com/brentsimmons/NetNewsWire/blob/main/Technotes/HowToSupportNetNewsWire.markdown", inBackground: false)
|
||||||
@ -918,7 +913,7 @@ extension AppDelegate : ScriptingAppDelegate {
|
|||||||
extension AppDelegate: NSWindowRestoration {
|
extension AppDelegate: NSWindowRestoration {
|
||||||
|
|
||||||
@objc static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void) {
|
@objc static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void) {
|
||||||
var mainWindow: NSWindow? = nil
|
var mainWindow: NSWindow?
|
||||||
if identifier.rawValue == WindowRestorationIdentifiers.mainWindow {
|
if identifier.rawValue == WindowRestorationIdentifiers.mainWindow {
|
||||||
mainWindow = appDelegate.createAndShowMainWindow().window
|
mainWindow = appDelegate.createAndShowMainWindow().window
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ struct Browser {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Opens a URL in the default browser.
|
/// Opens a URL in the default browser.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@ -34,7 +33,6 @@ struct Browser {
|
|||||||
open(urlString, inBackground: invert ? !AppDefaults.shared.openInBrowserInBackground : AppDefaults.shared.openInBrowserInBackground)
|
open(urlString, inBackground: invert ? !AppDefaults.shared.openInBrowserInBackground : AppDefaults.shared.openInBrowserInBackground)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Opens a URL in the default browser.
|
/// Opens a URL in the default browser.
|
||||||
///
|
///
|
||||||
/// - Parameters:
|
/// - Parameters:
|
||||||
@ -52,7 +50,7 @@ struct Browser {
|
|||||||
configuration.activates = false
|
configuration.activates = false
|
||||||
}
|
}
|
||||||
|
|
||||||
NSWorkspace.shared.open(preparedURL, configuration: configuration) { (runningApplication, error) in
|
NSWorkspace.shared.open(preparedURL, configuration: configuration) { (_, error) in
|
||||||
guard error != nil else { return }
|
guard error != nil else { return }
|
||||||
if let defaultBrowser = defaultBrowser {
|
if let defaultBrowser = defaultBrowser {
|
||||||
defaultBrowser.openURL(url, inBackground: inBackground)
|
defaultBrowser.openURL(url, inBackground: inBackground)
|
||||||
|
@ -59,4 +59,3 @@ final class CrashReportWindowController: NSWindowController {
|
|||||||
close()
|
close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
|||||||
self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
|
||||||
self.updateNotificationSettings()
|
self.updateNotificationSettings()
|
||||||
if granted {
|
if granted {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
@ -130,7 +130,6 @@ private extension FeedInspectorViewController {
|
|||||||
feed = singleFeed
|
feed = singleFeed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@objc func updateUI() {
|
@objc func updateUI() {
|
||||||
updateImage()
|
updateImage()
|
||||||
updateName()
|
updateName()
|
||||||
|
@ -19,7 +19,6 @@ protocol Inspector: AnyObject {
|
|||||||
|
|
||||||
typealias InspectorViewController = Inspector & NSViewController
|
typealias InspectorViewController = Inspector & NSViewController
|
||||||
|
|
||||||
|
|
||||||
final class InspectorWindowController: NSWindowController {
|
final class InspectorWindowController: NSWindowController {
|
||||||
|
|
||||||
class var shouldOpenAtStartup: Bool {
|
class var shouldOpenAtStartup: Bool {
|
||||||
@ -28,7 +27,7 @@ final class InspectorWindowController: NSWindowController {
|
|||||||
|
|
||||||
var objects: [Any]? {
|
var objects: [Any]? {
|
||||||
didSet {
|
didSet {
|
||||||
let _ = window
|
_ = window
|
||||||
currentInspector = inspector(for: objects)
|
currentInspector = inspector(for: objects)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,21 +66,19 @@ final class InspectorWindowController: NSWindowController {
|
|||||||
|
|
||||||
if let savedOrigin = originFromDefaults() {
|
if let savedOrigin = originFromDefaults() {
|
||||||
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
|
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
window?.flippedOrigin = NSPoint(x: 256, y: 256)
|
window?.flippedOrigin = NSPoint(x: 256, y: 256)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func inspector(for objects: [Any]?) -> InspectorViewController {
|
func inspector(for objects: [Any]?) -> InspectorViewController {
|
||||||
|
|
||||||
var fallbackInspector: InspectorViewController? = nil
|
var fallbackInspector: InspectorViewController?
|
||||||
|
|
||||||
for inspector in inspectors {
|
for inspector in inspectors {
|
||||||
if inspector.isFallbackInspector {
|
if inspector.isFallbackInspector {
|
||||||
fallbackInspector = inspector
|
fallbackInspector = inspector
|
||||||
}
|
} else if let objects = objects, inspector.canInspect(objects) {
|
||||||
else if let objects = objects, inspector.canInspect(objects) {
|
|
||||||
return inspector
|
return inspector
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,7 @@ private extension NothingInspectorViewController {
|
|||||||
if let objects = objects, objects.count > 1 {
|
if let objects = objects, objects.count > 1 {
|
||||||
nothingTextField?.isHidden = true
|
nothingTextField?.isHidden = true
|
||||||
multipleTextField?.isHidden = false
|
multipleTextField?.isHidden = false
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
nothingTextField?.isHidden = false
|
nothingTextField?.isHidden = false
|
||||||
multipleTextField?.isHidden = true
|
multipleTextField?.isHidden = true
|
||||||
}
|
}
|
||||||
|
@ -165,4 +165,3 @@ private extension AddFeedController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ final class AddFeedWindowController : NSWindowController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||||
hostWindow.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
|
hostWindow.beginSheet(window!) { (_: NSApplication.ModalResponse) in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ final class AddFeedWindowController : NSWindowController {
|
|||||||
|
|
||||||
if normalizedURLString.isEmpty {
|
if normalizedURLString.isEmpty {
|
||||||
cancelSheet()
|
cancelSheet()
|
||||||
return;
|
return
|
||||||
}
|
}
|
||||||
guard let url = URL(string: normalizedURLString) else {
|
guard let url = URL(string: normalizedURLString) else {
|
||||||
cancelSheet()
|
cancelSheet()
|
||||||
|
@ -25,7 +25,7 @@ class AddFolderWindowController : NSWindowController {
|
|||||||
|
|
||||||
func runSheetOnWindow(_ w: NSWindow) {
|
func runSheetOnWindow(_ w: NSWindow) {
|
||||||
hostWindow = w
|
hostWindow = w
|
||||||
hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
|
hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) in
|
||||||
|
|
||||||
if returnCode == NSApplication.ModalResponse.OK {
|
if returnCode == NSApplication.ModalResponse.OK {
|
||||||
self.addFolderIfNeeded()
|
self.addFolderIfNeeded()
|
||||||
|
@ -38,7 +38,7 @@ final class DetailContainerView: NSView {
|
|||||||
|
|
||||||
override func draw(_ dirtyRect: NSRect) {
|
override func draw(_ dirtyRect: NSRect) {
|
||||||
NSColor.controlBackgroundColor.set()
|
NSColor.controlBackgroundColor.set()
|
||||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
let r = dirtyRect.intersection(bounds)
|
||||||
r.fill()
|
r.fill()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,7 @@ final class DetailStatusBarView: NSView {
|
|||||||
if let link = linkForDisplay {
|
if let link = linkForDisplay {
|
||||||
urlLabel.stringValue = link
|
urlLabel.stringValue = link
|
||||||
self.isHidden = false
|
self.isHidden = false
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
urlLabel.stringValue = ""
|
urlLabel.stringValue = ""
|
||||||
self.isHidden = true
|
self.isHidden = true
|
||||||
}
|
}
|
||||||
@ -68,11 +67,8 @@ private extension DetailStatusBarView {
|
|||||||
func updateLinkForDisplay() {
|
func updateLinkForDisplay() {
|
||||||
if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty {
|
if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty {
|
||||||
linkForDisplay = mouseoverLink.strippingHTTPOrHTTPSScheme
|
linkForDisplay = mouseoverLink.strippingHTTPOrHTTPSScheme
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
linkForDisplay = nil
|
linkForDisplay = nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ final class DetailWebView: WKWebView {
|
|||||||
|
|
||||||
override func setFrameSize(_ newSize: NSSize) {
|
override func setFrameSize(_ newSize: NSSize) {
|
||||||
super.setFrameSize(newSize)
|
super.setFrameSize(newSize)
|
||||||
if (!inLiveResize) {
|
if !inLiveResize {
|
||||||
bigSurOffsetFix()
|
bigSurOffsetFix()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,4 +128,3 @@ private extension DetailWebView {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ final class DetailWebViewController: NSViewController {
|
|||||||
|
|
||||||
private var isShowingExtractedArticle: Bool {
|
private var isShowingExtractedArticle: Bool {
|
||||||
switch state {
|
switch state {
|
||||||
case .extracted(_, _, _):
|
case .extracted:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
@ -281,7 +281,7 @@ private extension DetailWebViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func reloadHTMLMaintainingScrollPosition() {
|
func reloadHTMLMaintainingScrollPosition() {
|
||||||
fetchScrollInfo() { scrollInfo in
|
fetchScrollInfo { scrollInfo in
|
||||||
self.windowScrollY = scrollInfo?.offsetY
|
self.windowScrollY = scrollInfo?.offsetY
|
||||||
self.reloadHTML()
|
self.reloadHTML()
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ private extension DetailWebViewController {
|
|||||||
func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) {
|
func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) {
|
||||||
let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x"
|
let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x"
|
||||||
|
|
||||||
webView.evaluateJavaScript(javascriptString) { (info, error) in
|
webView.evaluateJavaScript(javascriptString) { (info, _) in
|
||||||
guard let info = info as? [String: Any] else {
|
guard let info = info as? [String: Any] else {
|
||||||
completion(nil)
|
completion(nil)
|
||||||
return
|
return
|
||||||
|
@ -10,7 +10,7 @@ import AppKit
|
|||||||
|
|
||||||
final class IconView: NSView {
|
final class IconView: NSView {
|
||||||
|
|
||||||
var iconImage: IconImage? = nil {
|
var iconImage: IconImage? {
|
||||||
didSet {
|
didSet {
|
||||||
if iconImage !== oldValue {
|
if iconImage !== oldValue {
|
||||||
imageView.image = iconImage?.image
|
imageView.image = iconImage?.image
|
||||||
@ -76,7 +76,7 @@ final class IconView: NSView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func layout() {
|
override func layout() {
|
||||||
resizeSubviews(withOldSize: NSZeroSize)
|
resizeSubviews(withOldSize: NSSize.zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||||
@ -89,7 +89,7 @@ final class IconView: NSView {
|
|||||||
|
|
||||||
let color = NSApplication.shared.effectiveAppearance.isDarkMode ? IconView.darkBackgroundColor : IconView.lightBackgroundColor
|
let color = NSApplication.shared.effectiveAppearance.isDarkMode ? IconView.darkBackgroundColor : IconView.lightBackgroundColor
|
||||||
color.set()
|
color.set()
|
||||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
let r = dirtyRect.intersection(bounds)
|
||||||
r.fill()
|
r.fill()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ private extension IconView {
|
|||||||
|
|
||||||
func rectForImageView() -> NSRect {
|
func rectForImageView() -> NSRect {
|
||||||
guard !(iconImage?.isSymbol ?? false) else {
|
guard !(iconImage?.isSymbol ?? false) else {
|
||||||
return NSMakeRect(0.0, 0.0, bounds.size.width, bounds.size.height)
|
return NSRect(x: 0.0, y: 0.0, width: bounds.size.width, height: bounds.size.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
guard let image = iconImage?.image else {
|
guard let image = iconImage?.image else {
|
||||||
@ -116,22 +116,21 @@ private extension IconView {
|
|||||||
if imageSize.height == imageSize.width {
|
if imageSize.height == imageSize.width {
|
||||||
if imageSize.height >= viewSize.height * 0.75 {
|
if imageSize.height >= viewSize.height * 0.75 {
|
||||||
// Close enough to viewSize to scale up the image.
|
// Close enough to viewSize to scale up the image.
|
||||||
return NSMakeRect(0.0, 0.0, viewSize.width, viewSize.height)
|
return NSRect(x: 0.0, y: 0.0, width: viewSize.width, height: viewSize.height)
|
||||||
}
|
}
|
||||||
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
||||||
return NSMakeRect(offset, offset, imageSize.width, imageSize.height)
|
return NSRect(x: offset, y: offset, width: imageSize.width, height: imageSize.height)
|
||||||
}
|
} else if imageSize.height > imageSize.width {
|
||||||
else if imageSize.height > imageSize.width {
|
|
||||||
let factor = viewSize.height / imageSize.height
|
let factor = viewSize.height / imageSize.height
|
||||||
let width = imageSize.width * factor
|
let width = imageSize.width * factor
|
||||||
let originX = floor((viewSize.width - width) / 2.0)
|
let originX = floor((viewSize.width - width) / 2.0)
|
||||||
return NSMakeRect(originX, 0.0, width, viewSize.height)
|
return NSRect(x: originX, y: 0.0, width: width, height: viewSize.height)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wider than tall: imageSize.width > imageSize.height
|
// Wider than tall: imageSize.width > imageSize.height
|
||||||
let factor = viewSize.width / imageSize.width
|
let factor = viewSize.width / imageSize.width
|
||||||
let height = imageSize.height * factor
|
let height = imageSize.height * factor
|
||||||
let originY = floor((viewSize.height - height) / 2.0)
|
let originY = floor((viewSize.height - height) / 2.0)
|
||||||
return NSMakeRect(0.0, originY, viewSize.width, height)
|
return NSRect(x: 0.0, y: originY, width: viewSize.width, height: height)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,4 +33,3 @@ final class MainWindowKeyboardHandler: KeyboardDelegate {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
private var activityManager = ActivityManager()
|
private var activityManager = ActivityManager()
|
||||||
|
|
||||||
private var isShowingExtractedArticle = false
|
private var isShowingExtractedArticle = false
|
||||||
private var articleExtractor: ArticleExtractor? = nil
|
private var articleExtractor: ArticleExtractor?
|
||||||
private var sharingServicePickerDelegate: NSSharingServicePickerDelegate?
|
private var sharingServicePickerDelegate: NSSharingServicePickerDelegate?
|
||||||
|
|
||||||
private let windowAutosaveName = NSWindow.FrameAutosaveName("MainWindow")
|
private let windowAutosaveName = NSWindow.FrameAutosaveName("MainWindow")
|
||||||
@ -45,17 +45,17 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
private var sidebarViewController: SidebarViewController?
|
private var sidebarViewController: SidebarViewController?
|
||||||
private var timelineContainerViewController: TimelineContainerViewController?
|
private var timelineContainerViewController: TimelineContainerViewController?
|
||||||
private var detailViewController: DetailViewController?
|
private var detailViewController: DetailViewController?
|
||||||
private var currentSearchField: NSSearchField? = nil
|
private var currentSearchField: NSSearchField?
|
||||||
private let articleThemeMenuToolbarItem = NSMenuToolbarItem(itemIdentifier: .articleThemeMenu)
|
private let articleThemeMenuToolbarItem = NSMenuToolbarItem(itemIdentifier: .articleThemeMenu)
|
||||||
private var searchString: String? = nil
|
private var searchString: String?
|
||||||
private var lastSentSearchString: String? = nil
|
private var lastSentSearchString: String?
|
||||||
private var timelineSourceMode: TimelineSourceMode = .regular {
|
private var timelineSourceMode: TimelineSourceMode = .regular {
|
||||||
didSet {
|
didSet {
|
||||||
timelineContainerViewController?.showTimeline(for: timelineSourceMode)
|
timelineContainerViewController?.showTimeline(for: timelineSourceMode)
|
||||||
detailViewController?.showDetail(for: timelineSourceMode)
|
detailViewController?.showDetail(for: timelineSourceMode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private var searchSmartFeed: SmartFeed? = nil
|
private var searchSmartFeed: SmartFeed?
|
||||||
private var restoreArticleWindowScrollY: CGFloat?
|
private var restoreArticleWindowScrollY: CGFloat?
|
||||||
|
|
||||||
// MARK: - NSWindowController
|
// MARK: - NSWindowController
|
||||||
@ -283,7 +283,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
detailViewController.canScrollUp { (canScroll) in
|
detailViewController.canScrollUp { (canScroll) in
|
||||||
if (canScroll) {
|
if canScroll {
|
||||||
NSCursor.setHiddenUntilMouseMoves(true)
|
NSCursor.setHiddenUntilMouseMoves(true)
|
||||||
detailViewController.scrollPageUp(sender)
|
detailViewController.scrollPageUp(sender)
|
||||||
}
|
}
|
||||||
@ -340,8 +340,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
// TODO: handle search mode
|
// TODO: handle search mode
|
||||||
if timelineViewController.canGoToNextUnread(wrappingToTop: false) {
|
if timelineViewController.canGoToNextUnread(wrappingToTop: false) {
|
||||||
goToNextUnreadInTimeline(wrappingToTop: false)
|
goToNextUnreadInTimeline(wrappingToTop: false)
|
||||||
}
|
} else if sidebarViewController.canGoToNextUnread(wrappingToTop: true) {
|
||||||
else if sidebarViewController.canGoToNextUnread(wrappingToTop: true) {
|
|
||||||
sidebarViewController.goToNextUnread(wrappingToTop: true)
|
sidebarViewController.goToNextUnread(wrappingToTop: true)
|
||||||
|
|
||||||
// If we ended up on the same timelineViewController, we may need to wrap
|
// If we ended up on the same timelineViewController, we may need to wrap
|
||||||
@ -414,7 +413,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) {
|
@IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) {
|
||||||
currentTimelineViewController?.markAllAsRead() {
|
currentTimelineViewController?.markAllAsRead {
|
||||||
self.nextUnread(sender)
|
self.nextUnread(sender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1322,4 +1321,3 @@ private extension MainWindowController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,4 +141,3 @@ extension NNW3Feed: OPMLRepresentable {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,7 @@ class ExportOPMLWindowController: NSWindowController {
|
|||||||
let opmlString = OPMLExporter.OPMLString(with: account, title: filename)
|
let opmlString = OPMLExporter.OPMLString(with: account, title: filename)
|
||||||
do {
|
do {
|
||||||
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
||||||
}
|
} catch let error as NSError {
|
||||||
catch let error as NSError {
|
|
||||||
NSApplication.shared.presentError(error)
|
NSApplication.shared.presentError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,4 +105,3 @@ class ImportOPMLWindowController: NSWindowController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class SidebarCell : NSTableCellView {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
private let faviconImageView = IconView()
|
private let faviconImageView = IconView()
|
||||||
private let unreadCountView = UnreadCountView(frame: NSZeroRect)
|
private let unreadCountView = UnreadCountView(frame: NSRect.zero)
|
||||||
|
|
||||||
override var backgroundStyle: NSView.BackgroundStyle {
|
override var backgroundStyle: NSView.BackgroundStyle {
|
||||||
didSet {
|
didSet {
|
||||||
@ -99,7 +99,7 @@ class SidebarCell : NSTableCellView {
|
|||||||
if let cellAppearance = cellAppearance {
|
if let cellAppearance = cellAppearance {
|
||||||
titleView.font = cellAppearance.textFieldFont
|
titleView.font = cellAppearance.textFieldFont
|
||||||
}
|
}
|
||||||
resizeSubviews(withOldSize: NSZeroSize)
|
resizeSubviews(withOldSize: NSSize.zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||||
@ -165,4 +165,3 @@ private extension SidebarCell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,4 +32,3 @@ struct SidebarCellAppearance: Equatable {
|
|||||||
self.textFieldFont = NSFont.systemFont(ofSize: textFieldFontSize)
|
self.textFieldFont = NSFont.systemFont(ofSize: textFieldFontSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ struct SidebarCellLayout {
|
|||||||
|
|
||||||
var rTextField = NSRect(x: 0.0, y: 0.0, width: textFieldSize.width, height: textFieldSize.height)
|
var rTextField = NSRect(x: 0.0, y: 0.0, width: textFieldSize.width, height: textFieldSize.height)
|
||||||
if shouldShowImage {
|
if shouldShowImage {
|
||||||
rTextField.origin.x = NSMaxX(rFavicon) + appearance.imageMarginRight
|
rTextField.origin.x = rFavicon.maxX + appearance.imageMarginRight
|
||||||
}
|
}
|
||||||
rTextField = rTextField.centeredVertically(in: bounds)
|
rTextField = rTextField.centeredVertically(in: bounds)
|
||||||
|
|
||||||
@ -42,17 +42,17 @@ struct SidebarCellLayout {
|
|||||||
var rUnread = NSRect.zero
|
var rUnread = NSRect.zero
|
||||||
if !unreadCountIsHidden {
|
if !unreadCountIsHidden {
|
||||||
rUnread.size = unreadCountSize
|
rUnread.size = unreadCountSize
|
||||||
rUnread.origin.x = NSMaxX(bounds) - unreadCountSize.width
|
rUnread.origin.x = bounds.maxX - unreadCountSize.width
|
||||||
rUnread = rUnread.centeredVertically(in: bounds)
|
rUnread = rUnread.centeredVertically(in: bounds)
|
||||||
let textFieldMaxX = NSMinX(rUnread) - appearance.unreadCountMarginLeft
|
let textFieldMaxX = rUnread.minX - appearance.unreadCountMarginLeft
|
||||||
if NSMaxX(rTextField) > textFieldMaxX {
|
if rTextField.maxX > textFieldMaxX {
|
||||||
rTextField.size.width = textFieldMaxX - NSMinX(rTextField)
|
rTextField.size.width = textFieldMaxX - rTextField.minX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.unreadCountRect = rUnread
|
self.unreadCountRect = rUnread
|
||||||
|
|
||||||
if NSMaxX(rTextField) > NSMaxX(bounds) {
|
if rTextField.maxX > bounds.maxX {
|
||||||
rTextField.size.width = NSMaxX(bounds) - NSMinX(rTextField)
|
rTextField.size.width = bounds.maxX - rTextField.minX
|
||||||
}
|
}
|
||||||
self.titleRect = rTextField
|
self.titleRect = rTextField
|
||||||
}
|
}
|
||||||
|
@ -39,4 +39,3 @@ import RSCore
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ struct PasteboardFeed: Hashable {
|
|||||||
let feedID = dictionary[Key.feedID]
|
let feedID = dictionary[Key.feedID]
|
||||||
let editedName = dictionary[Key.editedName]
|
let editedName = dictionary[Key.editedName]
|
||||||
|
|
||||||
var accountType: AccountType? = nil
|
var accountType: AccountType?
|
||||||
if let accountTypeString = dictionary[Key.accountType], let accountTypeInt = Int(accountTypeString) {
|
if let accountTypeString = dictionary[Key.accountType], let accountTypeInt = Int(accountTypeString) {
|
||||||
accountType = AccountType(rawValue: accountTypeInt)
|
accountType = AccountType(rawValue: accountTypeInt)
|
||||||
}
|
}
|
||||||
@ -72,8 +72,7 @@ struct PasteboardFeed: Hashable {
|
|||||||
var pasteboardType: NSPasteboard.PasteboardType?
|
var pasteboardType: NSPasteboard.PasteboardType?
|
||||||
if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIInternalType) {
|
if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIInternalType) {
|
||||||
pasteboardType = FeedPasteboardWriter.feedUTIInternalType
|
pasteboardType = FeedPasteboardWriter.feedUTIInternalType
|
||||||
}
|
} else if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIType) {
|
||||||
else if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIType) {
|
|
||||||
pasteboardType = FeedPasteboardWriter.feedUTIType
|
pasteboardType = FeedPasteboardWriter.feedUTIType
|
||||||
}
|
}
|
||||||
if let foundType = pasteboardType {
|
if let foundType = pasteboardType {
|
||||||
@ -87,8 +86,7 @@ struct PasteboardFeed: Hashable {
|
|||||||
// Check for URL or a string that may be a URL.
|
// Check for URL or a string that may be a URL.
|
||||||
if pasteboardItem.types.contains(.URL) {
|
if pasteboardItem.types.contains(.URL) {
|
||||||
pasteboardType = .URL
|
pasteboardType = .URL
|
||||||
}
|
} else if pasteboardItem.types.contains(.string) {
|
||||||
else if pasteboardItem.types.contains(.string) {
|
|
||||||
pasteboardType = .string
|
pasteboardType = .string
|
||||||
}
|
}
|
||||||
if let foundType = pasteboardType {
|
if let foundType = pasteboardType {
|
||||||
@ -161,7 +159,6 @@ extension Feed: @retroactive PasteboardWriterOwner {
|
|||||||
static let feedUTIInternal = "com.ranchero.NetNewsWire-Evergreen.internal.feed"
|
static let feedUTIInternal = "com.ranchero.NetNewsWire-Evergreen.internal.feed"
|
||||||
static let feedUTIInternalType = NSPasteboard.PasteboardType(rawValue: feedUTIInternal)
|
static let feedUTIInternalType = NSPasteboard.PasteboardType(rawValue: feedUTIInternal)
|
||||||
|
|
||||||
|
|
||||||
init(feed: Feed) {
|
init(feed: Feed) {
|
||||||
self.feed = feed
|
self.feed = feed
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,6 @@ struct PasteboardFolder: Hashable {
|
|||||||
static let accountID = "accountID"
|
static let accountID = "accountID"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let name: String
|
let name: String
|
||||||
let folderID: String?
|
let folderID: String?
|
||||||
let accountID: String?
|
let accountID: String?
|
||||||
|
@ -16,7 +16,7 @@ import Account
|
|||||||
|
|
||||||
let treeController: TreeController
|
let treeController: TreeController
|
||||||
static let dragOperationNone = NSDragOperation(rawValue: 0)
|
static let dragOperationNone = NSDragOperation(rawValue: 0)
|
||||||
private var draggedNodes: Set<Node>? = nil
|
private var draggedNodes: Set<Node>?
|
||||||
|
|
||||||
init(treeController: TreeController) {
|
init(treeController: TreeController) {
|
||||||
self.treeController = treeController
|
self.treeController = treeController
|
||||||
@ -159,8 +159,7 @@ private extension SidebarOutlineDataSource {
|
|||||||
for feed in draggedFeeds {
|
for feed in draggedFeeds {
|
||||||
if feed.isLocalFeed {
|
if feed.isLocalFeed {
|
||||||
hasLocalFeed = true
|
hasLocalFeed = true
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
hasNonLocalFeed = true
|
hasNonLocalFeed = true
|
||||||
}
|
}
|
||||||
if hasLocalFeed && hasNonLocalFeed {
|
if hasLocalFeed && hasNonLocalFeed {
|
||||||
|
@ -119,7 +119,7 @@ extension SidebarViewController {
|
|||||||
NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu))
|
NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
|
||||||
if granted {
|
if granted {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false }
|
if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false }
|
||||||
@ -362,4 +362,3 @@ private extension SidebarViewController {
|
|||||||
return articles
|
return articles
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,7 +354,6 @@ protocol SidebarDelegate: AnyObject {
|
|||||||
menu.takeItems(from: contextualMenu)
|
menu.takeItems(from: contextualMenu)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// MARK: - NSOutlineViewDelegate
|
// MARK: - NSOutlineViewDelegate
|
||||||
|
|
||||||
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
||||||
@ -563,7 +562,6 @@ private extension SidebarViewController {
|
|||||||
treeControllerDelegate.addFilterException(folderFeedID)
|
treeControllerDelegate.addFilterException(folderFeedID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func queueRebuildTreeAndRestoreSelection() {
|
func queueRebuildTreeAndRestoreSelection() {
|
||||||
rebuildTreeAndRestoreSelectionQueue.add(self, #selector(rebuildTreeAndRestoreSelection))
|
rebuildTreeAndRestoreSelectionQueue.add(self, #selector(rebuildTreeAndRestoreSelection))
|
||||||
}
|
}
|
||||||
@ -819,7 +817,7 @@ private extension SidebarViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func applyToAvailableCells(_ completion: (SidebarCell, Node) -> Void) {
|
func applyToAvailableCells(_ completion: (SidebarCell, Node) -> Void) {
|
||||||
outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) -> Void in
|
outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) in
|
||||||
guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else {
|
guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@ class UnreadCountView : NSView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var intrinsicContentSizeIsValid = false
|
private var intrinsicContentSizeIsValid = false
|
||||||
private var _intrinsicContentSize = NSZeroSize
|
private var _intrinsicContentSize = NSSize.zero
|
||||||
|
|
||||||
override var intrinsicContentSize: NSSize {
|
override var intrinsicContentSize: NSSize {
|
||||||
if !intrinsicContentSizeIsValid {
|
if !intrinsicContentSizeIsValid {
|
||||||
var size = NSZeroSize
|
var size = NSSize.zero
|
||||||
if unreadCount > 0 {
|
if unreadCount > 0 {
|
||||||
size = textSize()
|
size = textSize()
|
||||||
size.width += (Appearance.padding.left + Appearance.padding.right)
|
size.width += (Appearance.padding.left + Appearance.padding.right)
|
||||||
@ -59,7 +59,7 @@ class UnreadCountView : NSView {
|
|||||||
|
|
||||||
private func textSize() -> NSSize {
|
private func textSize() -> NSSize {
|
||||||
if unreadCount < 1 {
|
if unreadCount < 1 {
|
||||||
return NSZeroSize
|
return NSSize.zero
|
||||||
}
|
}
|
||||||
|
|
||||||
if let cachedSize = UnreadCountView.textSizeCache[unreadCount] {
|
if let cachedSize = UnreadCountView.textSizeCache[unreadCount] {
|
||||||
@ -76,9 +76,9 @@ class UnreadCountView : NSView {
|
|||||||
|
|
||||||
private func textRect() -> NSRect {
|
private func textRect() -> NSRect {
|
||||||
let size = textSize()
|
let size = textSize()
|
||||||
var r = NSZeroRect
|
var r = NSRect.zero
|
||||||
r.size = size
|
r.size = size
|
||||||
r.origin.x = (NSMaxX(bounds) - Appearance.padding.right) - r.size.width
|
r.origin.x = (bounds.maxX - Appearance.padding.right) - r.size.width
|
||||||
r.origin.y = Appearance.padding.top
|
r.origin.y = Appearance.padding.top
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@ -93,4 +93,3 @@ class UnreadCountView : NSView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +78,9 @@ private extension ArticlePasteboardWriter {
|
|||||||
}
|
}
|
||||||
if let text = article.contentText {
|
if let text = article.contentText {
|
||||||
s += "\(text)\n\n"
|
s += "\(text)\n\n"
|
||||||
}
|
} else if let summary = article.summary {
|
||||||
else if let summary = article.summary {
|
|
||||||
s += "\(summary)\n\n"
|
s += "\(summary)\n\n"
|
||||||
}
|
} else if let html = article.contentHTML {
|
||||||
else if let html = article.contentHTML {
|
|
||||||
let convertedHTML = html.convertingToPlainText()
|
let convertedHTML = html.convertingToPlainText()
|
||||||
s += "\(convertedHTML)\n\n"
|
s += "\(convertedHTML)\n\n"
|
||||||
}
|
}
|
||||||
@ -187,4 +185,3 @@ private extension ArticlePasteboardWriter {
|
|||||||
return authors.map { authorDictionary($0) }
|
return authors.map { authorDictionary($0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,8 +227,7 @@ private extension MultilineTextFieldSizer {
|
|||||||
|
|
||||||
if oneWidth < width && (oneWidth > smallNeighbor.width || smallNeighbor.width == 0) {
|
if oneWidth < width && (oneWidth > smallNeighbor.width || smallNeighbor.width == 0) {
|
||||||
smallNeighbor = (oneWidth, oneHeight)
|
smallNeighbor = (oneWidth, oneHeight)
|
||||||
}
|
} else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
|
||||||
else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
|
|
||||||
largeNeighbor = (oneWidth, oneHeight)
|
largeNeighbor = (oneWidth, oneHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +42,7 @@ struct TimelineCellLayout {
|
|||||||
|
|
||||||
if height > 0.1 {
|
if height > 0.1 {
|
||||||
self.height = height
|
self.height = height
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
self.height = [feedNameRect, dateRect, titleRect, summaryRect, textRect, unreadIndicatorRect, iconImageRect].maxY() + paddingBottom
|
self.height = [feedNameRect, dateRect, titleRect, summaryRect, textRect, unreadIndicatorRect, iconImageRect].maxY() + paddingBottom
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,8 +61,7 @@ struct TimelineCellLayout {
|
|||||||
var lastTextRect = titleRect
|
var lastTextRect = titleRect
|
||||||
if numberOfLinesForTitle == 0 {
|
if numberOfLinesForTitle == 0 {
|
||||||
lastTextRect = textRect
|
lastTextRect = textRect
|
||||||
}
|
} else if numberOfLinesForTitle < appearance.titleNumberOfLines {
|
||||||
else if numberOfLinesForTitle < appearance.titleNumberOfLines {
|
|
||||||
if summaryRect.height > 0.1 {
|
if summaryRect.height > 0.1 {
|
||||||
lastTextRect = summaryRect
|
lastTextRect = summaryRect
|
||||||
}
|
}
|
||||||
@ -130,7 +128,7 @@ private extension TimelineCellLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var r = textBoxRect
|
var r = textBoxRect
|
||||||
r.origin.y = NSMaxY(titleRect)
|
r.origin.y = titleRect.maxY
|
||||||
let summaryNumberOfLines = appearance.titleNumberOfLines - titleNumberOfLines
|
let summaryNumberOfLines = appearance.titleNumberOfLines - titleNumberOfLines
|
||||||
|
|
||||||
let sizeInfo = MultilineTextFieldSizer.size(for: cellData.text, font: appearance.textOnlyFont, numberOfLines: summaryNumberOfLines, width: Int(textBoxRect.width))
|
let sizeInfo = MultilineTextFieldSizer.size(for: cellData.text, font: appearance.textOnlyFont, numberOfLines: summaryNumberOfLines, width: Int(textBoxRect.width))
|
||||||
@ -161,9 +159,9 @@ private extension TimelineCellLayout {
|
|||||||
static func rectForDate(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
static func rectForDate(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||||
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.dateString, font: appearance.dateFont)
|
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.dateString, font: appearance.dateFont)
|
||||||
|
|
||||||
var r = NSZeroRect
|
var r = NSRect.zero
|
||||||
r.size = textFieldSize
|
r.size = textFieldSize
|
||||||
r.origin.y = NSMaxY(rectAbove) + appearance.titleBottomMargin
|
r.origin.y = rectAbove.maxY + appearance.titleBottomMargin
|
||||||
r.size.width = textFieldSize.width
|
r.size.width = textFieldSize.width
|
||||||
|
|
||||||
r.origin.x = textBoxRect.maxX - textFieldSize.width
|
r.origin.x = textBoxRect.maxX - textFieldSize.width
|
||||||
@ -173,11 +171,11 @@ private extension TimelineCellLayout {
|
|||||||
|
|
||||||
static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||||
if cellData.showFeedName == .none {
|
if cellData.showFeedName == .none {
|
||||||
return NSZeroRect
|
return NSRect.zero
|
||||||
}
|
}
|
||||||
|
|
||||||
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.feedName, font: appearance.feedNameFont)
|
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.feedName, font: appearance.feedNameFont)
|
||||||
var r = NSZeroRect
|
var r = NSRect.zero
|
||||||
r.size = textFieldSize
|
r.size = textFieldSize
|
||||||
r.origin.y = dateRect.minY
|
r.origin.y = dateRect.minY
|
||||||
r.origin.x = textBoxRect.origin.x
|
r.origin.x = textBoxRect.origin.x
|
||||||
@ -188,7 +186,7 @@ private extension TimelineCellLayout {
|
|||||||
|
|
||||||
static func rectForUnreadIndicator(_ appearance: TimelineCellAppearance, _ titleRect: NSRect) -> NSRect {
|
static func rectForUnreadIndicator(_ appearance: TimelineCellAppearance, _ titleRect: NSRect) -> NSRect {
|
||||||
|
|
||||||
var r = NSZeroRect
|
var r = NSRect.zero
|
||||||
r.size = NSSize(width: appearance.unreadCircleDimension, height: appearance.unreadCircleDimension)
|
r.size = NSSize(width: appearance.unreadCircleDimension, height: appearance.unreadCircleDimension)
|
||||||
r.origin.x = appearance.cellPadding.left
|
r.origin.x = appearance.cellPadding.left
|
||||||
r.origin.y = titleRect.minY + 6
|
r.origin.y = titleRect.minY + 6
|
||||||
@ -237,4 +235,3 @@ private extension Array where Element == NSRect {
|
|||||||
return y
|
return y
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class TimelineTableCellView: NSTableCellView {
|
|||||||
private let titleView = TimelineTableCellView.multiLineTextField()
|
private let titleView = TimelineTableCellView.multiLineTextField()
|
||||||
private let summaryView = TimelineTableCellView.multiLineTextField()
|
private let summaryView = TimelineTableCellView.multiLineTextField()
|
||||||
private let textView = TimelineTableCellView.multiLineTextField()
|
private let textView = TimelineTableCellView.multiLineTextField()
|
||||||
private let unreadIndicatorView = UnreadIndicatorView(frame: NSZeroRect)
|
private let unreadIndicatorView = UnreadIndicatorView(frame: NSRect.zero)
|
||||||
private let dateView = TimelineTableCellView.singleLineTextField()
|
private let dateView = TimelineTableCellView.singleLineTextField()
|
||||||
private let feedNameView = TimelineTableCellView.singleLineTextField()
|
private let feedNameView = TimelineTableCellView.singleLineTextField()
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ class TimelineTableCellView: NSTableCellView {
|
|||||||
|
|
||||||
override func layout() {
|
override func layout() {
|
||||||
|
|
||||||
resizeSubviews(withOldSize: NSZeroSize)
|
resizeSubviews(withOldSize: NSSize.zero)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||||
@ -149,8 +149,7 @@ private extension TimelineTableCellView {
|
|||||||
|
|
||||||
if Int(floor(rect.height)) == 0 || Int(floor(rect.width)) == 0 {
|
if Int(floor(rect.height)) == 0 || Int(floor(rect.width)) == 0 {
|
||||||
hideView(textField)
|
hideView(textField)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
showView(textField)
|
showView(textField)
|
||||||
textField.setFrame(ifNotEqualTo: rect)
|
textField.setFrame(ifNotEqualTo: rect)
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,3 @@ final class TimelineContainerView: NSView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,8 +170,7 @@ private extension TimelineContainerViewController {
|
|||||||
func mode(for timelineViewController: TimelineViewController) -> TimelineSourceMode {
|
func mode(for timelineViewController: TimelineViewController) -> TimelineSourceMode {
|
||||||
if timelineViewController === regularTimelineViewController {
|
if timelineViewController === regularTimelineViewController {
|
||||||
return .regular
|
return .regular
|
||||||
}
|
} else if timelineViewController === searchTimelineViewController {
|
||||||
else if timelineViewController === searchTimelineViewController {
|
|
||||||
return .search
|
return .search
|
||||||
}
|
}
|
||||||
assertionFailure("Expected timelineViewController to match either regular or search timelineViewController, but it doesn’t.")
|
assertionFailure("Expected timelineViewController to match either regular or search timelineViewController, but it doesn’t.")
|
||||||
|
@ -106,7 +106,6 @@ extension TimelineViewController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private extension TimelineViewController {
|
private extension TimelineViewController {
|
||||||
|
|
||||||
func markArticles(_ articles: [Article], read: Bool) {
|
func markArticles(_ articles: [Article], read: Bool) {
|
||||||
@ -282,7 +281,6 @@ private extension TimelineViewController {
|
|||||||
return menuItem(NSLocalizedString("Copy External URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), urlString)
|
return menuItem(NSLocalizedString("Copy External URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), urlString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any) -> NSMenuItem {
|
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any) -> NSMenuItem {
|
||||||
|
|
||||||
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
|
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
|
||||||
|
@ -331,8 +331,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
|
|
||||||
if markAsRead {
|
if markAsRead {
|
||||||
markSelectedArticlesAsRead(sender)
|
markSelectedArticlesAsRead(sender)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
markSelectedArticlesAsUnread(sender)
|
markSelectedArticlesAsUnread(sender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -485,12 +484,11 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
|||||||
func markOlderArticlesRead(_ selectedArticles: [Article]) {
|
func markOlderArticlesRead(_ selectedArticles: [Article]) {
|
||||||
// Mark articles older than the selectedArticles(s) as read.
|
// Mark articles older than the selectedArticles(s) as read.
|
||||||
|
|
||||||
var cutoffDate: Date? = nil
|
var cutoffDate: Date?
|
||||||
for article in selectedArticles {
|
for article in selectedArticles {
|
||||||
if cutoffDate == nil {
|
if cutoffDate == nil {
|
||||||
cutoffDate = article.logicalDatePublished
|
cutoffDate = article.logicalDatePublished
|
||||||
}
|
} else if cutoffDate! > article.logicalDatePublished {
|
||||||
else if cutoffDate! > article.logicalDatePublished {
|
|
||||||
cutoffDate = article.logicalDatePublished
|
cutoffDate = article.logicalDatePublished
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -833,8 +831,7 @@ extension TimelineViewController: NSTableViewDelegate {
|
|||||||
cell.cellAppearance = showIcons ? cellAppearanceWithIcon : cellAppearance
|
cell.cellAppearance = showIcons ? cellAppearanceWithIcon : cellAppearance
|
||||||
if let article = articles.articleAtRow(row) {
|
if let article = articles.articleAtRow(row) {
|
||||||
configureTimelineCell(cell, article: article)
|
configureTimelineCell(cell, article: article)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
makeTimelineCellEmpty(cell)
|
makeTimelineCellEmpty(cell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -917,16 +914,16 @@ extension TimelineViewController: NSTableViewDelegate {
|
|||||||
|
|
||||||
switch edge {
|
switch edge {
|
||||||
case .leading:
|
case .leading:
|
||||||
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (action, row) in
|
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (_, _) in
|
||||||
self.toggleArticleRead(article);
|
self.toggleArticleRead(article)
|
||||||
tableView.rowActionsVisible = false
|
tableView.rowActionsVisible = false
|
||||||
}
|
}
|
||||||
action.image = article.status.read ? AppAssets.swipeMarkUnreadImage : AppAssets.swipeMarkReadImage
|
action.image = article.status.read ? AppAssets.swipeMarkUnreadImage : AppAssets.swipeMarkReadImage
|
||||||
return [action]
|
return [action]
|
||||||
|
|
||||||
case .trailing:
|
case .trailing:
|
||||||
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (action, row) in
|
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (_, _) in
|
||||||
self.toggleArticleStarred(article);
|
self.toggleArticleStarred(article)
|
||||||
tableView.rowActionsVisible = false
|
tableView.rowActionsVisible = false
|
||||||
}
|
}
|
||||||
action.backgroundColor = AppAssets.starColor
|
action.backgroundColor = AppAssets.starColor
|
||||||
@ -1236,8 +1233,7 @@ private extension TimelineViewController {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if let folder = representedObject as? Folder {
|
||||||
else if let folder = representedObject as? Folder {
|
|
||||||
for oneFeed in feeds {
|
for oneFeed in feeds {
|
||||||
if folder.hasFeed(with: oneFeed.feedID) || folder.hasFeed(withURL: oneFeed.url) {
|
if folder.hasFeed(with: oneFeed.feedID) || folder.hasFeed(withURL: oneFeed.url) {
|
||||||
return true
|
return true
|
||||||
|
@ -53,7 +53,7 @@ class AccountsAddCloudKitWindowController: NSWindowController {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
_ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate
|
|||||||
accountsReaderAPIWindowController.account = account
|
accountsReaderAPIWindowController.account = account
|
||||||
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
|
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
|
||||||
accountsWindowController = accountsReaderAPIWindowController
|
accountsWindowController = accountsReaderAPIWindowController
|
||||||
break
|
|
||||||
case .newsBlur:
|
case .newsBlur:
|
||||||
let accountsNewsBlurWindowController = AccountsNewsBlurWindowController()
|
let accountsNewsBlurWindowController = AccountsNewsBlurWindowController()
|
||||||
accountsNewsBlurWindowController.account = account
|
accountsNewsBlurWindowController.account = account
|
||||||
|
@ -103,7 +103,7 @@ class AccountsFeedbinWindowController: NSWindowController {
|
|||||||
try self.account?.removeCredentials(type: .basic)
|
try self.account?.removeCredentials(type: .basic)
|
||||||
try self.account?.storeCredentials(validatedCredentials)
|
try self.account?.storeCredentials(validatedCredentials)
|
||||||
|
|
||||||
self.account?.refreshAll() { result in
|
self.account?.refreshAll { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
break
|
break
|
||||||
|
@ -101,7 +101,7 @@ class AccountsNewsBlurWindowController: NSWindowController {
|
|||||||
try self.account?.storeCredentials(credentials)
|
try self.account?.storeCredentials(credentials)
|
||||||
try self.account?.storeCredentials(validatedCredentials)
|
try self.account?.storeCredentials(validatedCredentials)
|
||||||
|
|
||||||
self.account?.refreshAll() { result in
|
self.account?.refreshAll { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
break
|
break
|
||||||
|
@ -40,7 +40,6 @@ final class AccountsPreferencesViewController: NSViewController {
|
|||||||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil)
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil)
|
||||||
|
|
||||||
|
|
||||||
// Fix tableView frame — for some reason IB wants it 1pt wider than the clip view. This leads to unwanted horizontal scrolling.
|
// Fix tableView frame — for some reason IB wants it 1pt wider than the clip view. This leads to unwanted horizontal scrolling.
|
||||||
var rTable = tableView.frame
|
var rTable = tableView.frame
|
||||||
rTable.size.width = tableView.superview!.frame.size.width
|
rTable.size.width = tableView.superview!.frame.size.width
|
||||||
|
@ -158,7 +158,7 @@ class AccountsReaderAPIWindowController: NSWindowController {
|
|||||||
try self.account?.storeCredentials(credentials)
|
try self.account?.storeCredentials(credentials)
|
||||||
try self.account?.storeCredentials(validatedCredentials)
|
try self.account?.storeCredentials(validatedCredentials)
|
||||||
|
|
||||||
self.account?.refreshAll() { result in
|
self.account?.refreshAll { result in
|
||||||
switch result {
|
switch result {
|
||||||
case .success:
|
case .success:
|
||||||
break
|
break
|
||||||
|
@ -69,9 +69,6 @@ enum AddAccountSections: Int, CaseIterable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AddAccountsView: View {
|
struct AddAccountsView: View {
|
||||||
@ -270,10 +267,8 @@ struct AddAccountsView: View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
struct AddAccountsView_Previews: PreviewProvider {
|
struct AddAccountsView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
AddAccountsView(delegate: nil)
|
AddAccountsView(delegate: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,7 @@ private extension AdvancedPreferencesViewController {
|
|||||||
func updateUI() {
|
func updateUI() {
|
||||||
if wantsTestBuilds {
|
if wantsTestBuilds {
|
||||||
testBuildsButton.state = .on
|
testBuildsButton.state = .on
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
releaseBuildsButton.state = .on
|
releaseBuildsButton.state = .on
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ final class PreferencesControlsBackgroundView: NSView {
|
|||||||
|
|
||||||
let fillColor = self.effectiveAppearance.isDarkMode ? darkModeFillColor : lightModeFillColor
|
let fillColor = self.effectiveAppearance.isDarkMode ? darkModeFillColor : lightModeFillColor
|
||||||
fillColor.setFill()
|
fillColor.setFill()
|
||||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
let r = dirtyRect.intersection(bounds)
|
||||||
r.fill()
|
r.fill()
|
||||||
|
|
||||||
let borderColor = self.effectiveAppearance.isDarkMode ? darkModeBorderColor : lightModeBorderColor
|
let borderColor = self.effectiveAppearance.isDarkMode ? darkModeBorderColor : lightModeBorderColor
|
||||||
|
@ -17,7 +17,7 @@ final class PreferencesTableViewBackgroundView: NSView {
|
|||||||
let color = self.effectiveAppearance.isDarkMode ? darkBorderColor : lightBorderColor
|
let color = self.effectiveAppearance.isDarkMode ? darkBorderColor : lightBorderColor
|
||||||
color.setFill()
|
color.setFill()
|
||||||
|
|
||||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
let r = dirtyRect.intersection(bounds)
|
||||||
r.fill()
|
r.fill()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,7 @@ private extension PreferencesWindowController {
|
|||||||
|
|
||||||
if let currentView = currentView {
|
if let currentView = currentView {
|
||||||
window!.contentView?.replaceSubview(currentView, with: newViewController.view)
|
window!.contentView?.replaceSubview(currentView, with: newViewController.view)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
window!.contentView?.addSubview(newViewController.view)
|
window!.contentView?.addSubview(newViewController.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,9 +167,9 @@ private extension PreferencesWindowController {
|
|||||||
let windowFrame = window!.frame
|
let windowFrame = window!.frame
|
||||||
let contentViewFrame = window!.contentView!.frame
|
let contentViewFrame = window!.contentView!.frame
|
||||||
|
|
||||||
let deltaHeight = NSHeight(contentViewFrame) - NSHeight(viewFrame)
|
let deltaHeight = contentViewFrame.height - viewFrame.height
|
||||||
let heightForWindow = NSHeight(windowFrame) - deltaHeight
|
let heightForWindow = windowFrame.height - deltaHeight
|
||||||
let windowOriginY = NSMinY(windowFrame) + deltaHeight
|
let windowOriginY = windowFrame.minY + deltaHeight
|
||||||
|
|
||||||
var updatedWindowFrame = windowFrame
|
var updatedWindowFrame = windowFrame
|
||||||
updatedWindowFrame.size.height = heightForWindow
|
updatedWindowFrame.size.height = heightForWindow
|
||||||
@ -178,7 +177,7 @@ private extension PreferencesWindowController {
|
|||||||
updatedWindowFrame.size.width = windowWidth // NSWidth(viewFrame)
|
updatedWindowFrame.size.width = windowWidth // NSWidth(viewFrame)
|
||||||
|
|
||||||
var updatedViewFrame = viewFrame
|
var updatedViewFrame = viewFrame
|
||||||
updatedViewFrame.origin = NSZeroPoint
|
updatedViewFrame.origin = NSPoint.zero
|
||||||
updatedViewFrame.size.width = windowWidth
|
updatedViewFrame.size.width = windowWidth
|
||||||
if viewFrame != updatedViewFrame {
|
if viewFrame != updatedViewFrame {
|
||||||
view.frame = updatedViewFrame
|
view.frame = updatedViewFrame
|
||||||
|
@ -29,7 +29,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maps from UUID to a validation wrapper
|
// Maps from UUID to a validation wrapper
|
||||||
static var gPingPongMap = Dictionary<String, ValidationWrapper>()
|
static var gPingPongMap = [String: ValidationWrapper]()
|
||||||
static var validationQueue = DispatchQueue(label: "Toolbar Validation")
|
static var validationQueue = DispatchQueue(label: "Toolbar Validation")
|
||||||
|
|
||||||
// Bottleneck for calling through to a validation handler we have saved, and removing it from the list.
|
// Bottleneck for calling through to a validation handler we have saved, and removing it from the list.
|
||||||
@ -41,7 +41,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
||||||
if (messageName == "subscribeToFeed") {
|
if messageName == "subscribeToFeed" {
|
||||||
if var feedURLString = userInfo?["url"] as? String {
|
if var feedURLString = userInfo?["url"] as? String {
|
||||||
var openInDefaultBrowser = false
|
var openInDefaultBrowser = false
|
||||||
|
|
||||||
@ -61,8 +61,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
NSWorkspace.shared.open(feedURL)
|
NSWorkspace.shared.open(feedURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if messageName == "pong" {
|
||||||
else if (messageName == "pong") {
|
|
||||||
if let validationIDString = userInfo?["validationID"] as? String {
|
if let validationIDString = userInfo?["validationID"] as? String {
|
||||||
// Should we validate the button?
|
// Should we validate the button?
|
||||||
let shouldValidate = userInfo?["shouldValidate"] as? Bool ?? false
|
let shouldValidate = userInfo?["shouldValidate"] as? Bool ?? false
|
||||||
@ -97,7 +96,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
if thisValidationID != uniqueValidationID {
|
if thisValidationID != uniqueValidationID {
|
||||||
// Default to valid ... we'll know soon enough whether the latest state
|
// Default to valid ... we'll know soon enough whether the latest state
|
||||||
// is actually still valid or not...
|
// is actually still valid or not...
|
||||||
SafariExtensionHandler.callValidationHandler(forHandlerID: thisValidationID, withShouldValidate: true);
|
SafariExtensionHandler.callValidationHandler(forHandlerID: thisValidationID, withShouldValidate: true)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -108,13 +107,13 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
|||||||
// a timeout period has elapsed
|
// a timeout period has elapsed
|
||||||
window.getActiveTab { (activeTab) in
|
window.getActiveTab { (activeTab) in
|
||||||
guard let activeTab = activeTab else {
|
guard let activeTab = activeTab else {
|
||||||
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate:false);
|
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate: false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
activeTab.getActivePage { (activePage) in
|
activeTab.getActivePage { (activePage) in
|
||||||
guard let activePage = activePage else {
|
guard let activePage = activePage else {
|
||||||
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate:false);
|
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate: false)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,18 +70,18 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
|||||||
func deleteElement(_ element: ScriptingObject) {
|
func deleteElement(_ element: ScriptingObject) {
|
||||||
if let scriptableFolder = element as? ScriptableFolder {
|
if let scriptableFolder = element as? ScriptableFolder {
|
||||||
BatchUpdate.shared.perform {
|
BatchUpdate.shared.perform {
|
||||||
account.removeFolder(scriptableFolder.folder) { result in
|
account.removeFolder(scriptableFolder.folder) { _ in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if let scriptableFeed = element as? ScriptableFeed {
|
} else if let scriptableFeed = element as? ScriptableFeed {
|
||||||
BatchUpdate.shared.perform {
|
BatchUpdate.shared.perform {
|
||||||
var container: Container? = nil
|
var container: Container?
|
||||||
if let scriptableFolder = scriptableFeed.container as? ScriptableFolder {
|
if let scriptableFolder = scriptableFeed.container as? ScriptableFolder {
|
||||||
container = scriptableFolder.folder
|
container = scriptableFolder.folder
|
||||||
} else {
|
} else {
|
||||||
container = account
|
container = account
|
||||||
}
|
}
|
||||||
account.removeFeed(scriptableFeed.feed, from: container!) { result in
|
account.removeFeed(scriptableFeed.feed, from: container!) { _ in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
|||||||
|
|
||||||
@objc(isLocationRequiredToCreateForKey:)
|
@objc(isLocationRequiredToCreateForKey:)
|
||||||
func isLocationRequiredToCreate(forKey key: String) -> Bool {
|
func isLocationRequiredToCreate(forKey key: String) -> Bool {
|
||||||
return false;
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: --- Scriptable elements ---
|
// MARK: --- Scriptable elements ---
|
||||||
|
@ -54,7 +54,7 @@ extension AppDelegate : AppDelegateAppleEvents {
|
|||||||
|
|
||||||
if let themeURL = URL(string: themeURLString) {
|
if let themeURL = URL(string: themeURLString) {
|
||||||
let request = URLRequest(url: themeURL)
|
let request = URLRequest(url: themeURL)
|
||||||
let task = URLSession.shared.downloadTask(with: request) { location, response, error in
|
let task = URLSession.shared.downloadTask(with: request) { location, _, error in
|
||||||
guard let location = location else {
|
guard let location = location else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -71,7 +71,6 @@ extension AppDelegate : AppDelegateAppleEvents {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Special case URL with specific scheme handler x-netnewswire-feed: intended to ensure we open
|
// Special case URL with specific scheme handler x-netnewswire-feed: intended to ensure we open
|
||||||
// it regardless of which news reader may be set as the default
|
// it regardless of which news reader may be set as the default
|
||||||
let nnwScheme = "x-netnewswire-feed:"
|
let nnwScheme = "x-netnewswire-feed:"
|
||||||
@ -94,9 +93,9 @@ extension AppDelegate : AppDelegateAppleEvents {
|
|||||||
class NetNewsWireCreateElementCommand: NSCreateCommand {
|
class NetNewsWireCreateElementCommand: NSCreateCommand {
|
||||||
override func performDefaultImplementation() -> Any? {
|
override func performDefaultImplementation() -> Any? {
|
||||||
let classDescription = self.createClassDescription
|
let classDescription = self.createClassDescription
|
||||||
if (classDescription.className == "feed") {
|
if classDescription.className == "feed" {
|
||||||
return ScriptableFeed.handleCreateElement(command: self)
|
return ScriptableFeed.handleCreateElement(command: self)
|
||||||
} else if (classDescription.className == "folder") {
|
} else if classDescription.className == "folder" {
|
||||||
return ScriptableFolder.handleCreateElement(command: self)
|
return ScriptableFolder.handleCreateElement(command: self)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -183,4 +182,3 @@ class NetNewsWireExistsCommand : NSExistsCommand {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
|||||||
func deleteElement(_ element: ScriptingObject) {
|
func deleteElement(_ element: ScriptingObject) {
|
||||||
if let scriptableFeed = element as? ScriptableFeed {
|
if let scriptableFeed = element as? ScriptableFeed {
|
||||||
BatchUpdate.shared.perform {
|
BatchUpdate.shared.perform {
|
||||||
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { result in }
|
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { _ in }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
|||||||
// identifies where the new folder should be created
|
// identifies where the new folder should be created
|
||||||
let (account, folder) = command.accountAndFolderForNewChild()
|
let (account, folder) = command.accountAndFolderForNewChild()
|
||||||
guard folder == nil else {
|
guard folder == nil else {
|
||||||
print("support for folders within folders is NYI");
|
print("support for folders within folders is NYI")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,4 +13,3 @@ protocol ScriptingMainWindowController {
|
|||||||
var scriptingCurrentArticle: Article? { get }
|
var scriptingCurrentArticle: Article? { get }
|
||||||
var scriptingSelectedArticles: [Article] { get }
|
var scriptingSelectedArticles: [Article] { get }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,5 +95,3 @@ extension NSApplication : ScriptingObjectContainer {
|
|||||||
return ScriptableFeed(feed, container: self)
|
return ScriptableFeed(feed, container: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,23 +22,23 @@ extension NSScriptCommand {
|
|||||||
func isCreateCommand(forClass whatClass: String) -> Bool {
|
func isCreateCommand(forClass whatClass: String) -> Bool {
|
||||||
guard let arguments = self.arguments else {return false}
|
guard let arguments = self.arguments else {return false}
|
||||||
guard let newObjectClass = arguments["ObjectClass"] as? Int else {return false}
|
guard let newObjectClass = arguments["ObjectClass"] as? Int else {return false}
|
||||||
guard (newObjectClass.fourCharCode == whatClass.fourCharCode) else {return false}
|
guard newObjectClass.fourCharCode == whatClass.fourCharCode else {return false}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
||||||
let appleEvent = self.appleEvent
|
let appleEvent = self.appleEvent
|
||||||
var account = AccountManager.shared.defaultAccount
|
var account = AccountManager.shared.defaultAccount
|
||||||
var folder:Folder? = nil
|
var folder: Folder?
|
||||||
if let appleEvent = appleEvent {
|
if let appleEvent = appleEvent {
|
||||||
var descriptorToConsider: NSAppleEventDescriptor?
|
var descriptorToConsider: NSAppleEventDescriptor?
|
||||||
if let insertionLocationDescriptor = appleEvent.paramDescriptor(forKeyword: keyAEInsertHere) {
|
if let insertionLocationDescriptor = appleEvent.paramDescriptor(forKeyword: keyAEInsertHere) {
|
||||||
print("insertionLocation : \(insertionLocationDescriptor)")
|
print("insertionLocation : \(insertionLocationDescriptor)")
|
||||||
// insertion location can be a typeObjectSpecifier, e.g. 'in account "Acct"'
|
// insertion location can be a typeObjectSpecifier, e.g. 'in account "Acct"'
|
||||||
// or a typeInsertionLocation, e.g. 'at end of folder "
|
// or a typeInsertionLocation, e.g. 'at end of folder "
|
||||||
if (insertionLocationDescriptor.descriptorType == "insl".fourCharCode) {
|
if insertionLocationDescriptor.descriptorType == "insl".fourCharCode {
|
||||||
descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode)
|
descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode)
|
||||||
} else if ( insertionLocationDescriptor.descriptorType == "obj ".fourCharCode) {
|
} else if insertionLocationDescriptor.descriptorType == "obj ".fourCharCode {
|
||||||
descriptorToConsider = insertionLocationDescriptor
|
descriptorToConsider = insertionLocationDescriptor
|
||||||
}
|
}
|
||||||
} else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword: "subj".fourCharCode) {
|
} else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword: "subj".fourCharCode) {
|
||||||
|
@ -36,4 +36,3 @@ extension ScriptingObjectContainer {
|
|||||||
return specifier
|
return specifier
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class ShareViewController: NSViewController {
|
|||||||
extensionContainers = ExtensionContainersFile.read()
|
extensionContainers = ExtensionContainersFile.read()
|
||||||
buildFolderPopupMenu()
|
buildFolderPopupMenu()
|
||||||
|
|
||||||
var provider: NSItemProvider? = nil
|
var provider: NSItemProvider?
|
||||||
|
|
||||||
// Try to get any HTML that is maybe passed in
|
// Try to get any HTML that is maybe passed in
|
||||||
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
|
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
|
||||||
@ -117,7 +117,7 @@ private extension ShareViewController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let defaultContainer = ShareDefaultContainer.defaultContainer(containers: extensionContainers)
|
let defaultContainer = ShareDefaultContainer.defaultContainer(containers: extensionContainers)
|
||||||
var defaultMenuItem: NSMenuItem? = nil
|
var defaultMenuItem: NSMenuItem?
|
||||||
|
|
||||||
for account in extensionContainers.accounts {
|
for account in extensionContainers.accounts {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user