Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Pinned URL items beside Rename, without Arc's submenu (#76)

Victor Kildahl1772cf0539cf
diff --git a/Sources/Cra/Services/SidebarStore.swift b/Sources/Cra/Services/SidebarStore.swift
index d93ebce..1a5c406 100644
--- a/Sources/Cra/Services/SidebarStore.swift
+++ b/Sources/Cra/Services/SidebarStore.swift
@@ -511,7 +511,7 @@ final class SidebarStore {
touch()
}
- /// Arc's Edit Pinned Page ▸ Edit…: a new pinned URL for a pinned tab or favorite (#54). A tab
+ /// Edit Pinned URL…: a new pinned URL for a pinned tab or favorite (#54). A tab
/// on its pinned page goes with it; one navigated away keeps its page until Back to Pinned Page.
@discardableResult
func setPinnedURL(_ id: UUID, to url: String) -> Bool {
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
index 6c8654a..6ea4963 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
@@ -74,13 +74,13 @@ enum SidebarMenus {
menu.addItem(.separator())
add(menu, "Rename…") { ui.renamingID = id }
if item.title != nil { add(menu, "Use Page Title") { store.rename(id, to: nil) } }
+ if m.pinned, tab.liveItemURL == nil { pinnedURLItems(menu, id, navigatedAway: m.navigatedAway, store: store, actions: actions) }
add(menu, "Duplicate") { _ = store.duplicateTab(id) }
add(menu, "Copy Link") { copy(tab.url) }
add(menu, tab.muted ? "Unmute" : "Mute") {
store.setMuted(id, !tab.muted)
actions.performAction("muteTab:\(id)")
}
- if m.pinned, tab.liveItemURL == nil { editPinnedPage(menu, id, navigatedAway: m.navigatedAway, store: store, actions: actions) }
if m.pinned, m.navigatedAway {
menu.addItem(.separator())
add(menu, "Back to Pinned Page") { actions.resetPinnedTab(id) }
@@ -104,12 +104,12 @@ enum SidebarMenus {
return menu
}
- /// Arc's Edit Pinned Page submenu on pinned tabs and favorites (#54). Replace is greyed out
- /// while the tab is on its pinned page, as in Arc.
- static func editPinnedPage(_ menu: NSMenu, _ id: UUID, navigatedAway: Bool, store: SidebarStore, actions: SidebarActions) {
- let sub = submenu(menu, "Edit Pinned Page")
- add(sub, "Replace Pinned URL with Current", enabled: navigatedAway) { store.setPinnedHomeToCurrent(id) }
- add(sub, "Edit…") { actions.editPinnedURL(id) }
+ /// The pinned URL's items on pinned tabs and favorites (#54), beside Rename… since they edit
+ /// the same item. Arc puts them in an Edit Pinned Page submenu; Cra lists them flat, as
+ /// Anoninz suggested on PR #55. Replace is greyed out while the tab is on its pinned page.
+ static func pinnedURLItems(_ menu: NSMenu, _ id: UUID, navigatedAway: Bool, store: SidebarStore, actions: SidebarActions) {
+ add(menu, "Edit Pinned URL…") { actions.editPinnedURL(id) }
+ add(menu, "Replace Pinned URL with Current", enabled: navigatedAway) { store.setPinnedHomeToCurrent(id) }
}
/// Move to Folder / New Folder for this tab, or for every picked tab.
diff --git a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift
index 7425c71..eeb9a60 100644
--- a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift
+++ b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift
@@ -882,13 +882,13 @@ final class FavoriteTileView: NSView, ArcTooltipTarget, NSDraggingSource {
m.autoenablesItems = false
MenuItems.add(m, "Remove from Favorites") { store.removeFromFavorites(id) }
MenuItems.add(m, "Rename…") { ui.renamingID = id }
+ if let t = item.tab, t.liveItemURL == nil {
+ SidebarMenus.pinnedURLItems(m, id, navigatedAway: t.url != t.savedURL, store: store, actions: actions)
+ }
MenuItems.add(m, "Copy Link") {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(item.tab?.url ?? "", forType: .string)
}
- if let t = item.tab, t.liveItemURL == nil {
- SidebarMenus.editPinnedPage(m, id, navigatedAway: t.url != t.savedURL, store: store, actions: actions)
- }
if let t = item.tab, t.url != t.savedURL { MenuItems.add(m, "Back to Pinned Page") { actions.resetPinnedTab(id) } }
m.addItem(.separator())
MenuItems.add(m, "Change Icon…") { [weak self] in self?.pickIcon() }
diff --git a/Sources/Cra/UI/Windows/EditPinnedURLDialog.swift b/Sources/Cra/UI/Windows/EditPinnedURLDialog.swift
index 757a971..44cd1c9 100644
--- a/Sources/Cra/UI/Windows/EditPinnedURLDialog.swift
+++ b/Sources/Cra/UI/Windows/EditPinnedURLDialog.swift
@@ -1,6 +1,6 @@
import SwiftUI
-/// Arc 1.171's "Edit Pinned URL" dialog (a pinned tab's or favorite's Edit Pinned Page ▸ Edit…),
+/// Arc 1.171's "Edit Pinned URL" dialog (a pinned tab's or favorite's Edit Pinned URL…),
/// measured from a 2x capture (1 Nov, #54): a 393 × 265 pt navy card over the dimmed window, the
/// saved URL selected in its field. Arc enables Save for any text; Cra only for an address
/// (TypedURL.pinnedDestination), so a search or a script can't become the pinned page.
diff --git a/Sources/Cra/UI/Windows/MainWindowController.swift b/Sources/Cra/UI/Windows/MainWindowController.swift
index 96a75c0..7e99f06 100644
--- a/Sources/Cra/UI/Windows/MainWindowController.swift
+++ b/Sources/Cra/UI/Windows/MainWindowController.swift
@@ -1336,7 +1336,7 @@ final class MainWindowController: NSWindowController, NSWindowDelegate, BrowserM
app.runtime(for: id)?.browser.loadURL(home)
}
- /// Edit Pinned Page ▸ Edit… (#54): Arc's dialog with the pinned URL. A page showing the old
+ /// Edit Pinned URL… (#54): Arc's dialog with the pinned URL. A page showing the old
/// pinned URL loads the new one; one navigated away stays where it is.
func editPinnedURL(_ id: UUID) {
guard let window, let tab = store.item(id)?.tab, store.isPinned(id), tab.liveItemURL == nil else { return }
diff --git a/Tests/StoreTests.swift b/Tests/StoreTests.swift
index 340d2d8..4afdbd0 100644
--- a/Tests/StoreTests.swift
+++ b/Tests/StoreTests.swift
@@ -241,7 +241,7 @@ enum StoreTests {
expect(store.integrityProblems().isEmpty, "and the sidebar stays sound")
}
- /// Arc's Edit Pinned Page ▸ Edit… (#54, PR #55 by Anoninz): a new pinned URL keeps the item's
+ /// Edit Pinned URL… (#54, PR #55 by Anoninz): a new pinned URL keeps the item's
/// name, icon, colour and place, and survives a relaunch.
@MainActor
private static func pinnedURL() {