Skip to content

Commit

Permalink
Use standard toggleSidebar toolbar item. Fix #4103.
Browse files Browse the repository at this point in the history
  • Loading branch information
brentsimmons committed Oct 29, 2024
1 parent 8470ff7 commit e039a2b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 37 deletions.
6 changes: 3 additions & 3 deletions Mac/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
</dependencies>
<scenes>
<!--Application-->
Expand Down Expand Up @@ -400,7 +400,7 @@
<menuItem title="Show Sidebar" keyEquivalent="s" id="kIP-vf-haE">
<modifierMask key="keyEquivalentModifierMask" control="YES" command="YES"/>
<connections>
<action selector="toggleTheSidebar:" target="Ady-hI-5gd" id="1hl-EZ-ao4"/>
<action selector="toggleSidebar:" target="Ady-hI-5gd" id="wp8-Ae-erS"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="jKG-b2-ZWf"/>
Expand Down
5 changes: 2 additions & 3 deletions Mac/Base.lproj/UnifiedWindow.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22690"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down
32 changes: 2 additions & 30 deletions Mac/MainWindow/MainWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,20 +273,6 @@ final class MainWindowController : NSWindowController, NSUserInterfaceValidation
return validateToggleReadArticles(item)
}

if item.action == #selector(toggleTheSidebar(_:)) {
guard let splitViewItem = sidebarSplitViewItem else {
return false
}

let sidebarIsShowing = !splitViewItem.isCollapsed
if let menuItem = item as? NSMenuItem {
let title = sidebarIsShowing ? NSLocalizedString("Hide Sidebar", comment: "Menu item") : NSLocalizedString("Show Sidebar", comment: "Menu item")
menuItem.title = title
}

return true
}

return true
}

Expand Down Expand Up @@ -463,16 +449,6 @@ final class MainWindowController : NSWindowController, NSUserInterfaceValidation
nextUnread(sender)
}

@IBAction func toggleTheSidebar(_ sender: Any?) {
splitViewController!.toggleSidebar(sender)
guard let splitViewItem = sidebarSplitViewItem else { return }
if splitViewItem.isCollapsed {
currentTimelineViewController?.focus()
} else {
sidebarViewController?.focus()
}
}

@IBAction func markOlderArticlesAsRead(_ sender: Any?) {
currentTimelineViewController?.markOlderArticlesRead()
}
Expand Down Expand Up @@ -769,7 +745,6 @@ extension MainWindowController : ScriptingMainWindowController {
// MARK: - NSToolbarDelegate

extension NSToolbarItem.Identifier {
static let sidebarToggle = NSToolbarItem.Identifier("sidebarToggle")
static let newFeed = NSToolbarItem.Identifier("newFeed")
static let newFolder = NSToolbarItem.Identifier("newFolder")
static let refresh = NSToolbarItem.Identifier("refresh")
Expand All @@ -794,10 +769,6 @@ extension MainWindowController: NSToolbarDelegate {

switch itemIdentifier {

case .sidebarToggle:
let title = NSLocalizedString("Toggle Sidebar", comment: "Toggle Sidebar")
return buildToolbarButton(.toggleSidebar, title, AppAsset.toolbarSidebarToggleImage, "toggleTheSidebar:")

case .refresh:
let title = NSLocalizedString("Refresh", comment: "Refresh")
return buildToolbarButton(.refresh, title, AppAsset.toolbarRefreshImage, "refreshAll:")
Expand Down Expand Up @@ -880,7 +851,7 @@ extension MainWindowController: NSToolbarDelegate {

func toolbarAllowedItemIdentifiers(_ toolbar: NSToolbar) -> [NSToolbarItem.Identifier] {
[
.sidebarToggle,
NSToolbarItem.Identifier.toggleSidebar,
.refresh,
.newSidebarItemMenu,
.sidebarTrackingSeparator,
Expand All @@ -906,6 +877,7 @@ extension MainWindowController: NSToolbarDelegate {
.refresh,
.newSidebarItemMenu,
.sidebarTrackingSeparator,
NSToolbarItem.Identifier.toggleSidebar,
.markAllAsRead,
.toggleReadArticlesFilter,
.timelineTrackingSeparator,
Expand Down
1 change: 0 additions & 1 deletion Shared/AppAsset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ extension AppAsset {
// MARK: - Mac Toolbar

static let toolbarAddNewSidebarItemImage = RSImage.systemImage("plus")
static let toolbarSidebarToggleImage = RSImage.systemImage("sidebar.left")
static let toolbarRefreshImage = RSImage.systemImage("arrow.clockwise")
static let toolbarArticleThemeImage = RSImage.systemImage("doc.richtext")
static let toolbarCleanUpImage = RSImage.systemImage("wind")
Expand Down

0 comments on commit e039a2b

Please sign in to comment.