Skip to content

Commit

Permalink
🎨 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardodino committed Jun 5, 2023
1 parent d313af1 commit bcee962
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Sources/AboutWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AboutWindow {
let menuItem: NSMenuItem
private init() {
let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") ?? ""
menuItem = NSMenuItem(title: "About \(appName)", action: #selector(AboutWindow.show), keyEquivalent: "")
menuItem = NSMenuItem(title: "About \(appName)", action: #selector(show), keyEquivalent: "")
menuItem.target = self
}
@objc func show() {
Expand Down
1 change: 0 additions & 1 deletion Sources/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ enum State: Equatable {

@main
class AppDelegate: NSObject, NSApplicationDelegate {
private let notificationCenter = NotificationCenter.default
private var blinkStick: BlinkStick?
private var statusItem: StatusItem?
private var audioInput: AudioInput?
Expand Down
2 changes: 0 additions & 2 deletions Sources/AudioInput.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Foundation
import CoreAudio
import Cocoa

public extension Notification.Name {
Expand Down
2 changes: 1 addition & 1 deletion Sources/LaunchAtLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ final class LaunchAtLogin {
private(set) var menuItem: NSMenuItem

private init() {
menuItem = NSMenuItem(title: "Launch at login", action: #selector(LaunchAtLogin.toggle), keyEquivalent: "")
menuItem = NSMenuItem(title: "Launch at login", action: #selector(toggle), keyEquivalent: "")
menuItem.target = self
menuItem.state = state
}
Expand Down
23 changes: 10 additions & 13 deletions Sources/StatusItem.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Cocoa
import ServiceManagement

fileprivate extension NSApplication {
var quitMenuItem: NSMenuItem {
Expand All @@ -24,19 +23,17 @@ class StatusItem {

private let instance = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)

private lazy var menu: NSMenu = {
let menu = NSMenu()
menu.addItem(AboutWindow.shared.menuItem)
if #available(macOS 13.0, *) {
menu.addItem(LaunchAtLogin.shared.menuItem)
menu.addItem(NSMenuItem.separator())
}
menu.addItem(NSApplication.shared.quitMenuItem)
return menu
}()

init() {
instance.menu = menu
instance.menu = {
let menu = NSMenu()
menu.addItem(AboutWindow.shared.menuItem)
if #available(macOS 13.0, *) {
menu.addItem(LaunchAtLogin.shared.menuItem)
menu.addItem(NSMenuItem.separator())
}
menu.addItem(NSApplication.shared.quitMenuItem)
return menu
}()
}

func setIcon(_ icon: StateIcon) {
Expand Down

0 comments on commit bcee962

Please sign in to comment.