Archived
1
This repository has been archived on 2020-06-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tagtunes/TagTunes/AppDelegate.swift
Kim Wittenburg 0a485ff42a Stuff…
2019-02-01 22:59:01 +01:00

54 lines
1.7 KiB
Swift
Executable File

//
// AppDelegate.swift
// TagTunes
//
// Created by Kim Wittenburg on 28.08.15.
// Copyright © 2015 Kim Wittenburg. All rights reserved.
//
import Cocoa
@NSApplicationMain
internal class AppDelegate: NSObject, NSApplicationDelegate {
/// The app's unsorted tracks window. This should be initalized when the app
/// launches.
var unsortedTracksWindowController: NSWindowController!
/// The app's unsorted tracks controller.
weak var unsortedTracksController: UnsortedTracksController!
internal func applicationDidFinishLaunching(aNotification: NSNotification) {
Preferences.sharedPreferences.initializeDefaultValues()
let storyboard = NSStoryboard(name: "Main", bundle: nil)
unsortedTracksWindowController = storyboard.instantiateControllerWithIdentifier("unsortedTracksWindowController") as? NSWindowController
unsortedTracksController.visible = true
}
internal func applicationShouldTerminateAfterLastWindowClosed(sender: NSApplication) -> Bool {
return true
}
@IBAction func toggleUnsortedTracks(sender: AnyObject?) {
unsortedTracksController.visible = !unsortedTracksController.visible
}
}
extension NSApplication {
/// The app`s unsorted tracks controller. When a `UnsortedTracksController`
/// is initialized it should this property to itself.
///
/// The value of this property is not retained.
var unsortedTracksController: UnsortedTracksController! {
set {
(delegate as? AppDelegate)?.unsortedTracksController = newValue
}
get {
return (delegate as? AppDelegate)?.unsortedTracksController
}
}
}