Add App Icon (#23)

This commit is contained in:
Fedor Korotkov 2022-04-14 13:23:21 -04:00 committed by GitHub
parent 75b5d63387
commit e100cc0d7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 8 deletions

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.png filter=lfs diff=lfs merge=lfs -text

View File

@ -5,8 +5,8 @@
"kind" : "remoteSourceControl", "kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser", "location" : "https://github.com/apple/swift-argument-parser",
"state" : { "state" : {
"revision" : "82905286cc3f0fa8adc4674bf49437cab65a8373", "revision" : "f3c9084a71ef4376f2fabbdf1d3d90a49f1fabdb",
"version" : "1.1.1" "version" : "1.1.2"
} }
} }
], ],

View File

@ -7,13 +7,19 @@ let package = Package(
platforms: [ platforms: [
.macOS(.v12) .macOS(.v12)
], ],
products: [
.executable(name: "tart", targets: ["tart"])
],
dependencies: [ 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: [ targets: [
.executableTarget(name: "tart", .executableTarget(name: "tart",
dependencies: [ dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"), .product(name: "ArgumentParser", package: "swift-argument-parser"),
],
resources: [
.process("Resources/Icon.png")
]), ]),
] ]
) )

View File

@ -12,7 +12,8 @@ struct Run: AsyncParsableCommand {
var name: String var name: String
@Flag var noGraphics: Bool = false @Flag var noGraphics: Bool = false
@MainActor
func run() async throws { func run() async throws {
let vmDir = try VMStorage().read(name) let vmDir = try VMStorage().read(name)
vm = try VM(vmDir: vmDir) vm = try VM(vmDir: vmDir)
@ -33,9 +34,12 @@ struct Run: AsyncParsableCommand {
dispatchMain() dispatchMain()
} else { } else {
// UI mumbo-jumbo // UI mumbo-jumbo
let nsApp = await NSApplication.shared let nsApp = NSApplication.shared
await nsApp.setActivationPolicy(.regular) nsApp.setActivationPolicy(.regular)
await nsApp.activate(ignoringOtherApps: true) nsApp.activate(ignoringOtherApps: true)
let icon = Bundle.module.image(forResource: "Icon.png")
nsApp.applicationIconImage = icon
struct MainApp: App { struct MainApp: App {
var body: some Scene { var body: some Scene {
@ -57,7 +61,7 @@ struct Run: AsyncParsableCommand {
} }
} }
await MainApp.main() MainApp.main()
} }
} }
} }

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ffcf68332fd5a63ddd23ee941bbe45ec330c2d111aa17e252526a03b4b30facb
size 252602