diff --git a/ZeroTier One/PreferencesViewController.swift b/ZeroTier One/PreferencesViewController.swift index 95d2d882..0fd10281 100644 --- a/ZeroTier One/PreferencesViewController.swift +++ b/ZeroTier One/PreferencesViewController.swift @@ -10,9 +10,32 @@ import Cocoa class PreferencesViewController: NSViewController { + @IBOutlet var startupCheckBox: NSButton! + + let launchController = LaunchAtLoginController() + override func viewDidLoad() { super.viewDidLoad() // Do view setup here. + + if launchController.launchAtLogin { + startupCheckBox.state = NSOnState + } + else { + startupCheckBox.state = NSOffState + } + } + + @IBAction func onStartupCheckBoxChanged(sender: NSButton) { + let bundle = NSBundle.mainBundle() + let bundleURL = bundle.bundleURL + + if sender.state == NSOnState { + launchController.setLaunchAtLogin(true, forURL: bundleURL) + } + else { + launchController.setLaunchAtLogin(false, forURL: bundleURL) + } } } diff --git a/ZeroTier One/PreferencesViewController.xib b/ZeroTier One/PreferencesViewController.xib index 2a80a43a..62aef4c0 100644 --- a/ZeroTier One/PreferencesViewController.xib +++ b/ZeroTier One/PreferencesViewController.xib @@ -1,19 +1,33 @@ - + - + - + + - + + + + +