2016-06-24 03:04:57 +00:00
|
|
|
//
|
|
|
|
// PreferencesViewController.swift
|
|
|
|
// ZeroTier One
|
|
|
|
//
|
|
|
|
// Created by Grant Limberg on 6/23/16.
|
|
|
|
// Copyright © 2016 ZeroTier, Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
class PreferencesViewController: NSViewController {
|
|
|
|
|
2016-06-28 02:14:15 +00:00
|
|
|
@IBOutlet var startupCheckBox: NSButton!
|
|
|
|
|
|
|
|
let launchController = LaunchAtLoginController()
|
|
|
|
|
2016-06-24 03:04:57 +00:00
|
|
|
override func viewDidLoad() {
|
|
|
|
super.viewDidLoad()
|
|
|
|
// Do view setup here.
|
2016-06-28 02:14:15 +00:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
2016-06-24 03:04:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|