From e100cc0d7fca5c7479e3a826cddb20ad091b3507 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Thu, 14 Apr 2022 13:23:21 -0400 Subject: [PATCH] Add App Icon (#23) --- .gitattributes | 1 + Package.resolved | 4 ++-- Package.swift | 8 +++++++- Sources/tart/Commands/Run.swift | 14 +++++++++----- Sources/tart/Resources/Icon.png | 3 +++ 5 files changed, 22 insertions(+), 8 deletions(-) create mode 100644 .gitattributes create mode 100644 Sources/tart/Resources/Icon.png diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..24a8e87 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.png filter=lfs diff=lfs merge=lfs -text diff --git a/Package.resolved b/Package.resolved index 5ca09fb..8896f8c 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-argument-parser", "state" : { - "revision" : "82905286cc3f0fa8adc4674bf49437cab65a8373", - "version" : "1.1.1" + "revision" : "f3c9084a71ef4376f2fabbdf1d3d90a49f1fabdb", + "version" : "1.1.2" } } ], diff --git a/Package.swift b/Package.swift index 77df68e..dba98dc 100644 --- a/Package.swift +++ b/Package.swift @@ -7,13 +7,19 @@ let package = Package( platforms: [ .macOS(.v12) ], + products: [ + .executable(name: "tart", targets: ["tart"]) + ], dependencies: [ - .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.1"), + .package(url: "https://github.com/apple/swift-argument-parser", from: "1.1.2"), ], targets: [ .executableTarget(name: "tart", dependencies: [ .product(name: "ArgumentParser", package: "swift-argument-parser"), + ], + resources: [ + .process("Resources/Icon.png") ]), ] ) diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index d9a037d..1023cb6 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -12,7 +12,8 @@ struct Run: AsyncParsableCommand { var name: String @Flag var noGraphics: Bool = false - + + @MainActor func run() async throws { let vmDir = try VMStorage().read(name) vm = try VM(vmDir: vmDir) @@ -33,9 +34,12 @@ struct Run: AsyncParsableCommand { dispatchMain() } else { // UI mumbo-jumbo - let nsApp = await NSApplication.shared - await nsApp.setActivationPolicy(.regular) - await nsApp.activate(ignoringOtherApps: true) + let nsApp = NSApplication.shared + nsApp.setActivationPolicy(.regular) + nsApp.activate(ignoringOtherApps: true) + + let icon = Bundle.module.image(forResource: "Icon.png") + nsApp.applicationIconImage = icon struct MainApp: App { var body: some Scene { @@ -57,7 +61,7 @@ struct Run: AsyncParsableCommand { } } - await MainApp.main() + MainApp.main() } } } diff --git a/Sources/tart/Resources/Icon.png b/Sources/tart/Resources/Icon.png new file mode 100644 index 0000000..c6f8509 --- /dev/null +++ b/Sources/tart/Resources/Icon.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ffcf68332fd5a63ddd23ee941bbe45ec330c2d111aa17e252526a03b4b30facb +size 252602