From decb4261d4e2218bbb28e0ce4e228e07782c569c Mon Sep 17 00:00:00 2001 From: Grant Limberg Date: Mon, 27 Jun 2016 19:14:15 -0700 Subject: wire up control to launch at startup in preferences --- ZeroTier One/PreferencesViewController.swift | 23 +++++++++++++++++++++++ ZeroTier One/PreferencesViewController.xib | 22 ++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) 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 @@ - + - + - + + - + + + + + -- cgit v1.2.3