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.

Arc parity: Change Icon… and Share ▸ on the sidebar's tab menu

Victor6f3f298c7599
diff --git a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
index d3a7e6d..1cc2549 100644
--- a/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
+++ b/Sources/Cra/UI/Sidebar/List/SidebarMenus.swift
@@ -75,6 +75,25 @@ enum SidebarMenus {
add(menu, action: "favoriteTab", "Add to Favorites") { store.addToFavorites(id) }
}
menu.addItem(.separator())
+ // Arc's Today and pinned tab menus: Change Icon…, as Favorites have it.
+ let favicons = list.favicons
+ add(menu, "Change Icon…") {
+ let panel = NSOpenPanel()
+ panel.allowedContentTypes = [.image]
+ panel.prompt = "Use Icon"
+ panel.message = "Choose an image for \(item.displayTitle)."
+ guard panel.runModal() == .OK, let url = panel.url else { return }
+ guard let key = favicons.importCustomIcon(from: url) else { NSSound.beep(); return }
+ let old = store.item(id)?.tab?.customIconKey
+ store.setCustomIcon(key, for: id)
+ if let old { favicons.removeCustomIcon(old) }
+ }
+ if let key = tab.customIconKey {
+ add(menu, "Use Site Icon") {
+ store.setCustomIcon(nil, for: id)
+ favicons.removeCustomIcon(key)
+ }
+ }
add(menu, action: "renameTab", "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) }
@@ -86,6 +105,9 @@ enum SidebarMenus {
}
add(menu, action: "duplicateTab", "Duplicate") { _ = store.duplicateTab(id) }
add(menu, action: "copyURL", "Copy Link") { copy(CleanURL.withoutTrackers(tab.url)) }
+ if let url = URL(string: CleanURL.withoutTrackers(tab.url)), url.scheme?.hasPrefix("http") == true {
+ SharePicker.addMenu(to: menu, url: url)
+ }
add(menu, action: "muteTab", tab.muted ? "Unmute" : "Mute") {
store.setMuted(id, !tab.muted)
actions.performAction("muteTab:\(id)")
diff --git a/Sources/Cra/UI/SiteControlCenter.swift b/Sources/Cra/UI/SiteControlCenter.swift
index 59252fe..65b9d8c 100644
--- a/Sources/Cra/UI/SiteControlCenter.swift
+++ b/Sources/Cra/UI/SiteControlCenter.swift
@@ -811,6 +811,20 @@ final class SharePicker: NSObject, @preconcurrency NSSharingServicePickerDelegat
}
}
+ /// Arc's Share ▸ submenu on a sidebar tab: the same services, as menu items.
+ static func addMenu(to menu: NSMenu, url: URL) {
+ let sub = NSMenu()
+ for name in kept {
+ guard let service = NSSharingService(named: name), service.canPerform(withItems: [url]) else { continue }
+ let item = MenuItems.add(sub, service.title, image: service.image) { service.perform(withItems: [url]) }
+ item.image?.size = NSSize(width: 16, height: 16)
+ }
+ guard !sub.items.isEmpty else { return }
+ let share = NSMenuItem(title: "Share", action: nil, keyEquivalent: "")
+ share.submenu = sub
+ menu.addItem(share)
+ }
+
/// `done` runs when the list goes, `chose` when a service was picked.
func show(_ url: URL, relativeTo anchor: NSView, done: @escaping (_ chose: Bool) -> Void) {
let picker = NSSharingServicePicker(items: [url])
diff --git a/docs/arc-parity.md b/docs/arc-parity.md
index eed0f65..1533ee1 100644
--- a/docs/arc-parity.md
+++ b/docs/arc-parity.md
@@ -73,8 +73,8 @@ gains "New Profile".
| Where | Arc items Cra lacks |
|---|---|
-| Today tab | Share ▸, Change Icon… (Open in Split View and Archive Tabs Below done) |
-| Pinned tab | Share ▸, Change Icon…, Edit Pinned Page ▸ (Cra lists them flat on purpose, PR #55), Remove Pin (Add Split View done) |
+| Today tab | all done (Share ▸, Change Icon…, Open in Split View, Archive Tabs Below) |
+| Pinned tab | Edit Pinned Page ▸ (Cra lists them flat on purpose, PR #55), Remove Pin (Share ▸, Change Icon… and Add Split View done) |
| Space header / empty sidebar | Share Space… (*skip*), New Folder, Manage Spaces…, Delete Space (check order) |
| Toolbar address | Share ▸ (in the Site Control Center), Disable Shared Quotes (arc.net); the rest done |
| Library button | Show media ▸ Documents, Desktop, Screenshots, Arc Captures, Downloads |