diff --git a/macos/Sources/App/macOS/AppDelegate.swift b/macos/Sources/App/macOS/AppDelegate.swift index b9aab0ac4..028d4506c 100644 --- a/macos/Sources/App/macOS/AppDelegate.swift +++ b/macos/Sources/App/macOS/AppDelegate.swift @@ -928,7 +928,7 @@ class AppDelegate: NSObject, } else { GlobalEventTap.shared.disable() } - + updateAppIcon(from: config) } diff --git a/macos/Sources/Features/Custom App Icon/AppIcon.swift b/macos/Sources/Features/Custom App Icon/AppIcon.swift index 296bd10fe..13c6b83a1 100644 --- a/macos/Sources/Features/Custom App Icon/AppIcon.swift +++ b/macos/Sources/Features/Custom App Icon/AppIcon.swift @@ -56,7 +56,7 @@ enum AppIcon: Equatable, Codable { } } #endif - + func image(in bundle: Bundle) -> NSImage? { switch self { case .official: diff --git a/macos/Sources/Features/Custom App Icon/DockTilePlugin.swift b/macos/Sources/Features/Custom App Icon/DockTilePlugin.swift index ad750376d..a3e094f96 100644 --- a/macos/Sources/Features/Custom App Icon/DockTilePlugin.swift +++ b/macos/Sources/Features/Custom App Icon/DockTilePlugin.swift @@ -4,9 +4,9 @@ class DockTilePlugin: NSObject, NSDockTilePlugIn { // WARNING: An instance of this class is alive as long as Ghostty's icon is // in the doc (running or not!), so keep any state and processing to a // minimum to respect resource usage. - + private let pluginBundle = Bundle(for: DockTilePlugin.self) - + // Separate defaults based on debug vs release builds so we can test icons // without messing up releases. #if DEBUG @@ -84,7 +84,7 @@ class DockTilePlugin: NSObject, NSDockTilePlugIn { appIcon = pluginBundle.image(forResource: "AppIconImage")! NSWorkspace.shared.setIcon(appIcon, forFile: appBundlePath) } - + NSWorkspace.shared.noteFileSystemChanged(appBundlePath) dockTile.setIcon(appIcon) } diff --git a/macos/Sources/Features/Custom App Icon/Extensions/UserDefaults+AppIcon.swift b/macos/Sources/Features/Custom App Icon/Extensions/UserDefaults+AppIcon.swift index 9478cc5c3..d15644c93 100644 --- a/macos/Sources/Features/Custom App Icon/Extensions/UserDefaults+AppIcon.swift +++ b/macos/Sources/Features/Custom App Icon/Extensions/UserDefaults+AppIcon.swift @@ -3,26 +3,26 @@ import AppKit extension UserDefaults { private static let customIconKeyOld = "CustomGhosttyIcon" private static let customIconKeyNew = "CustomGhosttyIcon2" - + var appIcon: AppIcon? { get { // Always remove our old pre-docktileplugin values. defer { removeObject(forKey: Self.customIconKeyOld) } - + // Check if we have the new key for our dock tile plugin format. guard let data = data(forKey: Self.customIconKeyNew) else { return nil } return try? JSONDecoder().decode(AppIcon.self, from: data) } - + set { guard let newData = try? JSONEncoder().encode(newValue) else { return } - + set(newData, forKey: Self.customIconKeyNew) } } diff --git a/macos/Tests/CustomIconTests.swift b/macos/Tests/CustomIconTests.swift deleted file mode 100644 index df6310bbf..000000000 --- a/macos/Tests/CustomIconTests.swift +++ /dev/null @@ -1,20 +0,0 @@ -@testable import Ghostty -import Testing - -struct CustomIconTests { - @Test func migration() { - #expect(Ghostty.CustomAppIcon.blueprint == Ghostty.CustomAppIcon(string: "blueprint")) - - #expect(nil == Ghostty.CustomAppIcon(string: "~/downloads/some/file.png")) - - #expect(nil == Ghostty.CustomAppIcon(string: "#B0260C")) - - #expect(nil == Ghostty.CustomAppIcon(string: "plastic")) - - #expect(Ghostty.CustomAppIcon.customStyle(ghostColorHex: "#B0260C", screenColorHexes: [], iconFrame: .plastic) == Ghostty.CustomAppIcon(string: "#B0260C_plastic")) - - #expect(Ghostty.CustomAppIcon.customStyle(ghostColorHex: "#B0260C", screenColorHexes: ["#4F2C27"], iconFrame: .plastic) == Ghostty.CustomAppIcon(string: "#B0260C_#4F2C27_plastic")) - - #expect(Ghostty.CustomAppIcon.customStyle(ghostColorHex: "#B0260C", screenColorHexes: ["#4F2C27", "#B0260C"], iconFrame: .plastic) == Ghostty.CustomAppIcon(string: "#B0260C_#4F2C27_#B0260C_plastic")) - } -}