summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2016-06-27 19:14:15 -0700
committerGrant Limberg <glimberg@gmail.com>2016-06-27 19:14:15 -0700
commitdecb4261d4e2218bbb28e0ce4e228e07782c569c (patch)
treebb9c69a34782fb799f83c3e7a6305bb1572c057f
parentb0971e3a01fb2a21c8ae91f41d1c916f51c072e0 (diff)
downloadinfinitytier-decb4261d4e2218bbb28e0ce4e228e07782c569c.tar.gz
infinitytier-decb4261d4e2218bbb28e0ce4e228e07782c569c.zip
wire up control to launch at startup in preferences
-rw-r--r--ZeroTier One/PreferencesViewController.swift23
-rw-r--r--ZeroTier One/PreferencesViewController.xib22
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 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10101" systemVersion="15E32" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10116" systemVersion="15F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10101"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10116"/>
</dependencies>
<objects>
- <customObject id="-2" userLabel="File's Owner" customClass="PreferencesViewController" customModuleProvider="target">
+ <customObject id="-2" userLabel="File's Owner" customClass="PreferencesViewController" customModule="ZeroTier_One" customModuleProvider="target">
<connections>
+ <outlet property="startupCheckBox" destination="XSk-jN-ner" id="nvL-b1-gza"/>
<outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
- <rect key="frame" x="0.0" y="0.0" width="480" height="272"/>
+ <rect key="frame" x="0.0" y="0.0" width="284" height="54"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+ <subviews>
+ <button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="XSk-jN-ner">
+ <rect key="frame" x="18" y="18" width="248" height="18"/>
+ <buttonCell key="cell" type="check" title="Start ZeroTier One on system startup" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="VkJ-h4-tHf">
+ <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+ <font key="font" metaFont="system"/>
+ </buttonCell>
+ <connections>
+ <action selector="onStartupCheckBoxChanged:" target="-2" id="zAQ-DJ-c3w"/>
+ </connections>
+ </button>
+ </subviews>
+ <point key="canvasLocation" x="365" y="208"/>
</customView>
</objects>
</document>