Skip to content

Commit

Permalink
Added sorting drives by case insensitive alphabetical order
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Kootz <[email protected]>
  • Loading branch information
Austin Kootz committed Apr 18, 2018
1 parent 7a9db51 commit fa06244
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Binary file not shown.
18 changes: 8 additions & 10 deletions EjectionSeat/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Cocoa
class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {

let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
var menu: NSMenu = NSMenu()
let menu: NSMenu = NSMenu()

func applicationDidFinishLaunching(_ aNotification: Notification) {
//statusItem.title = "EjectionSeat"
Expand All @@ -31,7 +31,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
menu.setSubmenu(makeSubMenu(), for: (menu.item(withTitle: "Eject"))!)
menu.addItem(NSMenuItem.separator())
menu.addItem(NSMenuItem(title: "Quit", action: #selector(AppDelegate.quit(_:)), keyEquivalent: "q"))

}

func menuNeedsUpdate(_ menu: NSMenu) {
Expand All @@ -43,10 +42,15 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
return nil
}
let subMenu = NSMenu()
var numKey = 0
var titles: [String] = []
for url in urls {
titles.append(url.pathComponents[url.pathComponents.endIndex-1])
}
titles = titles.sorted{$0.caseInsensitiveCompare($1) == .orderedAscending}
var numKey = 0
for title in titles {
numKey += 1
subMenu.addItem(NSMenuItem(title: url.pathComponents[url.pathComponents.endIndex-1], action: #selector(AppDelegate.eject(_:)), keyEquivalent: "\(numKey)"))
subMenu.addItem(NSMenuItem(title: title, action: #selector(AppDelegate.eject(_:)), keyEquivalent: "\(numKey)"))
}
return subMenu
}
Expand Down Expand Up @@ -97,11 +101,5 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
}
return urls;
}


func applicationWillTerminate(_ aNotification: Notification) {
}


}

0 comments on commit fa06244

Please sign in to comment.