Merge branch '7.1.3-pre' of https://github.com/Ranchero-Software/NetNewsWire into 7.1.3-pre

This commit is contained in:
Brent Simmons committed 2026-07-28 21:41:18 -07:00
commit 5a47d7993d
4 files changed
+75 -11

No files matched your search

+22 -3
View File
@@ -539,8 +539,16 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
assertionFailure("Expected toolbarShowShareMenu to be called only by the Share item in the toolbar.")
return
}
guard let view = shareToolbarItem.view else {
// TODO: handle menu form representation
// In the toolbar's Text Only mode or overflow menu the item's view isn't on-window, so anchor the picker to the window instead.
let anchorView: NSView
let anchorRect: NSRect
if let view = shareToolbarItem.view, view.window != nil {
anchorView = view
anchorRect = view.bounds
} else if let contentView = window?.contentView {
anchorView = contentView
anchorRect = NSRect(x: contentView.frame.width / 2.0, y: contentView.frame.height - 4, width: 1, height: 1)
} else {
return
}
@@ -551,7 +559,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
self.sharingServicePickerDelegate?.selectedHTML = selectedHTML
let sharingServicePicker = NSSharingServicePicker(items: items)
sharingServicePicker.delegate = self.sharingServicePickerDelegate
sharingServicePicker.show(relativeTo: view.bounds, of: view, preferredEdge: .minY)
sharingServicePicker.show(relativeTo: anchorRect, of: anchorView, preferredEdge: .minY)
}
}
@@ -867,6 +875,7 @@ extension MainWindowController: NSToolbarDelegate {
let button = ArticleExtractorButton()
button.action = #selector(toggleArticleExtractor(_:))
toolbarItem.view = button
toolbarItem.menuFormRepresentation = NSMenuItem(title: description, action: #selector(toggleArticleExtractor(_:)), keyEquivalent: "")
return toolbarItem
case .share:
@@ -1179,6 +1188,10 @@ private extension MainWindowController {
if let toolbarItem = item as? NSToolbarItem {
toolbarItem.toolTip = commandName
// Text Only toolbar mode shows the label and menu form representation, so they need to track state too.
let shortName = markingRead ? NSLocalizedString("Mark Read", comment: "command") : NSLocalizedString("Mark Unread", comment: "command")
toolbarItem.label = shortName
toolbarItem.menuFormRepresentation?.title = shortName
}
if let menuItem = item as? NSMenuItem {
@@ -1263,6 +1276,10 @@ private extension MainWindowController {
if let toolbarItem = item as? NSToolbarItem {
toolbarItem.toolTip = commandName
// Text Only toolbar mode shows the label and menu form representation, so they need to track state too.
let shortName = starring ? NSLocalizedString("Star", comment: "Star") : NSLocalizedString("Unstar", comment: "Unstar")
toolbarItem.label = shortName
toolbarItem.menuFormRepresentation?.title = shortName
}
if let menuItem = item as? NSMenuItem {
@@ -1457,6 +1474,8 @@ private extension MainWindowController {
toolbarItem.view = button
toolbarItem.toolTip = title
toolbarItem.label = title
// A menu form representation keeps view-based items working in the toolbar's Text Only mode and overflow menu.
toolbarItem.menuFormRepresentation = NSMenuItem(title: title, action: Selector((selector)), keyEquivalent: "")
return toolbarItem
}
@@ -12,10 +12,6 @@ import AppKit
public class RSToolbarItem: NSToolbarItem {
override public func validate() {
guard let view = view, view.window != nil else {
isEnabled = false
return
}
isEnabled = isValidAsUserInterfaceItem()
}
}
@@ -29,7 +25,9 @@ private extension RSToolbarItem {
return validateWithResponder(target) ?? false
}
var responder = view?.window?.firstResponder
// view.window is nil when the item is shown as its menu form representation (the toolbar's
// Text Only mode or overflow menu), so fall back to the main window's responder chain.
var responder = view?.window?.firstResponder ?? NSApp.mainWindow?.firstResponder
if responder == nil {
return false
}
+15
View File
@@ -78,6 +78,7 @@ final class AppDefaults: Sendable {
static let selectedArticle = "selectedArticle"
static let didMigrateLegacyStateRestorationInfo = "didMigrateLegacyStateRestorationInfo"
static let splitViewPreferredDisplayMode = "splitViewPreferredDisplayMode"
static let timelineWidth = "timelineWidth"
}
let isDeveloperBuild: Bool = {
@@ -229,6 +230,20 @@ final class AppDefaults: Sendable {
}
}
// The iPad timeline (supplementary) column width. nil until the user has resized it.
var timelineWidth: Int? {
get {
return AppDefaults.store.object(forKey: Key.timelineWidth) as? Int
}
set {
if let newValue {
AppDefaults.store.set(newValue, forKey: Key.timelineWidth)
} else {
AppDefaults.store.removeObject(forKey: Key.timelineWidth)
}
}
}
var lastRefresh: Date? {
get {
return AppDefaults.date(for: Key.lastRefresh)
+35 -3
View File
@@ -304,13 +304,32 @@ struct SidebarItemNode: Hashable, Sendable {
}
}
private static let minimumTimelineWidth: CGFloat = 280
private static let maximumTimelineWidth: CGFloat = 440
private static func clampTimelineWidth(_ width: CGFloat) -> CGFloat {
if width < minimumTimelineWidth {
return minimumTimelineWidth
}
if width > maximumTimelineWidth {
return maximumTimelineWidth
}
return width
}
init(rootSplitViewController: RootSplitViewController) {
self.rootSplitViewController = rootSplitViewController
self.rootSplitViewController.minimumPrimaryColumnWidth = 300
self.rootSplitViewController.maximumPrimaryColumnWidth = 500
self.rootSplitViewController.minimumSupplementaryColumnWidth = 300
self.rootSplitViewController.preferredSupplementaryColumnWidth = 320
self.rootSplitViewController.maximumSupplementaryColumnWidth = 360
self.rootSplitViewController.minimumSupplementaryColumnWidth = SceneCoordinator.minimumTimelineWidth
self.rootSplitViewController.maximumSupplementaryColumnWidth = SceneCoordinator.maximumTimelineWidth
let restoredTimelineWidth: CGFloat
if let savedTimelineWidth = AppDefaults.shared.timelineWidth {
restoredTimelineWidth = CGFloat(savedTimelineWidth)
} else {
restoredTimelineWidth = 320
}
self.rootSplitViewController.preferredSupplementaryColumnWidth = Self.clampTimelineWidth(restoredTimelineWidth)
self.rootSplitViewController.preferredSplitBehavior = .tile
self.treeController = TreeController(delegate: treeControllerDelegate)
@@ -744,6 +763,19 @@ struct SidebarItemNode: Hashable, Sendable {
func didEnterBackground() {
hidingReadArticlesState.save()
saveExpandedContainers()
saveTimelineWidth()
}
private func saveTimelineWidth() {
// Only meaningful when the timeline is its own column (iPad, expanded); when collapsed its view fills the screen.
guard !rootSplitViewController.isCollapsed else {
return
}
let width = mainTimelineViewController?.view.bounds.width ?? 0
guard width > 0 else {
return
}
AppDefaults.shared.timelineWidth = Int(SceneCoordinator.clampTimelineWidth(width))
}
func suspend() {