Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Draw the Finder item's mark in the menu's text color on macOS 27

Țugui Dragoșc72c30de6148
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 69c090a2..7bce2e8a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -750,6 +750,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.
#### Every page
+- On macOS 27, Uninstall with Peel in Finder's menu shows its mark in the color of the menu's text, where it was black on a
+ dark menu.
- On macOS 27, a search field keeps the keyboard when the rows it filters come and go, so the next letter no longer
chooses a tool in the sidebar.
- A program another account has open, a build tool's daemon, and a script a running Node.js or Python process was
diff --git a/PeelFinder/FinderExtension.swift b/PeelFinder/FinderExtension.swift
index 01d891f0..d0a4b194 100644
--- a/PeelFinder/FinderExtension.swift
+++ b/PeelFinder/FinderExtension.swift
@@ -21,11 +21,36 @@ final class FinderExtension: FIFinderSync {
// On macOS 27 and later, AppKit usually hides menu item images. The glyph marks this item as Peel's in
// Finder's menu, so the item asks for its image to be shown.
if #available(macOS 27, *) {
+ item.image = Self.glyphInTheLabelColor()
item.preferredImageVisibility = .visible
}
return menu
}
+ /// Peel's glyph drawn in the color of a menu's text. Finder draws an extension's image as it comes, so a template
+ /// stays black, and on a dark menu it can hardly be seen.
+ private static func glyphInTheLabelColor() -> NSImage? {
+ let glyph = NSImage(resource: .peelGlyph)
+ let pixels = { (points: CGFloat) in Int(points * 2) }
+ guard let picture = NSBitmapImageRep(
+ bitmapDataPlanes: nil, pixelsWide: pixels(glyph.size.width), pixelsHigh: pixels(glyph.size.height),
+ bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .deviceRGB,
+ bytesPerRow: 0, bitsPerPixel: 0
+ ) else { return glyph }
+ picture.size = glyph.size
+ guard let context = NSGraphicsContext(bitmapImageRep: picture) else { return glyph }
+ NSGraphicsContext.saveGraphicsState()
+ NSGraphicsContext.current = context
+ let bounds = NSRect(origin: .zero, size: glyph.size)
+ glyph.draw(in: bounds)
+ NSColor.labelColor.set()
+ bounds.fill(using: .sourceIn)
+ NSGraphicsContext.restoreGraphicsState()
+ let image = NSImage(size: glyph.size)
+ image.addRepresentation(picture)
+ return image
+ }
+
@objc private func openInPeel(_ sender: NSMenuItem) {
guard
let application = selectedApplication,